{"record":{"id":"97d4a7cf9fe9823e","repo":"rohitg00/agentmemory","slug":"claude-code-hooks-fallback-skipped-hookresult-r-97d4a7","errorCode":null,"errorMessage":"Claude Code hooks fallback skipped: ${hookResult.reason}. MCP wiring still applied.","messagePattern":"Claude Code hooks fallback skipped: (.+?)\\. MCP wiring still applied\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cli/connect/claude-code.ts","lineNumber":111,"sourceCode":"    writeJsonAtomic(CLAUDE_JSON, next);\n\n    const verify = readJsonSafe<ClaudeConfig>(CLAUDE_JSON);\n    if (!entryMatches(verify?.mcpServers?.[\"agentmemory\"])) {\n      p.log.error(\n        `Verification failed: ${CLAUDE_JSON} did not contain mcpServers.agentmemory after write.`,\n      );\n      return { kind: \"skipped\", reason: \"verification-failed\" };\n    }\n\n    logInstalled(\"Claude Code\", CLAUDE_JSON);\n    p.log.info(\n      \"Restart Claude Code (or run `/mcp` inside a session) to pick up the new server.\",\n    );\n\n    if (opts.withHooks) {\n      const hookResult = installClaudeHooks(opts);\n      if (hookResult.kind === \"skipped\") {\n        p.log.warn(\n          `Claude Code hooks fallback skipped: ${hookResult.reason}. MCP wiring still applied.`,\n        );\n      }\n    }\n\n    return { kind: \"installed\", mutatedPath: CLAUDE_JSON, backupPath };\n  },\n};\n\n/**\n * Merge the bundled `plugin/hooks/hooks.json` into\n * `~/.claude/settings.json`'s top-level `hooks` field with absolute\n * script paths. Use this when agentmemory is NOT installed through\n * `/plugin marketplace add` (e.g. MCP standalone wiring), so the\n * hook scripts survive version bumps without `${CLAUDE_PLUGIN_ROOT}`\n * expansion (issue #508).\n *\n * Re-install strips entries whose command points under","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/rohitg00/agentmemory/blob/e04ba88819c365c9acf9d6661ea802143e728bd6/src/cli/connect/claude-code.ts#L93-L129","documentation":"agentmemory's `agentmemory connect claude-code` command wires the Claude Code MCP server into ~/.claude.json, and optionally installs lifecycle hooks. When --with-hooks is passed but installClaudeHooks() returns a 'skipped' result, the CLI logs this warning instead of failing, because MCP wiring already succeeded. It is informational: the connect succeeded, only the hooks add-on was not applied.","triggerScenarios":"Running `agentmemory connect claude-code --with-hooks` when installClaudeHooks() returns { kind: \"skipped\", reason } — e.g. the Claude Code settings file is missing or unparseable, the target directory does not exist, or a hook-merge precondition fails.","commonSituations":"Users with a fresh machine where Claude Code has never been launched (no settings file), users who deleted or renamed ~/.claude, custom CLAUDE_CONFIG_DIR setups, or permission problems on the settings path. The MCP wiring still applied, so developers are confused why hooks (context injection) don't appear after a 'successful' connect.","solutions":["Read the interpolated hookResult.reason in the warning message — it states exactly why hooks were skipped (e.g. file missing, merge refused).","Ensure Claude Code has been launched at least once so ~/.claude/settings.json exists, then re-run `agentmemory connect claude-code --with-hooks`.","Check that the Claude config path (CLAUDE_JSON / settings dir) is writable by the user running the command.","If hooks are not needed, ignore the warning — MCP wiring was still applied; verify with `claude mcp list` or /mcp in a session.","Re-run the connect command after fixing the environment; connect is idempotent and safe to repeat."],"exampleFix":"// before\nagentmemory connect claude-code --with-hooks\n// -> warning: Claude Code hooks fallback skipped: settings file not found ...\n\n// after\nclaude --version        # launch once so ~/.claude/settings.json exists\nls ~/.claude/settings.json\nagentmemory connect claude-code --with-hooks   # re-run; hooks installed","handlingStrategy":"validation","validationCode":"import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nconst claudeDir = join(process.env.HOME ?? \"\", \".claude\");\nif (!existsSync(join(claudeDir, \"settings.json\"))) {\n  console.error(\"Claude Code settings not found — launch `claude` once before `connect claude-code --with-hooks`.\");\n  process.exit(1);\n}","typeGuard":"type HookInstallResult = { kind: \"installed\" } | { kind: \"skipped\"; reason: string };\nfunction wasSkipped(r: unknown): r is { kind: \"skipped\"; reason: string } {\n  return typeof r === \"object\" && r !== null && \"kind\" in r && (r as any).kind === \"skipped\";\n}","tryCatchPattern":"try {\n  const hookResult = installClaudeHooks(opts);\n  if (hookResult.kind === \"skipped\") {\n    console.warn(`Hooks not installed (${hookResult.reason}); MCP wiring is unaffected.`);\n  }\n} catch (err) {\n  console.warn(\"Hook install failed; MCP wiring remains applied:\", err);\n}","preventionTips":["Launch Claude Code at least once before running `agentmemory connect claude-code --with-hooks`.","Verify ~/.claude/settings.json exists and is writable before connecting.","Read the `reason` in the warning instead of assuming connect failed — MCP wiring is independent.","Re-run connect after environment fixes; it is idempotent."],"tags":["cli","hooks","claude-code","install"],"backgroundTag":"hooks-install-skipped","analyzedSha":"e04ba88819c365c9acf9d6661ea802143e728bd6","analyzedAt":"2026-08-30T01:07:40.754Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}