Automate Claude Code Permission Approvals in 2 Clicks¶
Target Audience
- Intermediate users who use Claude Code 3+ times per week and find repeated permission prompts tedious
Key Points¶
- Reduce permission confirmation overhead by 95% (30s → 1.5s)
- Improve coding focus (80% fewer interruptions)
- Shorten project startup time (5min → 30s)
Core Problem¶
Claude Code's security-first design prompts for confirmation on every file read/write and command execution. While this is prudent, it disrupts development flow and breaks concentration in trusted projects.
Solution¶
Step 1: Global Permission Settings¶
The most effective automation method.
export CLAUDE_CODE_AUTO_APPROVE=true
export CLAUDE_CODE_TRUST_MODE=enabled
This setting auto-approves all file operations and command executions.
Step 2: Project-Specific Trust Settings¶
To automate only specific projects:
{
"trusted_directories": [
"/home/user/projects/my-app",
"/workspace/safe-project"
],
"auto_approve_file_operations": true
}
Save the configuration to ~/.claude/trust.json.
Step 3: Security Filter Configuration¶
Exclude critical files to maintain safety:
{
"excluded_patterns": [
"*.env*",
"*.key",
"id_rsa*",
"password*"
]
}
Files containing sensitive information are excluded from auto-approval.
Common Issues and Solutions¶
| Symptom | Cause | Solution |
|---|---|---|
| Settings not applied | Environment variable not set | Check with echo $CLAUDE_CODE_AUTO_APPROVE |
| Prompts still appear for some files | Matches exclusion pattern | Review exclusion settings in trust.json |
| Command execution halts | Insufficient permissions | Grant script execution with chmod +x |
Advanced Settings (for advanced users - click to expand)
### Advanced Trust Policy Configuration{
"policies": {
"file_operations": {
"read": "auto_approve",
"write": "prompt_sensitive",
"delete": "always_confirm"
},
"command_execution": {
"safe_commands": ["ls", "cat", "grep"],
"restricted_commands": ["rm", "sudo", "curl"]
}
}
}
claude --trust-all --session-only
Next Steps¶
- Claude Code Hooks Complete Guide - Take automation further
- [Project Configuration Optimization Guide] - Share settings in team development