Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
athola avatar

Context Optimization

  • 100 installs
  • 325 repo stars
  • Updated August 2, 2026
  • athola/claude-night-market

context-optimization is an 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.

About

context-optimization (Belief Clarity module) is a conservation-layer agent skill that stops you from shipping truncated chat history or session-state files that look tidy but cannot answer what was done and what is still missing. Solo builders running long Claude Code, Cursor, or Codex sessions hit context limits constantly; without this gate, continuation agents confidently execute the wrong next step because intermediate summaries dropped constraints. The skill implements two anchor questions—a progress probe and a gap probe—against any draft memory or compressed context, and blocks handoff when answers are vague. Use it journey-wide whenever you compress, summarize, or write session-state.md before clear-context workflows. It is intermediate complexity because you must interpret qualitative failures and expand the summary rather than expecting automatic metrics. Outcome is safer multi-step agent work with fewer belief-deviation loops across Build, Ship, and Operate debugging marathons.

  • 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

Context Optimization by the numbers

  • 100 all-time installs (skills.sh)
  • Ranked #4,381 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Security screen: HIGH risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/athola/claude-night-market --skill context-optimization

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs100
repo stars325
Security audit2 / 3 scanners passed
Last updatedAugust 2, 2026
Repositoryathola/claude-night-market

What it does

Verify compressed or handoff context still answers progress and gap probes before the next agent turn runs on stale beliefs.

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 you get

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

By the numbers

  • Two anchor questions (progress probe and gap probe) as the pre-compression gate

Files

SKILL.mdMarkdownGitHub ↗

Table of Contents

Context Optimization Hub

When To Use

  • Threshold Alert: When context usage approaches 50% of the window.
  • Complex Tasks: For operations requiring multi-file analysis or long tool chains.

When NOT To Use

  • Simple single-step tasks with low context usage
  • Already using mcp-code-execution for tool chains

Core Hub Responsibilities

1. Assess context pressure and MECW compliance. 2. Route to appropriate specialized modules. 3. Coordinate subagent-based workflows. 4. Manage token budget allocation across modules. 5. Synthesize results from modular execution.

Module Selection Strategy

def select_optimal_modules(context_situation, task_complexity):
    if context_situation == "CRITICAL":
        return ['mecw-assessment', 'subagent-coordination']
    elif task_complexity == 'high':
        return ['mecw-principles', 'subagent-coordination']
    else:
        return ['mecw-assessment']

Context Classification

UtilizationStatusAction
< 30%LOWContinue normally
30-50%MODERATEMonitor, apply principles
> 50%CRITICALImmediate optimization required

Large Output Handling (Claude Code 2.1.2+)

Behavior Change: Large bash command and tool outputs are saved to disk instead of being truncated; file references are provided for access.

Impact on Context Optimization

ScenarioBefore 2.1.2After 2.1.2
Large test outputTruncated, partial dataFull output via file reference
Verbose build logsLost after 30K charsComplete, accessible on-demand
Context pressureLess from truncationSame - only loaded when read

Best Practices

  • Avoid pre-emptive reads: Large outputs are referenced, not automatically loaded into context.
  • Read selectively: Use head, tail, or grep on file references.
  • Use full data: Quality gates can access complete test results via files.
  • Monitor growth: File references are small, but reading the full files adds to context.

Integration Points

  • Token Conservation: Receives usage strategies, returns MECW-compliant optimizations.
  • CPU/GPU Performance: Aligns context optimization with resource constraints.
  • MCP Code Execution: Delegates complex patterns to specialized MCP modules.

Resources

  • MECW Theory: See modules/mecw-principles.md for core concepts, the 50% rule, and quick-start code examples.
  • Context Analysis: See modules/mecw-assessment.md for risk identification.
  • Workflow Delegation: See modules/subagent-coordination.md for decomposition patterns.
  • Context Waiting: See modules/context-waiting.md for deferred loading strategies.
  • Cache Alignment: See modules/cache-aligned-prefixes.md for ordering context so provider KV caches hit (stable prefix first, volatile last).

Troubleshooting

Common Issues

If context usage remains high after optimization, check for large files that were read entirely rather than selectively. If MECW assessments fail, ensure that your environment provides accurate token count metadata. For permission errors when writing output logs to /tmp, verify that the project's temporary directory is writable.

Exit Criteria

  • [ ] Context pressure assessed against the MECW 50% rule
  • [ ] A memory tier or routing decision recorded for the current state
  • [ ] Large outputs referenced by file or handle, not read in full
  • [ ] When the request controls the provider payload, prefix ordering checked

against modules/cache-aligned-prefixes.md (stable first, volatile last)

  • [ ] Optimization downgraded to advisory when the harness already caches

(cache writes cost more than they save on non-repeated prefixes)

Related skills

How it compares

Use as a qualitative belief gate before compression, not as automatic token budgeting or RAG chunking.

FAQ

Who is context-optimization for?

It is for developers 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.

AI & Agent Buildingagentsautomation

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.