|
| 1 | +# Audit Settings |
| 2 | + |
| 3 | +Check `~/.claude/settings.json` for redundant permissions that are subsumed by broad wildcards. Optionally clean up the file. |
| 4 | + |
| 5 | +## Steps |
| 6 | + |
| 7 | +### 1. Read the user-level settings file |
| 8 | + |
| 9 | +```bash |
| 10 | +cat ~/.claude/settings.json |
| 11 | +``` |
| 12 | + |
| 13 | +If the file does not exist, report "No user-level settings.json found" and stop. |
| 14 | + |
| 15 | +### 2. Identify broad wildcards |
| 16 | + |
| 17 | +Parse the `permissions.allow` array. A **broad wildcard** is an entry with no parentheses -- it matches all invocations of that tool. |
| 18 | + |
| 19 | +Examples of broad wildcards: |
| 20 | + |
| 21 | +- `"Bash"` -- matches all Bash commands |
| 22 | +- `"Read"` -- matches all Read operations |
| 23 | +- `"mcp__*"` -- matches all MCP tools |
| 24 | + |
| 25 | +### 3. Find redundant specific entries |
| 26 | + |
| 27 | +For each broad wildcard found, identify specific entries it subsumes: |
| 28 | + |
| 29 | +- `"Bash"` subsumes `"Bash(git add:*)"`, `"Bash(gh pr merge 30 --squash --admin)"`, etc. |
| 30 | +- `"Read"` subsumes `"Read(d:/DevSpace/**)"`, etc. |
| 31 | +- `"mcp__*"` subsumes `"mcp__memory__create_entities"`, `"mcp__MCP_DOCKER__mcp-find"`, etc. |
| 32 | + |
| 33 | +An entry is redundant if a broader entry in the same array already covers it. |
| 34 | + |
| 35 | +### 4. Report findings |
| 36 | + |
| 37 | +Display a summary: |
| 38 | + |
| 39 | +```text |
| 40 | +Settings audit for ~/.claude/settings.json |
| 41 | +
|
| 42 | +Broad wildcards found: N |
| 43 | + - Bash |
| 44 | + - Read |
| 45 | + - Edit |
| 46 | + ... |
| 47 | +
|
| 48 | +Redundant specific entries: N |
| 49 | + - Bash(git add:*) (subsumed by Bash) |
| 50 | + - Bash(gh pr merge 30 --squash --admin) (subsumed by Bash) |
| 51 | + - Read(d:/DevSpace/**) (subsumed by Read) |
| 52 | + ... |
| 53 | +
|
| 54 | +Deny rules (preserved): N |
| 55 | + - Bash(rm -rf /) |
| 56 | +``` |
| 57 | + |
| 58 | +If zero redundant entries found, report "Settings are clean -- no redundant entries" and stop. |
| 59 | + |
| 60 | +### 5. Ask user to confirm cleanup |
| 61 | + |
| 62 | +Present the list of entries that would be removed. Explain: |
| 63 | + |
| 64 | +- Broad wildcards are kept |
| 65 | +- Deny rules are never removed |
| 66 | +- Non-redundant specific entries are kept |
| 67 | +- Only entries fully covered by a broad wildcard are removed |
| 68 | + |
| 69 | +Ask: "Remove N redundant entries? (This modifies ~/.claude/settings.json)" |
| 70 | + |
| 71 | +### 6. Clean up if confirmed |
| 72 | + |
| 73 | +Read the current file, remove redundant entries from `permissions.allow`, and write back. |
| 74 | + |
| 75 | +Use `Read` to get the current content, modify the JSON in a code block, and `Write` the cleaned version. |
| 76 | + |
| 77 | +**Preserve:** |
| 78 | + |
| 79 | +- All `permissions.deny` entries (never touch deny rules) |
| 80 | +- All entries NOT subsumed by a broad wildcard |
| 81 | +- All non-permission fields (`hooks`, `enabledPlugins`, `autoUpdatesChannel`, etc.) |
| 82 | +- JSON formatting (2-space indent) |
| 83 | + |
| 84 | +### 7. Report results |
| 85 | + |
| 86 | +Show before/after entry count and the cleaned file path. |
| 87 | + |
| 88 | +## Edge cases |
| 89 | + |
| 90 | +- **No broad wildcards**: Report "No broad wildcards found. Specific entries are all necessary." and stop. |
| 91 | +- **Mixed tool formats**: `"Bash(git:*)"` is subsumed by `"Bash"` but NOT by `"Bash(gh:*)"`. Only exact tool name match counts. |
| 92 | +- **settings.local.json**: This workflow only audits the user-level `~/.claude/settings.json`. Project-level and local files are not touched. |
| 93 | +- **Backup**: Before writing, create a backup at `~/.claude/settings.json.bak`. |
0 commit comments