ctxcraft

Evaluate and optimize your AI agent's context. Save tokens, cut costs.
ctxcraft analyzes your .claude/ directory structure and provides actionable recommendations to reduce token consumption โ without losing any functionality.
The Problem
AI coding agents (Claude Code, Cursor, Windsurf) load context files on every conversation. As your .claude/ directory grows, silent token waste accumulates:
- Verbose rule files that could be cut in half
- Duplicated content across rules, skills, and CLAUDE.md
- Unused skills/agents that are never invoked
- Always-on files that should be loaded on-demand
ctxcraft finds and fixes all of this.
vs /doctor? Claude Code's built-in /doctor proposes trims for a checked-in CLAUDE.md. ctxcraft audits the whole .claude/ surface โ rules/, skills/, agents/, legacy commands/, auto memory โ with a quality score, a plan-tier cost axis, and CI integration. Thresholds follow the official docs.
Quick Start
Option 1: Plugin Marketplace (Recommended)
# Add marketplace (one-time)
claude plugin marketplace add warrenth/ctxcraft
# Install plugin (run per project)
claude plugin install ctxcraft@tools
Then in Claude Code:
/ctxcraft:evaluate # Analyze token efficiency
/ctxcraft:optimize # Auto-fix issues
/ctxcraft:token-guide # Best practices reference
Note: claude plugin install must be run in each project. Despite scope: user, Claude Code plugins are not truly global โ you need to reinstall when switching to a new project.
Team auto-install via settings.json
{
"extraKnownMarketplaces": {
"ctxcraft": {
"source": { "source": "github", "repo": "warrenth/ctxcraft" }
}
},
"enabledPlugins": { "ctxcraft@tools": true }
}
Option 2: Global Install
curl -sL https://raw.githubusercontent.com/warrenth/ctxcraft/main/install.sh | bash
Then in Claude Code: /evaluate, /optimize, /token-guide
Project-local install
curl -sL https://raw.githubusercontent.com/warrenth/ctxcraft/main/install.sh | bash -s -- --local
/evaluate uses read-only tools (Read, Grep, Glob) โ no permission prompts. /optimize additionally uses Write/Edit and always asks before applying any change.
Note: plugin installs don't load the optional always-on rules file (rules/token-efficiency.md) โ plugins can't ship rules/. The install.sh path offers to copy it to ~/.claude/rules/ instead.
How It Works
$ /ctxcraft:evaluate
โโโ Phase 1: Token Efficiency Audit โโโ
PASS [ 1] CLAUDE.md size
FAIL [ 2] Always-on tokens โ Compress rules, save ~8,848 tokens
FAIL [ 3] Rules file size โ Move examples to skills/
PASS [ 4] Rules file count
WARN [ 5] Duplicate sections โ Keep in one place only
PASS [ 6] Progressive disclosure
...
PASS [25] Cross-reference validity
โโโ Phase 2: Report โโโ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโ
โ Category โ Tokens โ Files โ
โโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโค
โ Always-on (every) โ 16,848 โ 14 โ
โ On-demand (lazy) โ 53,040 โ 46 โ
โโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโค
โ Total โ 69,888 โ 60 โ
โโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโ
๐ก Potential savings: ~9,168 tokens/conversation
โโโ Summary โโโ
Quality: 86/100 (A-)
Cost: Comfortable (Max 5x plan)
PASS 20 WARN 3 FAIL 2
Before / After
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ctxcraft โ Optimization Complete โ
โ โ
โ Before After Change โ
โ Quality 78/100 โ 92/100 (+14 pts) โ
โ Grade B+ โ A โ
โ Always-on 16,848 โ 9,200 (-7,648 tok) โ
โ โ
โ PASS 20 โ 24 WARN 3 โ 1 FAIL 2 โ 0 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
What /optimize Does
- Compress โ Shrink verbose rules and CLAUDE.md while preserving meaning
- Deduplicate โ Merge overlapping rules into a single source of truth
- Clean up โ Identify and remove unused skills/agents
- Restructure โ Move always-on content to on-demand skills
- Split references โ Extract details from large SKILL.md (>250 lines) into references/
- Self-clean โ Remove temporary scratch files after optimization (never the plugin itself)
All changes require user confirmation before applying.
25 Checks
Token Efficiency (1โ8)