Skip to content
This repository was archived by the owner on Apr 5, 2026. It is now read-only.

Commit 3cb1804

Browse files
HerbHallclaude
andauthored
feat: add settings audit route to devkit-sync (#139)
Add route 12 (audit) that checks ~/.claude/settings.json for redundant specific permissions subsumed by broad wildcards. Reports findings and optionally cleans up the file with backup. Closes #134 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6ae7098 commit 3cb1804

3 files changed

Lines changed: 97 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ This backs up any existing files in `~/.claude/`, creates symlinks for all share
9595
| `/devkit-sync update` | Check version and upgrade to latest release |
9696
| `/devkit-sync verify` | Check if DevKit updates reached all active projects |
9797
| `/devkit-sync new-project` | Scaffold a new project with templates and profile |
98+
| `/devkit-sync audit` | Check for redundant permissions in settings.json |
9899

99100
### Multi-machine workflow
100101

claude/skills/devkit-sync/SKILL.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: devkit-sync
3-
description: Manual sync operations for DevKit multi-machine synchronization. Status, push, pull, init, diff, unlink, promote, update, and new-project scaffolding.
3+
description: Manual sync operations for DevKit multi-machine synchronization. Status, push, pull, init, diff, unlink, promote, update, new-project scaffolding, and settings audit.
44
user_invocable: true
55
---
66

@@ -32,6 +32,7 @@ What sync operation do you need?
3232
9. **Update** -- Check version and upgrade to a specific release or latest
3333
10. **Verify** -- Check if DevKit updates reached all active projects
3434
11. **New project** -- Scaffold a new project with DevKit templates and profile
35+
12. **Audit settings** -- Check for redundant permissions in settings.json
3536

3637
Or just type your question about DevKit sync.
3738
</intake>
@@ -50,6 +51,7 @@ Or just type your question about DevKit sync.
5051
| 9, "update", "upgrade", "version", "release" | workflows/update.md |
5152
| 10, "verify", "propagation", "check projects", "reach" | workflows/verify.md |
5253
| 11, "new-project", "scaffold", "create project", "new" | workflows/new-project.md |
54+
| 12, "audit", "cleanup", "settings audit", "redundant", "permissions" | workflows/audit-settings.md |
5355

5456
**After reading the workflow, follow it exactly.**
5557
</routing>
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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

Comments
 (0)