
Context Optimization
Verify compressed or handoff context still answers progress and gap probes before the next agent turn runs on stale beliefs.
Overview
context-optimization is a journey-wide agent skill that runs dual anchor-question clarity checks—usable whenever a solo builder needs to validate compressed context before committing to the next agent turn.
Install
npx skills add https://github.com/athola/claude-night-market --skill context-optimizationWhat is this skill?
- Dual anchor questions: progress probe and gap probe before accepting compression
- Pre-compression gate tied to MMPO-style belief-clarity (ambiguous summaries cause task drift)
- Apply before saving session-state.md and after any context-optimization pass
- Qualitative checker—not a tokenizer—focused on whether future reasoning can resume correctly
- Pairs with conserve:clear-context and conserve:context-optimization handoff points
- Two anchor questions (progress probe and gap probe) as the pre-compression gate
Adoption & trust: 1 installs on skills.sh; 304 GitHub stars; 2/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
What problem does it solve?
Your agent handoff or compressed context reads fine but cannot state real progress or missing requirements, so the next session drifts off-task.
Who is it for?
Long multi-step agent runs where you regularly compress context, rotate models, or delegate to a continuation agent with session-state.md.
Skip if: Single-shot prompts with no compression, or teams that do not maintain structured session state between agent invocations.
When should I use this skill?
Before saving session-state.md for clear-context, or immediately after any context compression or optimization step.
What do I get? / Deliverables
You reject or enrich summaries until both progress and gap probes are answerable, then proceed with clear-context or continuation workflows without silent belief deviation.
- Pass/fail clarity assessment on progress and gap probes
- Enriched summary instructions when probes fail
Recommended Skills
Journey fit
Useful at every journey phase - explore requirements and options before committing to a direction.
Where it fits
Before invoking clear-context, confirm session-state.md answers what files changed and what tests are still failing.
After summarizing a long PR review thread, run gap probe so the continuation agent still knows blocking review comments.
When resuming an outage investigation from a compressed log summary, verify the probe recalls current hypothesis and open actions.
Before handing a scoped prototype spec to a fresh agent, ensure compressed notes still list acceptance criteria gaps.
How it compares
Use as a qualitative belief gate before compression, not as automatic token budgeting or RAG chunking.
Common Questions / FAQ
Who is context-optimization for?
It is for solo builders and maintainers of agent conservation stacks who need reliable handoffs after context limits or intentional summarization.
When should I use context-optimization?
Use it before saving session-state in Build agent-tooling, after compression during Ship review marathons, and before Operate iterate sessions when you resume incident or refactor threads from a summary file.
Is context-optimization safe to install?
It is a read-only reasoning checklist with no external calls described, but review the Security Audits panel on this page before chaining it with skills that write secrets into session-state.
SKILL.md
READMESKILL.md - Context Optimization
# Belief Clarity Module ## Purpose Before compressing context or handing off to a continuation agent, verify the compressed form can answer two anchor questions. If it cannot, the compression has lost task-critical information. This implements the anchor-question pattern from MMPO (arXiv:2605.30159, Liu et al. 2026) as a qualitative pre-compression gate. The paper shows that ambiguous intermediate summaries cause belief deviation: the agent's internal model of the task drifts from reality as interactions extend. This module catches that drift before it causes a handoff failure. ## When to Apply Apply this check at two points: 1. **Before saving session-state.md** (conserve:clear-context): verify the draft state can answer both probes before delegating. 2. **After any context compression** (conserve:context-optimization): verify the compressed result retains the pre-compression answers. ## The Two Anchor Questions Ask these questions against the memory or compressed context: **Q1: Progress probe:** ``` Based on the current memory/context, what is the current task progress? What has been completed and what state is the task in now? ``` **Q2: Gap probe:** ``` Based on the current memory/context, what information is still needed to complete the task? List specific open items, not generic categories. ``` A memory that answers Q1 with specific completed steps and Q2 with a bounded list of concrete unknowns is clear enough to proceed. ## Scoring | Q1 answer | Q2 answer | Decision | |-----------|-----------|----------| | Specific and complete | Finite concrete list | Proceed | | Specific | Open-ended or generic | Expand memory before proceeding | | Hedging ("I think...") | Any | Regenerate or expand | | Vague or empty | Any | Regenerate: do not hand off | ## Usage Pattern ### Inline check before clear-context handoff ``` 1. Draft session-state.md with current task summary 2. Ask Q1 against the draft 3. Ask Q2 against the draft 4. If both score "Proceed": save and hand off 5. If either fails: append the failing probe's answer directly to session-state.md as "Current state: ..." and "Still needed: ..." then re-score ``` ### Post-compression verification ``` 1. Record Q1 and Q2 answers from pre-compression context 2. Apply compression (compact, summarize, delegate) 3. Ask Q1 and Q2 again against the compressed form 4. If answers materially match: compression preserved task state 5. If answers diverge: compression lost information; add a "Task state snapshot" section to the compressed form ``` ## Integration with memory-clarity-probe When `memory-palace:memory-clarity-probe` is available, delegate the dual-probe evaluation to it rather than running inline: ``` Skill(memory-palace:memory-clarity-probe) ``` The probe produces a `Clarity Assessment` block with composite score and recommendation. Use "Proceed" composite as the gate condition. ## Limitation This check is qualitative. It cannot compute token-level predictive entropy (true Belief Entropy from the MMPO paper) because Claude Code skills do not expose model log-probabilities. A session-state.md that produces confident but wrong answers to the probes will score as "Proceed" incorrectly. Pair this gate with explicit task-state verification (imbue:proof-of-work) for high-stakes handoffs. ## Failure Recovery If the check fails and expansion does not resolve it: 1. Do not hand off. The continuation agent will start from corrupted task state. 2. Ask the user to confirm current state and next steps. 3. Write the confirmed state explicitly as bullet points at the top of session-state.md before re-running the check. # Context Waiting Module ## Overview Integrates condition-based-waiting princip