Automate Claude Code Permission Approval in 2 Clicks: Setup Guide¶
Target Audience
- Intermediate users who use Claude Code 3+ times per week and find repeated permission prompts tedious
Key Points¶
- Reduce permission prompt overhead by 95% (30s → 1.5s)
- Improve coding focus (80% fewer interruptions)
- Shorten project startup time (5min → 30s)
Core Problem¶
Claude Code is designed with security as a priority, prompting for confirmation on every file read/write or command execution. However, in trusted projects, these prompts disrupt development flow and interrupt your thought process.
Solution¶
Step 1: Global Permission Settings¶
The most effective automation method.
export CLAUDE_CODE_AUTO_APPROVE=true
export CLAUDE_CODE_TRUST_MODE=enabled
With this configuration, all file operations and command executions will be auto-approved.
Step 2: Project-Specific Trust Settings¶
To automate only for specific projects:
{
"trusted_directories": [
"/home/user/projects/my-app",
"/workspace/safe-project"
],
"auto_approve_file_operations": true
}
Save the configuration file 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 will be 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 appear for some files | Matches exclusion pattern | Review exclusion settings in trust.json |
| Command execution hangs | Insufficient permissions | Grant script execution permission with chmod +x |
Advanced Configuration (For Advanced Users - Click to Expand)
### Advanced Trust Policy Settings{
"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] - How to share settings in team development