How to configure Claude Code for uninterrupted, automatic operation
This guide covers settings and hooks to eliminate permission prompts and maintain context across conversation compaction.
By default, Claude Code:
Both issues interrupt autonomous workflows. Here’s how to fix them.
Add to .claude/settings.local.json (project) or ~/.claude/settings.json (global):
{
"permissions": {
"defaultMode": "bypassPermissions"
}
}
This is the settings equivalent of --dangerously-skip-permissions.
claude --dangerously-skip-permissions
Press Shift+Tab during a session to toggle auto-accept mode.
Pre-approve specific tools instead of bypassing all:
{
"permissions": {
"allow": [
"Bash(git:*)",
"Bash(python:*)",
"Edit",
"Write",
"Read"
]
}
}
When conversations compact, Claude loses in-conversation context. Use hooks to automatically re-inject critical files.
Add to .claude/settings.local.json:
{
"hooks": {
"SessionStart": [
{
"matcher": "compact",
"hooks": [
{
"type": "command",
"command": "echo '=== POST-COMPACTION CONTEXT RELOAD ===' && echo '' && echo 'Please read: CLAUDE.md, NEXT.md, and the latest handover doc below:' && echo '' && LATEST=$(ls -t ai-memory/handover/*.md 2>/dev/null | head -1) && if [ -n \"$LATEST\" ]; then echo \"=== Latest Handover: $LATEST ===\"; echo ''; cat \"$LATEST\"; else echo 'No handover docs found in ai-memory/handover/'; fi"
}
]
}
]
}
}
How it works:
"matcher": "compact" - Only fires after compaction events.md file in ai-memory/handover/| Matcher | Fires When |
|---|---|
startup |
First session start |
resume |
/resume, --resume, or --continue |
clear |
/clear command |
compact |
Auto-compaction or /compact |
For files that should ALWAYS be available (not just after compaction), use imports in CLAUDE.md:
# Project Name
See @ai-memory/handover/latest-session.md
See @ai-memory/shared/project-context.md
See @NEXT.md
... rest of CLAUDE.md ...
The @ syntax imports files when CLAUDE.md is read. These survive compaction automatically.
File: .claude/settings.local.json
{
"hooks": {
"SessionStart": [
{
"matcher": "compact",
"hooks": [
{
"type": "command",
"command": "echo '=== POST-COMPACTION ===' && LATEST=$(ls -t ai-memory/handover/*.md 2>/dev/null | head -1) && if [ -n \"$LATEST\" ]; then cat \"$LATEST\"; fi"
}
]
}
]
},
"permissions": {
"defaultMode": "bypassPermissions",
"allow": [
"Bash(git:*)",
"Bash(python:*)",
"Edit",
"Write",
"Read"
]
},
"enableAllProjectMcpServers": true
}
| Item | Survives? | Mechanism |
|---|---|---|
| CLAUDE.md | Yes | Reloaded every session |
| CLAUDE.local.md | Yes | Always reloaded |
| Hooks | Yes | Config persists in settings |
| MCP servers | Yes | .mcp.json is reloaded |
| Conversation history | No | Compacted/summarized |
| In-conversation instructions | No | Lost after compaction |
For SPINE-managed projects, combine automation with context persistence:
ai-memory/
├── shared/ # Cross-session shared context
│ ├── project-context.md
│ ├── architecture.md
│ └── decisions.md
├── handover/ # Session handover documents
│ └── session-YYYY-MM-DD-topic.md
├── architect/ # Role-specific context
├── implementer/
├── reviewer/
└── backlog/ # Future work tracking
{
"hooks": {
"SessionStart": [
{
"matcher": "compact",
"hooks": [
{
"type": "command",
"command": "echo '=== SPINE CONTEXT RELOAD ===' && echo 'Read: CLAUDE.md, NEXT.md' && echo '' && LATEST=$(ls -t ai-memory/handover/*.md 2>/dev/null | head -1) && if [ -n \"$LATEST\" ]; then echo \"Latest handover: $LATEST\"; cat \"$LATEST\"; fi"
}
]
}
]
}
}
With bypassPermissions enabled:
archived/ folders for deleted files (never hard-delete)| Goal | Setting |
|---|---|
| No permission prompts | "defaultMode": "bypassPermissions" |
| Auto-reload after compact | SessionStart hook with "matcher": "compact" |
| Specific tool approval | "allow": ["Edit", "Bash(git:*)"] |
| Quick session toggle | Press Shift+Tab |