token-guide
Reference guide for token-efficient .claude/ directory design patterns
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Reference guide for token-efficient .claude/ directory design patterns
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
| name | token-guide |
| description | Reference guide for token-efficient .claude/ directory design patterns |
| user-invocable | false |
Source: code.claude.com/docs/en/memory.md, skills.md, sub-agents.md
Loaded at session start (always-on):
1. CLAUDE.md โ root, .claude/, ~/.claude/ โ plus @path imports (max depth 4;
imports load at launch, so splitting does NOT save tokens)
2. rules/**/*.md WITHOUT paths: frontmatter (recursive; subdirs and symlinks OK)
3. Skill descriptions (+ when_to_use, truncated at 1,536 chars)
โ except disable-model-invocation skills, which load NO description
4. Auto memory MEMORY.md โ first 200 lines or 25KB, whichever comes first
Loaded on-demand:
5. rules/**/*.md WITH paths: frontmatter โ when Claude reads matching files
6. skills/*/SKILL.md body โ when invoked (then stays in context)
7. agents/*.md body โ when the subagent is spawned
โ a spawned subagent also reloads the FULL CLAUDE.md hierarchy + rules
8. Memory topic files, nested CLAUDE.md / nested skills in subdirectories
Not context: hooks/ scripts, scratch/, settings files.
Block-level HTML comments (<!-- -->) are stripped before injection โ free for humans.
| Category | When Loaded | Cost per Conversation |
|---|---|---|
| CLAUDE.md + @imports | Always | Every single conversation |
rules without paths: | Always | Every single conversation |
rules with paths: | On file match | Only when matching files are read |
| Skill index (desc + when_to_use) | Always | โค1,536 chars each; 0 for disable-model-invocation skills |
| SKILL.md body | On invoke | Loads once, then persists in context (official tip: keep under 500 lines) |
| Agent .md body | On spawn | Body + full CLAUDE.md/rules reload per spawn |
| Auto memory MEMORY.md | Always | First 200 lines / 25KB only |
Aligned with the /evaluate thresholds (WARN 8,000 / CRITICAL 12,000):
| Always-loaded | Rating |
|---|---|
| < 4,000 tokens | Excellent |
| 4,000 - 8,000 | Good |
| 8,001 - 12,000 | Needs optimization (WARN) |
| > 12,000 | Critical โ actively wasting tokens (FAIL) |
Remember: always-on tokens are also reloaded into every spawned subagent's context, so real waste scales with subagent usage.
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 |