feat: add claude-permissions-optimizer skill#298
Merged
Conversation
da040b7 to
6744b1b
Compare
Adds a skill that reduces permission prompt fatigue by analyzing Claude Code session history, identifying safe Bash commands, and auto-applying them to settings.json. - Bundled Node.js extraction script scans session JSONL transcripts - Three-tier classification (green/yellow/red) cross-referenced against destructive_command_guard rule packs - Normalizes raw commands into Bash(pattern) allowlist rules - Script-first architecture: all data processing in script, model just presents results (~60% token reduction) - Scans up to 500 sessions or 30 days, whichever is more restrictive
Systematic cross-reference against destructive_command_guard rule packs uncovered and fixed multiple classification issues: - Fix compound command leak: classify now extracts first command from chains (&&, ||, ;) matching normalize behavior - Contextual risk flags: -f only preserved for git/docker/rm, -v only for docker. Prevents false fragmentation of green patterns - Mode-preserving normalization: sed/find/ast-grep produce narrow patterns (sed -n *, find -name *) so allowlist globs can't match destructive variants (sed -i, find -delete) - Fix git push -f, git restore -S, git clean -fd, git branch --force regex patterns - Add RED patterns from DCG: npm unpublish, cargo yank, dd, mkfs, pip uninstall, apt remove, brew uninstall - Add GREEN/YELLOW for git blame, shortlog, stash list, gh CLI, clone - Make skill cross-platform with environment self-detection - Add blocked-commands table and coverage percentage to output
32518c0 to
9985abb
Compare
- Add claude-permissions-optimizer to Content & Workflow skills table - Bump skill count from 40+ to 45+ - Add README update requirement to Adding Components section in AGENTS.md
This was referenced Mar 18, 2026
Merged
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new claude-permissions-optimizer skill that reduces permission prompt fatigue by analyzing Claude Code session history, identifying safe Bash commands used frequently, and auto-applying them to
settings.json.Inspired by Brian Scanlan's post:
We took this concept and built it as a skill for the compound-engineering plugin.
Why a skill instead of a hook?
The hook-based approach requires:
A skill is simpler and achieves the same outcome:
The user who's annoyed by permission prompts knows they're annoyed. They don't need a hook to tell them after the 5th prompt.
How it works
Bash(pattern)rules with mode-preserving normalization (e.g.,sed -n 's/foo/bar/' file->sed -n *, not the overly broadsed *)-ffor git/docker/rm,-vfor docker) to keep dangerous variants separate without fragmenting safe patternsnode --version->node *) to prevent normalization from turning safe commands into unsafe recommendationscd /dir && git branch -Dclassifies ascd, notgit branch -D)settings.jsonwith JSON validation and automatic rollback on corruptionDesign
--daysand--max-sessionsflagsBash(pattern)globs can't match destructive variants. Commands with mode-switching flags produce narrow patterns (sed -n *) instead of broad ones (sed *)Script-first architecture
The skill uses a script-first architecture where the bundled Node.js script handles all data processing and the model just presents results. This cut token usage by 60%+:
A compound learning doc captures this pattern for future skill development.
Classification approach
The extraction script's classification draws from destructive_command_guard patterns and was systematically cross-referenced against DCG's rule packs (core/git, core/filesystem, package_managers, system, containers):
sed -i,find -delete,ast-grep --rewrite) produce narrow patterns so the allowlist glob can't match the dangerous form-fpreserved for git/docker/rm (force), ignored for grep/tail (benign);-vpreserved for docker (volumes), ignored everywhere else (verbose)&&/||/;chains, matching normalization scope--stagedand-S,--forceand-f,-Dand--force)node --version) from producing unsafe wildcard patterns (node *)docker system prune --dry-runis green, without the flag is reddocker-compose down(yellow) vsdocker-compose down -v(red)Coverage includes 60+ RED patterns (rm, git destructive ops, publishing, system commands, disk ops, package removal, SQL injection, credential exposure), read-only GREEN patterns for git, gh CLI, dev tools, and linters, and YELLOW patterns for recoverable write operations.
What's included
plugins/compound-engineering/skills/claude-permissions-optimizer/SKILL.md-- skill definition (5 steps: scope, extract, present, confirm, apply)plugins/compound-engineering/skills/claude-permissions-optimizer/scripts/extract-commands.mjs-- Node.js extraction + classification scriptdocs/solutions/skill-design/script-first-skill-architecture.md-- compound learning: script-first architecture patterndocs/solutions/skill-design/claude-permissions-optimizer-classification-fix.md-- compound learning: classification design and DCG cross-referenceTest plan
node plugins/compound-engineering/skills/claude-permissions-optimizer/scripts/extract-commands.mjsand verify clean JSON output