Context Conservation
Rules for maximizing work done per context window. Every token spent on exploration is a token not spent on implementation.
Core Principles
- Grep first, read second — never Read a file blind. Grep for the symbol/pattern, get line numbers, then Read with offset/limit.
- Narrow reads — always use offset/limit. Aim for 10-20 lines around the target, not 100+.
- One read per edit — Read the target lines, Edit them, move on. Don't re-read to verify; the Edit tool confirms success.
- Parallel independent calls — if you need to read 3 files, do it in one message with 3 Read calls.
- No redundant searches — if you already know the file and line from a prior Grep, go straight to Read+Edit.
Tool Selection — Cheapest First
| Need |
Use |
NOT |
| Find a file by name |
Glob |
Explore agent, find, ls -R |
| Find a symbol in code |
Grep (files_with_matches) |
Explore agent, Read + scan |
| Read specific lines |
Read (offset/limit) |
cat, head, full-file Read |
| Simple edit |
Edit |
sed, awk, Write (full rewrite) |
| Repeated pattern edit |
Edit with replace_all: true |
Multiple individual Edits |
| Add key to 7 i18n files |
7 parallel Edits |
Invoke i18n skill |
When NOT to Use Agents
Don't use Explore/Task agent when:
- You know the file — just Grep + Read directly
- The search is simple — one Grep finds it
- You need < 3 lookups — do them yourself
Do use Explore agent when:
- Truly open-ended search across unknown files
- Need to understand an unfamiliar subsystem
- Would take 5+ Grep/Read rounds to find what you need
When NOT to Invoke Skills
Don't invoke a skill when:
- The task is trivial (e.g., adding one i18n key — just Grep the insertion point and Edit 7 files)
- You already know the pattern from memory/context
- The skill document is large and the task is small
Do invoke a skill when:
- Following a multi-step procedure with project-specific gotchas
- The task is complex enough that the skill's checklist prevents mistakes
- You genuinely don't remember the procedure
Read Discipline
BAD: Read(file, offset=1, limit=2000) // entire file, huge context cost
BAD: Read(file) // same — default reads everything
OK: Read(file, offset=350, limit=50) // 50 lines around target
GOOD: Read(file, offset=368, limit=5) // just the lines you need
After a Grep gives line 370, read lines 368-373 (offset=368, limit=6). Not 300-450.
Edit Discipline
- Trust Edit output — it confirms success. Don't Read after to verify.
replace_all: true — for patterns repeated across a file (e.g., renaming a variable). One Edit, not N.
- Include minimal context —
old_string just needs to be unique, not the whole function.
Search Strategy
- Start with
Grep(pattern, output_mode="files_with_matches") — cheapest, just filenames
- If needed,
Grep(pattern, output_mode="content", -n=true) on the specific file — gives line numbers
- Then
Read(file, offset=line-2, limit=10) — surgical read
- Edit and move on
Multi-File Edits (e.g., i18n)
For identical edits across multiple files:
- Grep one file to find insertion point and context
- Read the 2-3 target lines from ALL files in parallel (one message, 7 Read calls)
- Edit ALL files in parallel (one message, 7 Edit calls)
Total: 1 Grep + 7 Reads + 7 Edits = 15 tool calls. Not a skill invocation + exploration.
File Size Awareness
Files over ~300 lines cost 1-2K tokens per full read. A read-edit-read cycle on a 1000+ line file eats 4-6K tokens. When a file repeatedly causes context pressure:
- Decompose it — extract inline components, utility functions, tab content into separate files (see
2026-03-03-monster-file-decomposition journey)
- Extraction order: pure utilities → inline components with typed props → shared/duplicated rendering → tab content → complex sections
- Move local-only state into extracted components — if state is only used within a tab, make it internal, don't pass as props
- Target: each file under 300 lines. The page shell keeps imports, hooks, layout; everything else gets its own file.
Current monster files remaining: GovernanceTable.tsx (1263), drep/[drepId].tsx (1392)
Anti-Patterns
| Anti-pattern |
Cost |
Fix |
| Explore agent for known files |
~50K tokens |
Direct Grep + Read |
| Full-file Read to find one function |
~5K tokens |
Grep for function name first |
| Reading file before every Edit |
2x reads |
Read once, Edit, trust output |
| Loading large skill for small task |
~3K tokens |
Just do the task directly |
| Re-reading after successful Edit |
Wasted read |
Edit tool already confirms |
| Sequential reads that could be parallel |
Wasted turns |
Batch into one message |
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: context3description: Context window conservation rules. Invoke when approaching context limits or before large tasks. Use when this capability is needed.4---56# Context Conservation78Rules for maximizing work done per context window. Every token spent on exploration is a token not spent on implementation.910## Core Principles11121. **Grep first, read second** — never Read a file blind. Grep for the symbol/pattern, get line numbers, then Read with offset/limit.132. **Narrow reads** — always use offset/limit. Aim for 10-20 lines around the target, not 100+.143. **One read per edit** — Read the target lines, Edit them, move on. Don't re-read to verify; the Edit tool confirms success.154. **Parallel independent calls** — if you need to read 3 files, do it in one message with 3 Read calls.165. **No redundant searches** — if you already know the file and line from a prior Grep, go straight to Read+Edit.1718## Tool Selection — Cheapest First1920| Need | Use | NOT |21|------|-----|-----|22| Find a file by name | `Glob` | Explore agent, `find`, `ls -R` |23| Find a symbol in code | `Grep` (files_with_matches) | Explore agent, Read + scan |24| Read specific lines | `Read` (offset/limit) | `cat`, `head`, full-file Read |25| Simple edit | `Edit` | `sed`, `awk`, Write (full rewrite) |26| Repeated pattern edit | `Edit` with `replace_all: true` | Multiple individual Edits |27| Add key to 7 i18n files | 7 parallel Edits | Invoke i18n skill |2829## When NOT to Use Agents3031**Don't use Explore/Task agent when:**32- You know the file — just Grep + Read directly33- The search is simple — one Grep finds it34- You need < 3 lookups — do them yourself3536**Do use Explore agent when:**37- Truly open-ended search across unknown files38- Need to understand an unfamiliar subsystem39- Would take 5+ Grep/Read rounds to find what you need4041## When NOT to Invoke Skills4243**Don't invoke a skill when:**44- The task is trivial (e.g., adding one i18n key — just Grep the insertion point and Edit 7 files)45- You already know the pattern from memory/context46- The skill document is large and the task is small4748**Do invoke a skill when:**49- Following a multi-step procedure with project-specific gotchas50- The task is complex enough that the skill's checklist prevents mistakes51- You genuinely don't remember the procedure5253## Read Discipline5455```56BAD: Read(file, offset=1, limit=2000) // entire file, huge context cost57BAD: Read(file) // same — default reads everything58OK: Read(file, offset=350, limit=50) // 50 lines around target59GOOD: Read(file, offset=368, limit=5) // just the lines you need60```6162After a Grep gives line 370, read lines 368-373 (offset=368, limit=6). Not 300-450.6364## Edit Discipline6566- **Trust Edit output** — it confirms success. Don't Read after to verify.67- **`replace_all: true`** — for patterns repeated across a file (e.g., renaming a variable). One Edit, not N.68- **Include minimal context** — `old_string` just needs to be unique, not the whole function.6970## Search Strategy71721. Start with `Grep(pattern, output_mode="files_with_matches")` — cheapest, just filenames732. If needed, `Grep(pattern, output_mode="content", -n=true)` on the specific file — gives line numbers743. Then `Read(file, offset=line-2, limit=10)` — surgical read754. Edit and move on7677## Multi-File Edits (e.g., i18n)7879For identical edits across multiple files:801. Grep one file to find insertion point and context812. Read the 2-3 target lines from ALL files in parallel (one message, 7 Read calls)823. Edit ALL files in parallel (one message, 7 Edit calls)8384Total: 1 Grep + 7 Reads + 7 Edits = 15 tool calls. Not a skill invocation + exploration.8586## File Size Awareness8788Files over ~300 lines cost 1-2K tokens per full read. A read-edit-read cycle on a 1000+ line file eats 4-6K tokens. When a file repeatedly causes context pressure:89901. **Decompose it** — extract inline components, utility functions, tab content into separate files (see `2026-03-03-monster-file-decomposition` journey)912. **Extraction order**: pure utilities → inline components with typed props → shared/duplicated rendering → tab content → complex sections923. **Move local-only state into extracted components** — if state is only used within a tab, make it internal, don't pass as props934. **Target**: each file under 300 lines. The page shell keeps imports, hooks, layout; everything else gets its own file.9495**Current monster files remaining**: `GovernanceTable.tsx` (1263), `drep/[drepId].tsx` (1392)9697## Anti-Patterns9899| Anti-pattern | Cost | Fix |100|---|---|---|101| Explore agent for known files | ~50K tokens | Direct Grep + Read |102| Full-file Read to find one function | ~5K tokens | Grep for function name first |103| Reading file before every Edit | 2x reads | Read once, Edit, trust output |104| Loading large skill for small task | ~3K tokens | Just do the task directly |105| Re-reading after successful Edit | Wasted read | Edit tool already confirms |106| Sequential reads that could be parallel | Wasted turns | Batch into one message |107108---109> Converted and distributed by [TomeVault](https://tomevault.io/claim/nomos-guild) — claim your Tome and manage your conversions.110<!-- tomevault:4.0:skill_md:2026-04-11 -->