Claude-skill-registry context_mastery
Advanced token optimization and context management strategies.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/context-mastery-cityfish91159-maihouses" ~/.claude/skills/majiayu000-claude-skill-registry-context-mastery-528e42 && rm -rf "$T"
manifest:
skills/data/context-mastery-cityfish91159-maihouses/SKILL.mdsource content
Context Mastery & Token Optimization Protocol
1. The "Grep-First" Rule (Token Saver)
- Problem:
on a 2000-line file consumes ~500-1000 tokens instantly.read_file - Solution: Always use
orgrep
first to inspect specific functions or imports.read_file_range - Banned:
orcat
on entire directories or massive files (e.g.,read_file
, giant logs) unless absolutely necessary.package-lock.json
2. Incremental Summarization
- Trigger: When the conversation exceeds ~20 turns or you feel the context window filling.
- Action:
- Summarize what has been achieved in the last 10 turns.
- Write it to
orscratchpad.md
.active_task.md - Explicitly state "I am clearing internal context of validated steps" (if tool allows) or just rely on the scratchpad for future lookup.
3. Focused Context Loading
- Don't: "Read all files in
to understand the project." (Too expensive).src/ - Do:
- Read
/CLAUDE.md
.README.md - Read directory listing
.ls -R - Selectively read only the interfaces (
) or entry points (types.ts
) related to the current task.index.ts
- Read
4. Context Efficiency Checklist
- Did I use
instead of reading the whole file?grep - Did I check if I already have this info in
?MEMORY.md - Is my next prompt efficient? (Avoid repeating massive code blocks back to the user).