Claude Code

Configuration debugging and the .claude directory

Diagnose CLAUDE.md, settings, hooks, MCP, skills, permissions, local directories, data flow, and cleanup.

When rules are ignored, hooks do not run, MCP is missing, or skills/settings do not apply, inspect what Claude Code actually loaded instead of guessing.

#Start with these commands

CommandInspect
/contextSystem prompt, memory, skills, subagents, MCP, messages
/memoryLoaded CLAUDE.md, rules, and auto memory
/skillsProject, user, and plugin skills
/hooksRegistered hooks and events
/mcpServers, connections, and approvals
/permissionsSources of allow/ask/deny rules
/doctorSchema, installation, duplicate subagent names
/statusSettings sources, policy, login, model
/debug <problem>Enable logs and investigate with Claude

#Configuration locations

FilePurposeCommit?
CLAUDE.mdProject conventions and commandsYes
.claude/CLAUDE.mdAdditional project memoryYes
.claude/settings.jsonShared settings, permissions, hooksYes, without keys
.claude/settings.local.jsonPersonal project overridesNo
~/.claude/settings.jsonUser preferences, environment, permissionsNo
.mcp.jsonProject MCP serversYes, use environment references for secrets
~/.claude.jsonApp/login/project state and some MCP dataDo not hand-edit business settings here
.claude/commands/Slash commandsYes
.claude/skills/<name>/SKILL.mdProject skillYes
.claude/agents/Custom subagentsYes
.claude/output-styles/Output stylesProject or user scope

~/.claude.json is not a settings file. Put permissions, hooks, and env in settings.json.

#Settings merging and precedence

Ordinary precedence:

  1. Managed policy.
  2. Command-line configuration; individual flags/environment variables have feature-specific precedence.
  3. Project local settings.
  4. Shared project settings.
  5. User settings.

Permission lists merge. Conflicts follow deny → ask → allow, not simple replacement.

SymptomCauseFix
User setting ignoredProject local key overrides itInspect /status sources
Hook absentWritten into a separate file or ~/.claude.jsonPut it under hooks in settings
MCP absent.mcp.json placed inside .claudeMove project MCP definition to repository root
MCP lacks environmentSettings env differs from server process configurationDefine server env in .mcp.json
Skill absentStored as .claude/skills/name.mdUse name/SKILL.md
Subdirectory memory absentLoaded on demandRead a file in that directory

#CLAUDE.md does not apply

/memory
/context all

If absent, check its location and launch directory. If present but ineffective, rules may be vague, conflicting, or too long.

More reliable instructions:

  • Name the actual test command.
  • State directory ownership, such as React components in src/components.
  • Enforce restrictions with permissions/hooks instead of prose alone.
  • Split large repositories by directory instead of making the root file encyclopedic.

#Hooks do not trigger

/hooks
claude --debug hooks
SymptomCause
Missing from /hooksSettings not loaded or wrong key
Matcher missesCase-sensitive tool name; use Bash, Edit, Write
Multiple-tool matcher failsUse one regex string such as EditWrite
Schema error/doctor reports it and the hook is discarded
Unstable pathUse CLAUDE_PROJECT_DIR or an absolute path
Wrong exit behaviorFollow the event's JSON/stderr contract

#MCP is missing

claude mcp list
claude mcp get <name>
claude --debug mcp
SymptomAction
Project server pending approvalApprove in /mcp
Server failedInspect stderr, command, args, env
Connected with zero toolsReconnect and inspect debug output
OAuth failureclaude mcp login <name>
Relative paths fail in some directoriesUse absolute paths
Many tools disrupt cachingUse supported tool search or split servers

#Compare against clean configuration

Safe mode disables most customizations:

claude --safe-mode

If the problem disappears, investigate CLAUDE.md, skills, plugins, hooks, MCP, custom commands, agents, output styles, and workflows.

For a clean directory:

mkdir -p /tmp/claude-clean
cd /tmp
CLAUDE_CONFIG_DIR=/tmp/claude-clean claude

Notes:

  • Managed policy may still apply.
  • macOS credentials may remain in Keychain rather than being isolated by CLAUDE_CONFIG_DIR.
  • Linux/Windows may require credentials again; Passion8 uses its gateway variables.

#Organize .claude

Recommended layout:

.claude/
  settings.json
  settings.local.json
  commands/
    review.md
  skills/
    release-check/
      SKILL.md
  agents/
    qa-reviewer.md
  output-styles/
    concise.md
AvoidReason
.claude/.mcp.jsonProject MCP belongs at repository root
.claude/skills/foo.mdA skill requires a directory and SKILL.md
.claude/hooks.jsonOrdinary hooks belong in settings; plugins can have separate hook files
Real keys in project settingsProject files are easy to commit accidentally

#Data flow and local data

Claude Code sends required prompts, tool results, file excerpts, and MCP output to the selected provider. With Passion8, also consider gateway logging, billing, and retention policies.

DataLocation/destinationConsideration
Project filesEnter context after readsRestrict sensitive paths
User settings/state~/.claude and ~/.claude.jsonDo not commit
Shell outputCurrent session contextAvoid secrets and excessive logs
MCP outputCurrent session contextFilter database/browser results
TelemetryControlled by OTel environmentAvoid raw API bodies
WebFetch domain checksMay use a safety check serviceAccount for outbound domains

For stricter projects:

  • Deny Read on .env and .env.*.
  • Ask or hook-check curl, wget, and database writes.
  • Never print full keys in hook stderr.
  • Collect only necessary monitoring fields; avoid OTEL_LOG_RAW_API_BODIES.

#Cache effects

Debugging often changes prompt prefixes:

ActionEffect on five-minute / one-hour caching
New session after editing CLAUDE.mdChanged prefix usually creates a cache entry
Change permissionsOften small, but changed tool availability can alter prefixes
Add/remove MCP serverChanged schemas can miss
Add/remove skills/pluginsInstructions or tools can change
Safe modeDifferent prefix; unsuitable for normal hit-rate evaluation
Clean config directoryUseful diagnosis, not representative project caching

#Official references

Support

Need help?

For setup, billing, or model issues, email us. Check the status page for uptime.

WeChat / QQ support is available at the bottom right.