1---2name: common-context-optimization3description: Manage context and prompt-cache costs without losing task state. Use for context management, orchestration cost, token budgets, large tool outputs, cache misses, or long-running conversations.4metadata:5 source: https://skillmd.com/skills/hoangnguyen0403/common-context-optimization6 triggers:7 files:8 - "*.log"9 - "chat-history.json"10 keywords:11 - reduce tokens12 - optimize context13 - summarize history14 - clear output15 - context management16 - prompt-cache17 - prompt caching18 - orchestration cost19---2021## **Priority: P1 (HIGH)**2223## Workflow24251. **Inspect** host capabilities; do not assume agents can rewrite history, prompts, or memory.262. **Project outputs** after consuming them: retain decisions, evidence, errors, and required values; point to complete logs/artifacts by stable reference.273. **Bound context** at host-supported boundaries. Carry goal, active slice, authority, decisions, blockers, evidence links, and next action; preserve a stable append-only prefix where supported.284. **Compact** only when useful and supported. Keep required details retrievable; never discard source evidence or rely on a fixed turn/token threshold.295. **Measure** cache reads, replayed input, and total actor cost across the whole task. Separate observed usage from estimates; no invoice, savings, or efficacy claims without evidence.3031## Anti-Patterns3233- **No history rewrite assumption**: Project outputs or create artifact references; use only host-supported controls.34- **No fixed threshold**: Compact from observed context pressure and task needs, not a universal turn/token count.35- **No evidence deletion**: Keep stable references to source outputs, decisions, and verification. Archive required packets, reports and receipts at durable references before cleanup.36- **No omission-as-optimization**: Never claim savings from suppressing required instruction bodies. Selection or body-return counts are not acknowledgment, comprehension, or enforcement.37- **No partial cost claim**: Include cache reads, replay, and total actor cost; label estimates. Missing coverage or rates means no savings claim.3839## References4041- [Compaction](references/compaction.md)42- [Masking and output projection](references/masking.md)43- [Implementation and cost measurement](references/implementation.md)