From ctxcraft
Guides token-efficient .claude/ directory design with context loading rules, token budgets, and patterns like thin rules thick skills and CLAUDE.md as index.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ctxcraft:token-guideThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
```
Every conversation starts by loading:
1. CLAUDE.md (project root) ← ALWAYS loaded
2. CLAUDE.md (.claude/ directory) ← ALWAYS loaded
3. rules/*.md ← ALWAYS loaded
4. Skill/agent descriptions (names) ← ALWAYS loaded (just the index)
Loaded on-demand (only when triggered):
5. skills/*/SKILL.md ← when /command is invoked
6. agents/*.md ← when Agent tool selects it
7. Memory files ← when relevant context detected
| Category | When Loaded | Cost per Conversation |
|---|---|---|
| CLAUDE.md | Always | Every single conversation |
| rules/*.md | Always | Every single conversation |
| Skill index | Always | Minimal (name + description only) |
| SKILL.md body | On trigger | Only when /command runs |
| Agent .md body | On delegation | Only when agent is spawned |
| Memory files | On relevance | Only when memory system activates |
| Always-loaded | Rating |
|---|---|
| < 2,000 tokens | Excellent |
| 2,000 - 4,000 | Good |
| 4,000 - 6,000 | Needs optimization |
| > 6,000 | Critical — actively wasting tokens |
rules/error-handling.md (always loaded — 15 lines):
- Key constraints only
- One-liner per rule
- Reference: "> Deep dive: /error-handling-guide"
skills/error-handling-guide/SKILL.md (on-demand — 200 lines):
- Full examples
- Anti-patterns with code
- Detailed explanations
CLAUDE.md should be a TABLE OF CONTENTS, not a manual.
BAD (300 lines):
## Architecture
[50 lines explaining Clean Architecture...]
## Patterns
[80 lines of code examples...]
GOOD (80 lines):
## Architecture
Clean Architecture: app → domain/data/core
> Details: rules/architecture.md
## Patterns
Service layer: dependency injection + repository pattern + reactive streams
> Details: rules/architecture.md, /project-patterns
Move content that's only relevant to specific tasks into skills:
/tdd skill/migration skill/release skill/dep-check skillIf a rule requires >30 lines of explanation with examples, it's better as an agent:
rules/code-review.md (10 lines):
- Review checklist summary
- "Delegate detailed review to code-reviewer agent"
agents/code-reviewer.md (100 lines):
- Full review criteria
- Examples of good/bad patterns
- Output format
| Pattern | Waste | Fix |
|---|---|---|
| CLAUDE.md > 200 lines | ~1,500+ tokens/conv | Compress to index |
| Duplicate content in rules + CLAUDE.md | ~500-1,000 tokens | Single source of truth |
| Examples in rules/ | ~300-800 tokens | Move to skills |
| 15+ rules files | ~2,000+ tokens | Consolidate to 5-8 |
| Verbose prose in rules | ~500+ tokens | Convert to tables/bullets |
| Unused skills with long descriptions | Minimal but noisy | Prune or shorten description |
npx claudepluginhub warrenth/ctxcraft --plugin ctxcraftEvaluates .claude/ directory token efficiency by scanning files, estimating tokens, categorizing load types, detecting issues like long CLAUDE.md or duplicates, and generating scored report.
Estimates per-turn token costs of .claude/ configs and CLAUDE.md, classifies always-loaded vs path-scoped vs invoked-only, ranks top contributors, flags overruns. Use --api for exact Anthropic counts.
Creates, updates, or optimizes CLAUDE.md files following Anthropic best practices for project context, coding standards, and persistent memory management.