Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions agents/context-engineer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: context-engineer
description: Analyzes and optimizes context window usage across sessions. Use when context feels bloated, sessions run slow, or approaching compaction limits.
tools: ["Read", "Glob", "Grep", "Bash"]
omitClaudeMd: true
---

# Context Engineer
Expand Down
61 changes: 61 additions & 0 deletions agents/cost-analyst.md
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
67 changes: 67 additions & 0 deletions agents/permission-analyst.md
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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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
Verify each finding against the current code and only fix it if needed.

In `@agents/permission-analyst.md` around lines 15 - 16, The analyst prompt
expects both approved and denied counts but the pipeline only persists denials
(scripts/permission-denied.js), so add explicit approval telemetry ingestion and
storage and update the prompt to reference that source; specifically, extend or
create a counterpart (e.g., scripts/permission-approved.js or add a
persistApprovalRecord/ingestPermissionTelemetry path alongside
persistDenialRecord) to record approval events, update any ingestion/ETL that
aggregates session logs to emit both approved and denied counters, and revise
agents/permission-analyst.md (including the sections around lines 15-16 and
49-50) to read from the new approval data source so the agent can report
concrete "Approved [N] times" and "Denied [N] times" values.

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
1 change: 1 addition & 0 deletions agents/planner.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: planner
description: Break down complex tasks into implementation plans before writing code. Use when task touches >5 files, requires architecture decisions, or has unclear requirements.
tools: ["Read", "Glob", "Grep"]
omitClaudeMd: true
---

# Planner
Expand Down
1 change: 1 addition & 0 deletions agents/reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: reviewer
description: Code review specialist that verifies every finding against actual code before reporting. Use before committing, for PR reviews, or after major changes.
tools: ["Read", "Glob", "Grep", "Bash"]
omitClaudeMd: true
---

# Reviewer
Expand Down
1 change: 1 addition & 0 deletions agents/scout.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: Confidence-gated exploration that assesses readiness before impleme
tools: ["Read", "Glob", "Grep", "Bash"]
background: true
isolation: worktree
omitClaudeMd: true
---

# Scout - Confidence-Gated Exploration
Expand Down
29 changes: 29 additions & 0 deletions commands/auto-setup.md
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
```
35 changes: 35 additions & 0 deletions commands/compact-guard.md
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
```
30 changes: 30 additions & 0 deletions commands/cost-tracker.md
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
```
31 changes: 31 additions & 0 deletions commands/mcp-audit.md
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
```
32 changes: 32 additions & 0 deletions commands/permission-tuner.md
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
```

After running, review the suggested rules and apply the ones you want.
Loading