
reedom-flag-foryou
Document Optimization(Compaction) for Claude Code
Install
/plugin install reedom-flag-foryou@reedom-commands-and-skillsRun it inside Claude Code after adding the marketplace with /plugin marketplace add reedom/claude-code-commands.
Contents
Discovered from sourceSkills 1
Context Engineering Optimizer
Optimize content for AI consumption by reducing tokens while preserving essential information.
Core Principle
Context is finite. Every token depletes the attention budget. Optimize ruthlessly.
Reference: context-engineering-guide.md
Optimization Workflow
Use TodoWrite
Step 1: Create Draft
Analyze input and create optimized version:
Remove/Reduce:
- Redundant explanations (AI already knows common knowledge)
- Verbose transitions ("In this section, we will discuss...")
- Duplicate information across sections
- Filler words and phrases
- Overly detailed examples when one suffices
- Charts/diagrams/tables if text conveys same info more efficiently
Preserve:
- Domain-specific knowledge AI lacks
- Concrete examples that demonstrate behavior
- Critical constraints and rules
- Structural organization (headers, sections)
- Actionable instructions
Format choices:
- Prefer bullet points over prose
- Use imperative form
- Choose text OR graphical representation, not both
- Keep code examples minimal but complete
Language:
- English no matter the original language unless otherwise specified through prompt
- Most token-efficient for current models
- Preserves technical terminology accuracy
XML + Markdown tables:
<!-- WRONG -->
<data>
| Col | Val |
|-----|-----|
| A | B |
</data>
<!-- CORRECT - empty lines required -->
<data>
| Col | Val |
|-----|-----|
| A | B |
</data>
Step 2: Compare and Refine
Compare draft against original:
Check for information loss:
- Critical details missing?
- Context for understanding removed?
- Edge cases dropped that matter?
Check for over-optimization:
- Can sections be further condensed?
- Any remaining redundancy?
- Self-evident comments still present?
Restore if:
- Meaning becomes ambiguous
- Important nuance lost
- Actionability reduced
Step 3: Output
For materials (files to overwrite):
- Overwrite original with optimized version
For transient content:
- Output the optimized version as final result
Quality Criteria
Optimized content should:
- Reduce token count by 30-70% typically
- Preserve all actionable information
- Maintain clear structure
- Be self-contained (no dangling references)
- Target the Goldilocks zone: specific enough to guide, flexible enough to adapt
Agents 1
Context Engineering for AI Agents
Source: anthropic.com/engineering/effective-context-engineering-for-ai-agents
Core Principle
Context engineering > prompt engineering. Manage the complete token configuration for optimal model behavior, not just instructions.
Why Context Matters
Context rot: More tokens = reduced recall precision (gradient, not cliff) Attention dilution: n^2 pairwise relationships stretch thin as context grows Training bias: Models trained on shorter sequences perform better there
Effective Context Anatomy
System Prompts
Target the Goldilocks zone:
- Specific enough to guide behavior
- Flexible enough to avoid brittle logic
Avoid:
- Hardcoded if-else logic (breaks under variation)
- Vague high-level guidance (assumes shared context)
Structure with XML tags or Markdown headers: <instructions>, ## Tool guidance
Tools
Well-designed tools are:
- Self-contained
- Robust to error
- Clear about intended use
Failure pattern: Bloated toolsets with overlapping functionality. If humans can't identify which tool to use, neither can agents.
Examples (Few-Shot)
Don't stuff edge cases. Curate diverse, canonical examples that portray expected behavior. Examples function as powerful visual references for LLMs.
Context Retrieval
Just-in-Time (Preferred)
Maintain lightweight identifiers (paths, URLs, queries), retrieve dynamically via tools.
Benefits:
- Progressive disclosure through exploration
- File sizes suggest complexity
- Naming conventions indicate purpose
- Timestamps signal relevance
Hybrid Strategy
Combine pre-loaded essentials (CLAUDE.md) with autonomous exploration (glob, grep).
Long-Horizon Techniques
Compaction
Summarize conversation history approaching limits. Preserve:
- Architectural decisions
- Unresolved bugs
- Implementation details
Discard:
- Redundant tool outputs
- Verbose messages
Approach: Maximize recall first, then optimize precision.
Structured Note-Taking
Write external persistent notes, pull back as needed. Enables multi-hour coherence without memory prompting.
Sub-Agent Architecture
Specialized sub-agents handle focused tasks with clean context. Return condensed summaries (1,000-2,000 tokens) not exhaustive output. Achieves clear separation of concerns.
Key Rules
- Context is finite - Every token depletes attention budget. Curate ruthlessly.
- Start minimal - Test with minimal prompts on best model, add clarity based on failures.
- Efficient tools - Return token-efficient info, encourage efficient behaviors.
- Match technique to task:
- Compaction: extensive back-and-forth
- Note-taking: iterative development
- Multi-agent: parallel exploration
- Embrace autonomy - Let intelligent models act intelligently with less curation.
Sponsors
Details
- Marketplace
- reedom/claude-code-commands
- Source
- flag-foryou
- Author
- HANAI Tohru
- Category
- Community