Analyze accumulated permissions and suggest smart wildcard patterns
Analyze accumulated permissions in settings.local.json and suggest smart wildcard patterns to add to the shared configuration.
analyze (default), apply, or cleanupExample invocations:
/analyze-permissions → analyze and suggest patterns/analyze-permissions apply → apply suggested patterns to shared config/analyze-permissions cleanup → just run the cleanup scriptRead these files:
<project-root>/.claude/settings.local.json - accumulated "Always allow" permissions (per-project, not at ~/.claude/)~/.claude/settings.json - shared/base permissions managed by the configure script~/.dotfiles/ai/configure-tool-permissions.sh - canonical source for global permissionsNote: settings.local.json is project-specific. Each repo has its own at <repo>/.claude/settings.local.json. The global ~/.claude/settings.json is shared across all projects.
For each entry in settings.local.json:
Check if already covered - Is there a wildcard in settings.json that covers this?
Bash(git commit -m "Fix bug") is covered by Bash(git commit:*)Bash(curl https://api.example.com) is covered by Bash(curl:*)Identify pattern opportunities - Group similar commands:
kubectl commands → suggest Bash(kubectl:*)docker commands → suggest Bash(docker:*)WebFetch(https://example.com/*)Decide global vs local - Where should the pattern live?
npx, python, docker compose, etc.)git push for a personal repo)Assess safety - Consider if the pattern is safe for auto-approval:
git push for a personal repo)sudo, permission-loosening patterns like chmod 777, or anything that could expose credentials or secretsOutput a structured report:
## Permission Analysis
### Settings Overview
- settings.local.json: X entries
- settings.json: Y entries (Z wildcards)
### Already Covered (can be removed)
These entries in settings.local.json are redundant:
| Entry | Covered by |
|-------|------------|
| Bash(git commit -m "...") | Bash(git commit:*) |
### Suggested New Patterns
These patterns would consolidate multiple specific entries:
| Pattern | Covers | Safety |
|---------|--------|--------|
| Bash(kubectl:*) | 4 entries | ✅ Safe (read-heavy) |
| Bash(docker exec:*) | 3 entries | ⚠️ Review (can modify) |
### Uncategorized
These entries don't fit a pattern (one-offs):
- Bash(some-specific-command)
Based on the action argument:
analyze (default):
apply:
configure-tool-permissions.sh in the PERMISSIONS_CONFIG sectioncleanup:
scripts/cleanup-settings-local.shWhen adding patterns to configure-tool-permissions.sh:
PERMISSIONS_CONFIG JSON arrayif statement so the script knows to re-run~/.dotfiles/ai/configure-tool-permissions.shscripts/cleanup-settings-local.shImportant: The configure script merges new entries into settings.json but never removes existing ones. This means settings.json also accumulates "don't ask again" entries over time. The cleanup script only cleans settings.local.json. To fully clean settings.json, you'd need to manually remove redundant entries or rebuild it from the script.