feat(settings-audit): Add Claude Code settings optimizer skill
- Add new 00-claude-code-setting skill for token usage optimization - Includes audit scripts for MCP servers, CLAUDE.md, and extensions - Auto-fix capability with backup for serverInstructions and frontmatter - Add YAML frontmatter to 17 command files - Target: keep baseline under 30% of 200K context limit Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
---
|
||||
description: Audit Claude Code settings for token efficiency. Analyzes MCP servers, CLAUDE.md, extensions and provides optimization recommendations.
|
||||
argument-hint: [--fix] [--tokens-only]
|
||||
allowed-tools: Read, Glob, Grep, Bash, Write
|
||||
---
|
||||
|
||||
# Claude Code Settings Audit
|
||||
|
||||
Audit your Claude Code configuration to optimize token usage and performance.
|
||||
|
||||
## Arguments
|
||||
- `--fix`: Apply safe fixes automatically (with backup)
|
||||
- `--tokens-only`: Quick token budget check only
|
||||
|
||||
## Audit Process
|
||||
|
||||
### 1. Token Budget Check
|
||||
|
||||
Calculate current baseline token usage:
|
||||
|
||||
```bash
|
||||
# Quick estimation
|
||||
echo "=== Token Budget Estimation ==="
|
||||
```
|
||||
|
||||
**Targets:**
|
||||
- CLAUDE.md: <3,000 tokens (~200 lines)
|
||||
- MCP with Tool Search: <10,000 tokens
|
||||
- Working space: >70% of 200K context
|
||||
|
||||
### 2. MCP Server Analysis
|
||||
|
||||
Check locations:
|
||||
- `~/.claude/settings.json`
|
||||
- `./.claude/settings.json`
|
||||
|
||||
For each server, evaluate:
|
||||
- [ ] Has `serverInstructions` (CRITICAL for Tool Search)
|
||||
- [ ] Appropriate load strategy (always/lazy/disable)
|
||||
- [ ] Token impact estimation
|
||||
|
||||
**Server Token Estimates:**
|
||||
| Server | Tokens | Strategy |
|
||||
|--------|--------|----------|
|
||||
| Playwright | ~13,500 | always |
|
||||
| Notion | ~5,000 | always |
|
||||
| GitHub | ~18,000 | lazy |
|
||||
| PostgreSQL | ~8,000 | lazy |
|
||||
| Zapier | ~25,000+ | disable |
|
||||
|
||||
### 3. CLAUDE.md Analysis
|
||||
|
||||
Check:
|
||||
- `~/.claude/CLAUDE.md` (global)
|
||||
- `./CLAUDE.md` (project)
|
||||
|
||||
Evaluate:
|
||||
- [ ] Line count (critical if >200)
|
||||
- [ ] Token estimate (critical if >3,000)
|
||||
- [ ] Good structure (headers, lists, not wall of text)
|
||||
- [ ] No redundant information
|
||||
- [ ] No information Claude already knows
|
||||
|
||||
### 4. Extensions Analysis
|
||||
|
||||
**Commands** (`~/.claude/commands/`):
|
||||
- Has YAML frontmatter with description?
|
||||
- Under 100 lines?
|
||||
|
||||
**Skills** (`~/.claude/skills/`):
|
||||
- Has SKILL.md?
|
||||
- Under 500 lines?
|
||||
|
||||
**Agents** (`~/.claude/agents/`):
|
||||
- Tools appropriately restricted?
|
||||
|
||||
## Output Format
|
||||
|
||||
```markdown
|
||||
# Settings Audit Report
|
||||
Generated: [timestamp]
|
||||
|
||||
## Token Budget Summary
|
||||
| Component | Tokens | % of 200K | Status |
|
||||
|-----------|--------|-----------|--------|
|
||||
| CLAUDE.md | X | Y% | OK/WARN/CRITICAL |
|
||||
| MCP Servers | X | Y% | OK/WARN/CRITICAL |
|
||||
| Extensions | X | Y% | OK/WARN/CRITICAL |
|
||||
| **Baseline** | **X** | **Y%** | — |
|
||||
| **Available** | **X** | **Y%** | — |
|
||||
|
||||
## Critical Issues
|
||||
[Must fix immediately]
|
||||
|
||||
## Warnings
|
||||
[Should address soon]
|
||||
|
||||
## Recommendations
|
||||
1. [Prioritized action]
|
||||
2. [...]
|
||||
|
||||
## Auto-Fix Available
|
||||
[List of safe fixes that can be applied with --fix]
|
||||
```
|
||||
|
||||
## Quick Fixes
|
||||
|
||||
If `--fix` is provided:
|
||||
1. Add `serverInstructions` to MCP servers missing them
|
||||
2. Add frontmatter to commands missing it
|
||||
3. Create backup before any changes
|
||||
|
||||
## Execution
|
||||
|
||||
1. Run token budget analysis first
|
||||
2. Analyze each component
|
||||
3. Generate prioritized report
|
||||
4. Offer auto-fix if issues found
|
||||
5. Save report to `./settings-audit-report.md`
|
||||
Reference in New Issue
Block a user