Skip to content

[BUG] "Don't Ask Again" Overwrites Entire Permissions Array #5710

Closed as not planned

Description

@jessicawestbrook

Bug Report: "Don't Ask Again" Overwrites Entire Permissions Array

Description

When clicking "Don't ask again" for a command permission in Claude Code, the entire allow array in .claude/settings.local.json gets replaced with just the new permission, causing all previously saved permissions to be lost.

Expected Behavior

New permissions should be appended to the existing allow array, preserving all previously saved permissions.

Actual Behavior

The entire allow array is replaced with only the new permission, deleting all existing permissions.

Steps to Reproduce

  1. Have multiple permissions in .claude/settings.local.json:

    {
      "permissions": {
        "allow": [
          "Bash(npm install:*)",
          "Bash(npm run dev:*)",
          "Bash(git status:*)"
        ]
      }
    }
  2. Run a new command that triggers a permission prompt (e.g., npx tsc)

  3. Click "Don't ask again"

  4. Check .claude/settings.local.json

  5. The file now contains only:

    {
      "permissions": {
        "allow": [
          "Bash(npx tsc:*)"
        ]
      }
    }

Impact

  • Users lose all their saved permissions every time they add a new one
  • Have to manually restore permissions or re-approve commands repeatedly
  • Makes the "Don't ask again" feature counterproductive

Environment

  • Claude Code version: [Current version]
  • OS: Windows
  • Project type: Next.js/TypeScript

Workaround

Created a script to restore permissions:

// restore-permissions.js
const fs = require('fs');
const path = require('path');

const settingsPath = path.join(__dirname, '.claude', 'settings.local.json');
const desiredPermissions = [
  "Bash(npm install:*)",
  "Bash(npm run dev:*)",
  // ... other permissions
];

const currentSettings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
const currentAllow = currentSettings.permissions?.allow || [];
const mergedPermissions = [...new Set([...desiredPermissions, ...currentAllow])];
currentSettings.permissions.allow = mergedPermissions;
fs.writeFileSync(settingsPath, JSON.stringify(currentSettings, null, 2));

Suggested Fix

When adding a new permission, the code should:

  1. Read the current permissions array
  2. Add the new permission if it doesn't exist
  3. Write back the merged array

Example fix:

// Instead of:
settings.permissions.allow = [newPermission];

// Should be:
settings.permissions.allow = [...new Set([...settings.permissions.allow, newPermission])];

Additional Context

This happens consistently - observed multiple times in a single session where permissions were overwritten with:

  • Bash(npx tsc:*)
  • Bash(taskkill:*)
  • Bash(powershell:*)

Each time, all previous permissions were lost.

Activity

  1. chilts commented on Sep 6, 2025

    @chilts

    I am also getting this problem and it is very frustrating. Having to say yes to something I've said yes to already (multiple times now due to this bug) gets unwieldy.

    My workaround is that my .claude/settings.local.json file is checked in to git, so I just git checkout .claude/settings.local.json regularly, usually after I have finished a task and done a /clear. I've also quit claude at this point, re-run it, but still it manages to lose the permissions.allow array pretty soon, as @jessicawestbrook says, when it asks again - though I also find it asks for commands that are already allowed, so it probably just disappears upon config read even prior to asking for permission.

    Just to finish, why not change permissions.allow to an object (with true values) so that object manipulation such as adding a new permission is much much easier than having to do array manipulation. Ultimately this doesn't matter if it works, but currently it doesn't.

  2. DanielHaddon commented on Sep 12, 2025

    @DanielHaddon

    Yeah this is a very annoying issue.

  3. BR4096 commented on Oct 9, 2025

    @BR4096

    This claude-settings.json corruption started to occur in v2.0.12 (Claude Code) MacOS earlier today each time the file was read.

  4. Nihileon commented on Oct 16, 2025

    @Nihileon

    same issue here in Current version: 2.0.20

  5. k2iuh commented on Oct 19, 2025

    @k2iuh

    Same for me on 2.0.22 and MacOS 26. This is so annoying.

  6. arnonmoscona commented on Nov 6, 2025

    @arnonmoscona

    Detailed Investigation Report: Permissions Ignored Despite Explicit Configuration

    Environment

    • Claude Code Version: 2.0.34
    • Platform: macOS (Darwin 22.6.0)
    • Project: Local project with .claude/settings.local.json

    Problem Statement

    Claude Code repeatedly requests permissions for actions explicitly allowed in .claude/settings.local.json, including:

    • Bash commands: uv run ruff check, uv run ruff format, uv run python -m py_compile
    • MCP tools: mcp__basic-memory__edit_note, mcp__basic-memory__write_note, etc.

    All of these permissions were explicitly listed in the permissions.allow array.

    Investigation Steps

    Theory 1: Path Format Issue (Single vs Double Slash)

    Based on issue #6850 and #6881, we hypothesized that absolute paths needed double slashes (//) on macOS.

    Changes Made:

    // Before
    "Read(/Users/arnon/projects/**)"
    "Bash(/Users/arnon/bin/send_text:*)"
    
    // After
    "Read(//Users/arnon/projects/**)"
    "Bash(//Users/arnon/bin/send_text:*)"
    
    Result: ❌ Failed - Still requested permissions
    
    Test Method: Fresh Claude instance, asked to run uv run ruff check on a file
    Outcome: Permission prompt appeared despite pattern being in allow list
    
    Theory 2: Wildcard Syntax Issue (Colon vs Space)
    
    Based on issue #819, we hypothesized that command:* syntax doesn't match space-separated arguments.
    
    Changes Made:
    // Before
    "Bash(uv run ruff check:*)"
    "Bash(uv run ruff format:*)"
    
    // After  
    "Bash(uv run ruff *)"
    
    Result: ❌ Failed - Still requested permissions
    
    Test Method: New Claude instance after configuration change
    Outcome: Still prompted for permission to run uv run ruff check bin/checked_bash.py
    
    Theory 3: Configuration File Corruption
    
    Rolled back .claude/settings.local.json to a known-good version from Oct 27 (commit a079a14) using git.
    
    Result: ❌ Failed - Still requested permissions with old configuration
    
    Test Method: Fresh Claude instance with rolled-back configuration
    Outcome: Permissions still requested, ruling out configuration file as the cause
    
    Evidence of Core Bug
    
    1. MCP Tool Permissions Ignored:
      - Tool mcp__basic-memory__edit_note explicitly listed on line 40 of settings
      - Claude still prompted: "Do you want to proceed? ... for basic-memory - edit_note commands"
      - No wildcards, no paths, exact string match - still failed
    2. Fresh Instance Behavior:
      - Problem occurs in brand new Claude instances running for <10 seconds
      - Rules out issues from #10028 about periodic clearing after hours of use
      - Indicates permission matching is broken at initialization
    3. Pattern Independence:
      - Failed with single slash paths
      - Failed with double slash paths
      - Failed with colon wildcards
      - Failed with space wildcards
      - Failed with exact MCP tool names (no wildcards at all)
    
    Verification Steps Taken
    
    # Verified settings file exists and contains permissions
    $ grep -n "edit_note" .claude/settings.local.json
    39:      "mcp__basic-memory__edit_note",
    
    # Verified only one settings file in project
    $ ls -la .claude/settings*.json
    -rw-r--r--@ 1 arnon  staff  2845 Nov  6 12:09 .claude/settings.local.json
    
    # Tested with git history
    $ git log --oneline -- .claude/settings.local.json
    ffe4d62 FLO-72: Add customers table page with sortable columns
    99fa209 FLO-72: Implement users table page infrastructure
    a079a14 FLO-72: prep for implementing table pages
    
    # Rolled back and tested
    $ git checkout a079a14 -- .claude/settings.local.json
    # Result: Still prompted for permissions
    
    Screenshot Evidence
    
    Permission prompt appeared for uv run ruff check bin/checked_bash.py despite:
    - Settings containing "Bash(uv run ruff check:*)" (later changed to "Bash(uv run ruff *)")
    - Fresh Claude instance
    - File explicitly shown in working directory
    
    Conclusion
    
    The permission system in Claude Code 2.0.34 does not read or respect .claude/settings.local.json at all, or the pattern matching is completely broken for all pattern types.
    
    This is not caused by:
    - Path format (single vs double slash)
    - Wildcard syntax (colon vs space)
    - Configuration file corruption
    - Duplicate entries
    - Periodic clearing (happens immediately)
    
    This appears to be a fundamental bug in the permission system initialization or matching logic affecting:
    - All Bash command patterns
    - All MCP tool permissions
    - Both wildcard and exact-match patterns
    
    The system prompts for permissions on every fresh instance regardless of configuration, making the settings file effectively non-functional.
    
    Reproducibility
    
    100% reproducible on every fresh Claude Code instance with any configuration pattern tested.
    
  7. arnonmoscona commented on Nov 6, 2025

    @arnonmoscona

    This critical security bug has been open for 3 months with no assignee. Permission system is completely non-functional in v2.0.34. Escalating to
    security@anthropic.com and support@anthropic.com

  8. MannyPeterson commented on Nov 8, 2025

    @MannyPeterson

    Friends,

    Frustrating, indeed. Here is how I have been surviving.

    chmod 444 .claude/settings.local.json
    chmod 555 .claude
    

    When I start Claude Code, I instruct it to read .claude/settings.local.json.

    Warm regards,

    Manny

  9. kinglycodes commented on Nov 14, 2025

    @kinglycodes

    Same here and still not fixed

  10. github-actions commented on Dec 15, 2025

    @github-actions

    This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

  11. mousio commented on Dec 16, 2025

    @mousio

    So, arrays in settings.local.json are replaced instead of merged/appended?
    Note then that the bug also affects additionalDirectories when using /add-dir multiple times.

    Workaround

    Manually edit .claude/settings.local.json to include all directories.

  12. github-actions commented on Jan 15, 2026

    @github-actions

    This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

  13. github-actions commented on Jan 23, 2026

    @github-actions

    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.

  14. locked as resolved and limited conversation to collaborators on Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:authbugSomething isn't workinghas reproHas detailed reproduction stepsplatform:windowsIssue specifically occurs on Windows

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions