Claude Code Permission Denied Fix: File Access and Shell Command Errors (2026)
Claude Code asks for permission before modifying files or running shell commands. Sometimes it gets stuck in a loop of permission denials, or you accidentally denied something you need. Hereβs how to fix it.
The permission system
Claude Code has three permission levels:
| Action | Default | Can auto-approve |
|---|---|---|
| Read files | β Auto-approved | Always |
| Write files | β Asks first | Yes, configurable |
| Shell commands | β Asks first | Yes, configurable |
| Delete files | β Asks first | Yes, configurable |
| Network access | β Asks first | Yes, configurable |
When Claude asks βAllow this action?β and you press n, it remembers that denial for the session.
Fix 1: Reset session permissions
If you accidentally denied a permission:
# Start a new session (clears all permission decisions)
/clear
# Or rewind to before the denial
# Double-tap Esc
Thereβs no way to un-deny a specific permission within a session. Starting fresh or rewinding is the cleanest fix.
Fix 2: Configure auto-approve in settings
For actions you always want to allow:
// .claude/settings.json in your project root
{
"permissions": {
"allow": [
"read_file",
"list_directory",
"search_files",
"write_file",
"shell_command"
],
"deny": [
"delete_file"
]
}
}
This auto-approves file writes and shell commands while still blocking deletions. Adjust based on your trust level.
Warning: Auto-approving shell commands means Claude can run anything without asking. Only do this on projects where you trust the codebase and have git to revert changes.
Fix 3: Directory access issues
Claude Code can only access files in your current working directory and subdirectories:
# This works
cd /Users/you/project
claude "Read src/app.ts"
# This fails β outside project directory
claude "Read /etc/hosts"
claude "Read ../other-project/file.ts"
If you need Claude to access files outside the project:
# Option 1: Start Claude from a parent directory
cd /Users/you
claude "Compare project-a/src/auth.ts with project-b/src/auth.ts"
# Option 2: Copy the file into your project
cp ../other-project/reference.ts ./tmp/
claude "Read tmp/reference.ts for reference"
Fix 4: Shell command blocked by OS
On macOS, the system might block Claudeβs shell commands:
# If you see "Operation not permitted"
# Grant Terminal full disk access:
# System Settings β Privacy & Security β Full Disk Access β Add Terminal
On Linux, SELinux or AppArmor might interfere:
# Check SELinux
getenforce
# If "Enforcing", temporarily set to permissive for testing
sudo setenforce 0
Fix 5: npm/pip permission errors
Claude tries to install packages and gets permission denied:
# npm: use --prefix or fix permissions
npm config set prefix ~/.npm-global
export PATH=~/.npm-global/bin:$PATH
# pip: use --user flag
# Tell Claude: "Use pip install --user when installing packages"
# Or use a virtual environment
python -m venv .venv
source .venv/bin/activate
# Then start Claude β it'll use the venv
Fix 6: Git permission errors
# "fatal: not a git repository"
# Initialize git first
git init
git add -A
git commit -m "Initial commit"
# "Permission denied (publickey)"
# Claude can't push to remote β this is expected
# Push manually after Claude makes changes
git push origin main
Claude Code works best in git repositories. It uses git for tracking changes and enabling /rewind. Always initialize git before starting a Claude session.
Related: How to Use Claude Code Β· Claude Code Routines Guide Β· Claude Code vs Codex CLI vs Gemini CLI Β· Ollama Out of Memory Fix Β· AI Agent Security