[BUG] --dangerously-skip-permissions does not bypass "edit its own settings" prompt for .claude/ directory writes
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When running Claude Code with --dangerously-skip-permissions, writes to files inside ~/.claude/ still trigger a permission prompt:
Do you want to make this edit to .md?
- Yes
❯ 2. Yes, and allow Claude to edit its own settings for this session
- No
This happens every new session, defeating the purpose of the flag.
## Steps to Reproduce
- Configure
settings.jsonwith"defaultMode": "bypassPermissions"and"skipDangerousModePermissionPrompt": true - Launch with
claude --dangerously-skip-permissions - Use any skill that writes files to
~/.claude/(e.g., session-handoff, save-plan, or auto-memory) - The "edit its own settings" prompt appears despite the flag
## Expected Behavior
--dangerously-skip-permissions should bypass ALL permission prompts, including writes to .claude/ directory. The flag name itself implies full bypass.
## Actual Behavior
A hardcoded "protected directory" check for .claude/ overrides the --dangerously-skip-permissions flag. The user must manually approve once per session
(option 2).
## Environment
- Claude Code version: 2.1.81
- OS: Windows 11 Pro
- Settings:
defaultMode: "bypassPermissions",skipDangerousModePermissionPrompt: true - Multiple plugins/skills enabled that write to
~/.claude/
## Impact
This breaks autonomous workflows and CI/CD usage where no human is present to approve. It also creates friction for power users who have explicitly opted into
full bypass mode.
What Should Happen?
When --dangerously-skip-permissions flag is active, ALL permission prompts should be bypassed — including writes to the .claude/ directory. The flag name
explicitly says "dangerously skip permissions", so no permission check should override it. Currently a hardcoded "protected directory" check for .claude/ still
triggers the "edit its own settings" prompt every session, which defeats the purpose of the flag and breaks autonomous/unattended workflows.
Error Messages/Logs
Steps to Reproduce
- Set
"defaultMode": "bypassPermissions"and"skipDangerousModePermissionPrompt": truein~/.claude/settings.json - Launch Claude Code with
claude --dangerously-skip-permissions - Trigger any action that writes a file inside
~/.claude/(e.g., a plugin skill writing a .md file, auto-memory saving to~/.claude/projects/*/memory/, or
session-handoff creating a handoff file)
- A permission prompt appears: "Do you want to make this edit to <file>.md? 1. Yes / 2. Yes, and allow Claude to edit its own settings for this session / 3. No"
- This happens on every new session, regardless of the flag
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.81 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
_No response_
16 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Same as #37253 and #37157 — \
~/.claude/\is a hardcoded protected directory that even \--dangerously-skip-permissions\won't bypass. This is by design to prevent the model from modifying its own hooks and settings.Workaround — a PreToolUse hook that auto-approves writes to specific \
.claude/\subdirectories:\
\\bash\INPUT=\$(cat)
TOOL=\$(echo "\$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
FILE=\$(echo "\$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)
[[ "\$TOOL" != "Edit" && "\$TOOL" != "Write" ]] && exit 0
case "\$FILE" in
*/\.claude/commands/*|*/\.claude/skills/*|*/\.claude/agents/*|*/\.claude/rules/*)
jq -n '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow","permissionDecisionReason":".claude subdirectory auto-approved"}}'
exit 0 ;;
esac
exit 0
\
\This selectively allows writes to safe subdirectories while keeping \
hooks/\and \settings.json\protected.Additional findings — PreToolUse hooks also cannot bypass this
After investigating the workaround suggested in the comments (PreToolUse hook with
permissionDecision: "allow"), I confirmed that it does not work either.What I tried
PreToolUsecommand hook that returns:settings.jsonwith matcherEdit|Writejqavailable, script executable, correct JSON output verifiedResult
The "Do you want to make this edit? / Yes, and allow Claude to edit its own settings for this session" prompt still appears despite the hook returning
allow.Root cause analysis
The
.claude/self-edit protection operates at a separate layer from the permission system:| Layer | What controls it | Can be bypassed? |
|---|---|---|
| Permission rules |
settings.jsonallow/deny lists | Yes (via--dangerously-skip-permissions) || PreToolUse hooks | Hook scripts returning
permissionDecision| Yes (hooks can override) || Built-in self-edit protection | Hardcoded in source | No — nothing bypasses this |
The self-edit protection for
.claude/fires after hooks, overriding anypermissionDecision: "allow"from PreToolUse hooks. This means:--dangerously-skip-permissions→ still prompts ❌defaultMode: "bypassPermissions"→ still prompts ❌skipDangerousModePermissionPrompt: true→ only skips the initial warning, not per-edit prompts ❌permissionDecision: "allow"→ still prompts ❌Impact
This affects all users with plugins/skills that write to
~/.claude/(auto-memory, session-handoff, save-plan, insights, etc.). The prompt appears every new session, requiring manual approval via option 2.Suggestion
Either:
--dangerously-skip-permissionstruly bypass everything (the flag name implies this)"allowSelfEdit": truethat explicitly opts into bypassing the self-edit protectionEnvironment
@adelfino69 Thanks for testing this so thoroughly. Your analysis is correct — my workaround was wrong for the
.claude/self-edit case.The key finding from your table is that the built-in self-edit protection runs after PreToolUse hooks and overrides the
allowdecision. So even a correctly configured hook returningpermissionDecision: "allow"gets ignored for.claude/writes.To clarify for others reading: PreToolUse hooks with
permissionDecisiondo work for overriding protection on.git/and.vscode/directories (the other hardcoded protected paths). The.claude/self-edit check is a separate, unhookable layer that none of the current bypass mechanisms can reach.Agree that option 1 or 3 from your suggestions would resolve this cleanly.
Idea... Have you tried adding a permission in your project or globally in the settings.json?
Or using Read(), Write(), etc.
I can confirm this doesn't work either. My
settings.jsonalready has the most permissive configuration possible:EditandWriteare allowed without any path restrictions, plusbypassPermissionsmode is active. Adding"Edit(~/.claude/**)"would be redundant — unrestricted"Edit"already covers every path.The self-edit prompt for
.claude/still appears every session.This confirms @yurukusa's analysis: the
.claude/protection is a hardcoded layer that operates independently of the entire permissions system. No combination of settings can bypass it.PreToolUse can't bypass the built-in protected-directory check because it runs before those checks — the
"allow"gets overridden downstream.PermissionRequest runs after the built-in checks, so it sticks:
~/.claude/hooks/allow-claude-dir.sh:Confirmed working in #37836, #36044, #36282.
I tested the
allow-claude-dir.shand it is NOT working. claude2.1.81on windows. pretty frustrating.Hitting this constantly. I have hooks and agents that legitimately need to edit files in .claude/hooks/ and .claude/skills/, and the permission prompt interrupts every single operation. When I'm away from the screen the prompt times out and registers as a rejection, which derails the entire workflow. Please give us a way to allowlist specific .claude/ subdirectories.
Did you try the
allow-claude-dir.shtrick above?This completely allows all edits for me, no need for a script.
Confirmed working on Windows 11 —
printfinline is the cleanest solution.After several days of testing every possible bypass (documented earlier in this thread), I can confirm that @openclosure's
PermissionRequest+printfapproach fully resolves the issue on Windows.What works
Tested writes to
~/.claude/plans/,~/.claude/projects/*/memory/, and other.claude/subdirectories — no permission prompt appeared.Full working
settings.json(Windows 11, Claude Code 2.1.86)For anyone struggling with this on Windows, here's the minimal configuration that works:
Key points:
defaultMode: "bypassPermissions"+skipDangerousModePermissionPrompt: truehandle all normal permission promptsPermissionRequesthook handles the.claude/self-edit prompt specifically — this is the one that nothing else can bypassprintfworks natively in Git Bash on Windows — no need to installjqor create external scriptstimeout: 5is optional but recommended to avoid hanging if something goes wrongWhy the script-based approach failed on Windows
@jasonswearingen reported that
allow-claude-dir.shdidn't work on Windows (claude 2.1.81). I can confirm the same — I had @yurukusa's script configured in mysettings.jsonbut the prompt kept appearing every session.The likely root cause: when Claude Code invokes
bashon Windows (Git Bash), the shell environment may not havejqin itsPATH, or the$(cat)stdin pipe behaves differently. The script fails silently (no output) → Claude falls back to the built-in prompt.The
printfinline approach eliminates all external dependencies — nojq, no separate.shfile, no stdin parsing. It just returns the allow decision directly.Important:
PermissionRequestvsPreToolUseThis is the key technical detail that took us a while to figure out. There are two different hook events, and only one works for this:
| Hook event | When it runs | Can bypass
.claude/self-edit? ||------------|-------------|----------------------------------|
|
PreToolUse| Before permission checks | ❌ No — the self-edit protection runs after and overrides it ||
PermissionRequest| After built-in checks, when a prompt would be shown | ✅ Yes — it intercepts the prompt before the user sees it |If you're using
PreToolUsewithpermissionDecision: "allow", switch toPermissionRequestwithdecision: { behavior: "allow" }. Note the different JSON structure too.Summary of all approaches tested
| Approach | Works? | Why |
|----------|--------|-----|
|
--dangerously-skip-permissions| ❌ |.claude/self-edit protection is a separate hardcoded layer ||
defaultMode: "bypassPermissions"| ❌ | Same reason ||
permissions.allow: ["Edit", "Write"](unrestricted) | ❌ | Permission allow lists don't override self-edit protection ||
PreToolUsehook returningpermissionDecision: "allow"| ❌ | Runs before the self-edit check — gets overridden downstream ||
PermissionRequesthook with external bash script +jq| ⚠️ | Works on Linux/macOS, but unreliable on Windows (silentjq/stdin failures) ||
PermissionRequesthook with inlineprintf| ✅ | Runs after the self-edit check, no external dependencies, cross-platform |Note on scope
This hook approves all
Edit|Writeoperations that trigger a permission prompt, not just.claude/writes. If you want to be more selective, you could wrap theprintfin a bash conditional — but if you're already inbypassPermissionsmode, the only prompts reachingPermissionRequestshould be the.claude/self-edit ones anyway.Thanks to @yurukusa for identifying
PermissionRequestas the correct hook event and explaining the execution order, and @openclosure for the elegantprintfsimplification.That said, I still think this should be fixed upstream —
--dangerously-skip-permissionsshould mean what it says. But at least we have a solid, copy-pasteable workaround now.@chrislloyd the issue still exists as of
v 2.1.126, please reopen.EDIT: I upgraded to latest and now the issue is gone, so not sure. either way, yeah okay to keep closed.
Shouldn't it be fixed since that version actually?
https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#21126
I upgraded to latest and now the issue is gone, so not sure. either way, yeah okay to keep closed.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.