-
-
Notifications
You must be signed in to change notification settings - Fork 171
feat: advanced hooks, LLM gates, and 7 new skills for v3.2.0 #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| --- | ||
| name: cost-analyst | ||
| description: Analyze session token usage and cost patterns. Identify expensive operations and recommend optimizations. Use to understand and reduce session costs. | ||
| tools: ["Read", "Glob", "Grep", "Bash"] | ||
| omitClaudeMd: true | ||
| --- | ||
|
|
||
| # Cost Analyst | ||
|
|
||
| Analyze token usage patterns and recommend cost optimizations. | ||
|
|
||
| ## Workflow | ||
|
|
||
| 1. Check current session token usage | ||
| 2. Identify the most expensive operations | ||
| 3. Analyze cache hit rates | ||
| 4. Recommend specific optimizations | ||
|
|
||
| ## Analysis Areas | ||
|
|
||
| ### Token Consumption by Category | ||
| - File reads (large files without offset/limit) | ||
| - Grep/search results (broad patterns returning many results) | ||
| - Tool result overhead (MCP tools with verbose output) | ||
| - System prompt size (CLAUDE.md + skills + MCP tool descriptions) | ||
| - Agent spawning (each agent gets fresh context) | ||
|
|
||
| ### Cache Optimization | ||
| - Stable system prompts improve cache hit rate | ||
| - Changing CLAUDE.md mid-session breaks cache | ||
| - Fork subagents share prompt cache (byte-identical) | ||
| - Reusing agents via SendMessage saves context creation cost | ||
|
|
||
| ### Model Selection Impact | ||
| - Opus: highest quality, highest cost | ||
| - Sonnet: good balance for most tasks | ||
| - Haiku: fast and cheap for simple lookups | ||
|
|
||
| ## Recommendations Template | ||
|
|
||
| ```text | ||
| COST ANALYSIS | ||
|
|
||
| Top cost drivers: | ||
| 1. [operation] -- ~[N]K tokens | ||
| 2. [operation] -- ~[N]K tokens | ||
|
|
||
| Optimization opportunities: | ||
| - [specific change] -- saves ~[N]K tokens/session | ||
| - [specific change] -- saves ~$X.XX/session | ||
|
|
||
| Current efficiency: [score]/100 | ||
| Projected savings: $X.XX/session | ||
| ``` | ||
|
|
||
| ## Rules | ||
|
|
||
| - Focus on actionable optimizations, not just reporting | ||
| - Never sacrifice code quality for cost savings | ||
| - Prioritize by impact (token savings x frequency) | ||
| - Consider both input and output token costs |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| --- | ||
| name: permission-analyst | ||
| description: Analyze permission denial patterns and generate optimized alwaysAllow/alwaysDeny rules. Use when permission prompts slow down workflow. | ||
| tools: ["Read", "Glob", "Grep", "Bash"] | ||
| omitClaudeMd: true | ||
| --- | ||
|
|
||
| # Permission Analyst | ||
|
|
||
| Analyze permission patterns and recommend rule optimizations. | ||
|
|
||
| ## Workflow | ||
|
|
||
| 1. Read current permission settings from `.claude/settings.json` and `~/.claude/settings.json` | ||
| 2. Check session logs for permission approval/denial patterns | ||
| 3. Categorize operations by risk level (safe/medium/dangerous) | ||
| 4. Generate optimized rules | ||
|
|
||
| ## Risk Categories | ||
|
|
||
| ### Safe (auto-approve candidates) | ||
| - All read-only tools: Read, Glob, Grep | ||
| - Read-only git: `git status`, `git diff*`, `git log*`, `git branch` | ||
| - Test/lint: `npm test*`, `npm run lint*`, `npm run typecheck*` | ||
| - Python: `pytest*`, `ruff*`, `mypy*` | ||
| - Rust: `cargo test*`, `cargo check*`, `cargo clippy*` | ||
| - Go: `go test*`, `go vet*` | ||
|
|
||
| ### Medium (approve with awareness) | ||
| - Edit, Write -- file modifications | ||
| - `git add*` -- staging | ||
| - `git commit*` -- committing | ||
| - `npm install*` -- dependency changes | ||
|
|
||
| ### Dangerous (never auto-approve) | ||
| - `git push --force*`, `git reset --hard*` | ||
| - `rm -rf*`, `rm -r*` on non-temp dirs | ||
| - `DROP TABLE`, `DELETE FROM` without WHERE | ||
| - Any `--no-verify` flag | ||
|
|
||
| ## Output | ||
|
|
||
| ```text | ||
| PERMISSION ANALYSIS | ||
|
|
||
| Current rules: [X] allow, [Y] deny | ||
|
|
||
| Session patterns: | ||
| Approved [N] times: [tool/pattern] | ||
| Denied [N] times: [tool/pattern] | ||
|
|
||
| Recommended additions: | ||
| alwaysAllow: | ||
| + [rule] -- approved [N]x, [risk level] | ||
|
|
||
| alwaysDeny: | ||
| + [rule] -- [reason] | ||
|
|
||
| Estimated prompts saved: ~[N] per session | ||
| ``` | ||
|
|
||
| ## Rules | ||
|
|
||
| - Never recommend auto-approving destructive operations | ||
| - Present all recommendations for user approval | ||
| - Include risk assessment for each recommendation | ||
| - Read-only operations are always safe to auto-approve | ||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| --- | ||
| description: Auto-detect project type and configure quality gates, permissions, and hooks for a new codebase | ||
| --- | ||
|
|
||
| # /auto-setup - Project Configuration | ||
|
|
||
| Automatically detect your project type and set up pro-workflow quality gates. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| Run in any project to: | ||
| 1. Detect project type (Node.js, Python, Rust, Go) | ||
| 2. Configure lint/typecheck/test commands | ||
| 3. Set up safe permission rules | ||
| 4. Verify tooling is installed | ||
|
|
||
| ## Supported Project Types | ||
|
|
||
| - **Node.js/TypeScript** — npm/pnpm/yarn, ESLint, TypeScript, Jest/Vitest | ||
| - **Python** — pip/poetry, ruff/flake8, mypy, pytest | ||
| - **Rust** — cargo, clippy, cargo test | ||
| - **Go** — go vet, golangci-lint, go test | ||
| - **Mixed/Monorepo** — detects multiple types | ||
|
|
||
| ## Usage | ||
|
|
||
| ``` | ||
| /auto-setup | ||
| ``` |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| --- | ||
| description: Smart context compaction with state preservation — saves critical state before compact and restores after | ||
| --- | ||
|
|
||
| # /compact-guard - Protected Compaction | ||
|
|
||
| Protect your working context through compaction. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| Run before `/compact` to: | ||
| 1. Save your current task state | ||
| 2. Note which files you're editing (max 5 survive compaction) | ||
| 3. Record decisions made this session | ||
| 4. Compact safely | ||
| 5. Restore critical context after | ||
|
|
||
| ## When To Use | ||
|
|
||
| - Before manual `/compact` | ||
| - When you see auto-compact warnings | ||
| - At natural task boundaries | ||
|
|
||
| ## Key Insight | ||
|
|
||
| Claude Code only restores **5 files** after compaction, with **5K tokens per file** and **50K total budget**. Plan accordingly: | ||
| - Prioritize the file you're actively editing | ||
| - Move exploration results to subagents | ||
| - Keep notes in a scratch file | ||
|
|
||
| ## Usage | ||
|
|
||
| ``` | ||
| /compact-guard | ||
| ``` | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| --- | ||
| description: Track session costs, understand token spend, and get optimization tips | ||
| --- | ||
|
|
||
| # /cost-tracker - Cost Awareness | ||
|
|
||
| Understand and optimize your session costs. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| Run to see: | ||
| - Current session cost estimate | ||
| - Top cost drivers | ||
| - Optimization suggestions | ||
| - Budget guidance for your task type | ||
|
|
||
| ## Cost Benchmarks | ||
|
|
||
| | Task Type | Typical | Budget Alert | | ||
| |-----------|---------|-------------| | ||
| | Bug fix | $0.10-0.50 | $1.00 | | ||
| | Small feature | $0.50-2.00 | $3.00 | | ||
| | Large feature | $2.00-8.00 | $10.00 | | ||
| | Refactor | $1.00-5.00 | $7.00 | | ||
|
|
||
| ## Usage | ||
|
|
||
| ``` | ||
| /cost-tracker | ||
| ``` |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| --- | ||
| description: Audit MCP servers for token overhead, redundancy, and usage — recommend servers to disable for faster sessions | ||
| --- | ||
|
|
||
| # /mcp-audit - MCP Server Optimization | ||
|
|
||
| Audit your MCP servers and reduce token overhead. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| Run to see: | ||
| - Active MCP servers and their tool counts | ||
| - Estimated token overhead per request | ||
| - Servers you haven't used recently | ||
| - Recommendations for disabling/keeping | ||
|
|
||
| ## Key Insight | ||
|
|
||
| Every MCP server adds ALL its tool descriptions to EVERY API request. A server with 20 tools adds ~2K-4K tokens per request whether you use it or not. | ||
|
|
||
| ## Thresholds | ||
|
|
||
| - Servers: <10 ideal, >15 reduce | ||
| - Total tools: <80 ideal, >120 reduce | ||
| - Per server: <15 ok, >30 split or disable | ||
|
|
||
| ## Usage | ||
|
|
||
| ``` | ||
| /mcp-audit | ||
| ``` |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| --- | ||
| description: Analyze permission denial patterns and generate optimized allow/deny rules to reduce prompt fatigue | ||
| --- | ||
|
|
||
| # /permission-tuner - Permission Optimization | ||
|
|
||
| Analyze your permission patterns and generate rules to reduce prompt fatigue. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| Run this command to: | ||
| 1. Scan permission denial history | ||
| 2. Identify safe patterns for auto-approval | ||
| 3. Generate optimized rules | ||
| 4. Present for your approval | ||
|
|
||
| ## What It Does | ||
|
|
||
| Reads your session's permission patterns and categorizes them: | ||
|
|
||
| - **Safe to auto-approve**: Read-only operations (Read, Glob, Grep, git status/diff/log) | ||
| - **Consider auto-approving**: Frequently approved operations (Edit, npm test) | ||
| - **Keep asking**: Operations that need review (git commit, npm install) | ||
| - **Auto-deny**: Dangerous operations (rm -rf, git push --force) | ||
|
|
||
| ## Usage | ||
|
|
||
| ``` | ||
| /permission-tuner | ||
| ``` | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| After running, review the suggested rules and apply the ones you want. | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approval-count reporting is underspecified against available telemetry.
The current pipeline persists denial records only (
scripts/permission-denied.js), but this prompt requires explicit approved/denied pattern counts. Without a concrete approval data source, the agent can produce unreliable “Approved [N] times” outputs.Also applies to: 49-50
🤖 Prompt for AI Agents