token-optimization
Strategies for reducing token usage in Claude sessions. Use when approaching context limits, loading large codebases, or wanting faster/cheaper sessions. Covers anatomy-first reading, targeted grep over full-file reads, and context window management.
- License 许可
- Apache-2.0
- 最近更新
- 2026-10-05
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- token-optimization
- description
- Strategies for reducing token usage in Claude sessions. Use when approaching context limits, loading large codebases, or wanting faster/cheaper sessions. Covers anatomy-first reading, targeted grep over full-file reads, and context window management.
03 SKILL.md 正文
Token Optimization Skill
Maximize quality while minimizing token consumption in every session.
Core Principle
Read anatomy first, grep second, read files third.
The .wolf/anatomy.md file contains a curated map of the entire codebase. Reading it costs ~2K tokens versus ~350K to explore files ad-hoc.
Session Start Protocol
- Read
CLAUDE.md(~2K tokens) — rules, patterns, critical reminders - Read
.wolf/anatomy.md(~3K tokens) — project structure map - Read
.wolf/cerebrum.md(~4K tokens) — accumulated knowledge - Grep for specific patterns rather than reading full directories
- Read only the specific files you need to change
Savings: ~30K tokens per session vs. ad-hoc exploration
Token-Saving Patterns
Instead of reading entire directories
# ❌ Expensive: reads 50+ files
ls app/(dashboard)/ → read each page.tsx
# ✅ Cheap: targeted search
grep -rn "useTranslations" app/(dashboard)/cash-runway/ --include="*.tsx"
Instead of reading full registry
# ❌ Expensive
read: src/lib/agent-skills/registry.ts (800+ lines)
# ✅ Cheap: find what you need
grep -n "cto_agent\|finance_agent" src/lib/agent-skills/registry.ts
Instead of reading all message files
# ❌ Expensive
read: messages/ar.json (2000+ lines)
# ✅ Cheap: find the namespace
grep -A 20 '"CashRunway"' messages/ar.json
Context Window Management
When to use the wolf hooks
- session-start: Always — orients you in 200 tokens instead of 30K
- memory-persist: When you discover a new pattern worth keeping
- learn-from-error: When a bug is resolved and lessons should be saved
- session-end: When wrapping up significant work
File size awareness
| File | Approx tokens | Strategy |
|---|---|---|
messages/ar.json |
~12K | Use grep, read specific namespace |
src/lib/agent-skills/registry.ts |
~8K | Use grep for specific agent |
app/(dashboard)/**/page.tsx |
~3K each | Read only file you're changing |
SKILL.md files |
~2K each | Load only when skill is relevant |
.wolf/anatomy.md |
~3K | Always read first |
Kalmeron-Specific Token Traps
messages/ar.json+messages/en.json: These grow every session. Use grep to check if a key exists before reading the full file.registry.ts: 800+ lines. Grep for the specific agent rather than reading it all.app/(dashboard)/: 30+ pages. Let anatomy.md tell you which file to open..agents/skills/: 120+ SKILL.md files. Only load the skill that's relevant to the current task.
Weekly Token Budget Review
Check .wolf/token-ledger.json to see if the project is trending over 500K tokens per session.
If sessions consistently exceed 350K tokens:
- Run
.wolf/hooks/scan-anatomy.shto update estimates - Review anatomy.md for stale information
- Archive old cerebrum entries to
cerebrum-archive.md
04 同仓库更多 Skills
skill-creator
To create new CLI skills following Anthropic's official best practices with zero manual configuration. This skill automates brainstorming, template application, validation, and installation processes while maintaining progressive disclosure patterns and writing style standards.
business-investment-advisor
Business investment analysis and capital allocation advisor. Use when evaluating whether to invest in equipment, real estate, a new business, hiring, technology, or any capital expenditure. Also use for ROI calculations, IRR, NPV, payback period, build vs buy decisions, lease vs buy analysis, vendor evaluation, or deciding where to allocate limited budget for maximum return.
add-new-agent
خطوات تفصيليّة لإضافة وكيل ذكاء اصطناعي جديد إلى منصّة Kalmeron من الفكرة إلى الإنتاج
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
writing-plans
Use when you have a spec or requirements for a multi-step task, before touching code
web-design-guidelines
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".