claude-code - 💡(How to fix) Fix PreToolUse hook's permissionDecision ignored for .claude/ directory in bypassPermissions mode [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#51801Fetched 2026-04-22 07:52:28
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×4commented ×1

Root Cause

.claude/agents/, .claude/skills/, and .claude/channels/ contain user-authored content (agent definitions, skill manuals, access configs), not security-sensitive settings like settings.json. Users who opt into bypassPermissions should be able to allow writes to these subdirectories via hook logic, especially for automation (e.g., agent orchestration system updates, channel access sync).

Code Example

[Hook] ALLOW .claude/ path: /Users/sanokazuya/.claude/channels/discord/access.json
[Claude Code] Permission required: Write to /Users/sanokazuya/.claude/channels/discord/access.json
User prompted for approval
RAW_BUFFERClick to expand / collapse

Problem

In bypassPermissions mode, write operations to .claude/ directory always trigger user confirmation prompts, even when:

  • User has defaultMode: "bypassPermissions" set
  • skipDangerousModePermissionPrompt: true is enabled
  • Write(*) / Edit(*) are in the allow list
  • A PreToolUse hook returns {"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow"}}

The hook fires and logs its decision, but the built-in .claude/ protection overrides it, making the hook ineffective.

Why this matters

.claude/agents/, .claude/skills/, and .claude/channels/ contain user-authored content (agent definitions, skill manuals, access configs), not security-sensitive settings like settings.json. Users who opt into bypassPermissions should be able to allow writes to these subdirectories via hook logic, especially for automation (e.g., agent orchestration system updates, channel access sync).

Current behavior

[Hook] ALLOW .claude/ path: /Users/sanokazuya/.claude/channels/discord/access.json
[Claude Code] Permission required: Write to /Users/sanokazuya/.claude/channels/discord/access.json
→ User prompted for approval

Desired behavior

Option B (recommended): Allow PreToolUse hook's permissionDecision: "allow" to take precedence over built-in .claude/ protection.

Alternative options:

  • (A) Exempt .claude/agents/, .claude/skills/, .claude/commands/, .claude/channels/ from built-in protection in bypassPermissions mode
  • (C) Add a protectedDirectories setting for customizable protection

Environment

  • Claude Code v2.1.117
  • macOS
  • bypassPermissions mode with Write(*) and PreToolUse hook

extent analysis

TL;DR

Implementing Option B by modifying the Claude Code to prioritize the PreToolUse hook's permissionDecision over the built-in .claude/ protection is likely the most effective fix.

Guidance

  • Review the Claude Code's permission handling logic to identify where the built-in .claude/ protection is overriding the PreToolUse hook's decision.
  • Consider adding a conditional check to respect the permissionDecision from the PreToolUse hook when bypassPermissions mode is enabled and skipDangerousModePermissionPrompt is true.
  • Evaluate the feasibility of implementing Option A or Option C as alternative solutions, depending on the desired level of customization and security.
  • Test any changes with various scenarios to ensure the PreToolUse hook's decisions are correctly overriding the built-in protection for .claude/ subdirectories.

Example

// Pseudocode example of conditional check
if (bypassPermissionsMode && skipDangerousModePermissionPrompt && preToolUseHookDecision === 'allow') {
  // Override built-in .claude/ protection with hook's decision
  allowWriteOperation = true;
}

Notes

The solution may require modifications to the Claude Code's core logic and should be thoroughly tested to avoid introducing security vulnerabilities.

Recommendation

Apply workaround Option B, as it directly addresses the issue by giving precedence to the PreToolUse hook's decision, aligning with the desired behavior for users who opt into bypassPermissions mode.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix PreToolUse hook's permissionDecision ignored for .claude/ directory in bypassPermissions mode [1 comments, 2 participants]