Agent skill

Context Optimization

by athola in athola/claude-night-market

Optimizes context window via MECW principles and memory tiering.

MITAuto-check passedAgent Workflows

Install Context Optimization

skills CLI
$ npx skills add athola/claude-night-market --skill context-optimization -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install athola/claude-night-market context-optimization --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/athola/claude-night-market.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/conserve/skills/context-optimization .claude/skills/context-optimization && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
context-optimization
GitHub stars
342
Token cost
~1.4k tokens
SKILL.md length
469 words
Files
13
Skills in repo
160
Repo updated
First seen
Licence
MIT

At a glance

Optimizes context window via MECW principles and memory tiering.

  • Works in 5 steps: Assess context pressure and MECW… → Route to appropriate specialized modules. → Coordinate subagent-based workflows. → …
  • Context exceeds 30%
  • SKILL.md covers When To Use, When NOT To Use, Core Hub Responsibilities and Module Selection Strategy, plus 6 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Context Optimization is an agent skill from athola/claude-night-market. Optimizes context window via MECW principles and memory tiering. Use when context exceeds 30% or before long multi-step tasks.

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 13 other files (for example `modules/belief-clarity.md`, `modules/cache-aligned-prefixes.md` and `modules/compression-strategies.md`).

It sits in Agent Workflows, covering Context engineering. It works with Model Context Protocol. The repository describes itself as: 23 Claude Code plugins: TDD enforcement hooks, git/PR workflows, spec-driven development, code review, project lifecycle, fix-from-error, maintenance automation, context… The licence is MIT.

When your agent uses it

  • Context exceeds 30%
  • Before long multi-step tasks

Example prompts

  • “Use the context-optimization skill to optimiz context window via MECW principles and memory tiering”
  • “/context-optimization”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  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.

What it can do on your machine

Read from SKILL.md and the folder at commit 9f3eb00. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Context Optimization loads about 1.4k tokens when it runs. Until then it costs about 37 tokens; SKILL.md has 469 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~37
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from athola/claude-night-market at commit 9f3eb00, republished under its MIT licence (© athola). 469 words, ~1,422 tokens.

Download SKILL.mdSave it as .claude/skills/context-optimization/SKILL.md (or your agent's skills folder). This skill also uses 12 other files; get the full folder from GitHub.
name
context-optimization
description
Optimizes context window via MECW principles and memory tiering. Use when context exceeds 30% or before long multi-step tasks.
alwaysApply
false
category
conservation
token_budget
150
progressive_loading
true
modules
modules/context-waiting.md, modules/findings-format.md, modules/mecw-assessment.md, modules/mecw-principles.md, modules/memory-tiers.md…
model_hint
standard
role
hook-target

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

python
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.
Show full SKILL.md (224 more words)Show less

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).
  • Compression Choice: See modules/compression-strategies.md to pick one of /clear and /catchup, a continuation agent, archive and summarize, or delegation, with savings and risk.
  • Large Tool Outputs: See modules/reversible-compression.md for archiving an oversized output to a retrievable handle.
  • Pasted Logs: See modules/log-debugging-hygiene.md for filtering a log before any compression. /filter-log anchors on it.

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)

© athola, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 12 other files in plugins/conserve/skills/context-optimization of athola/claude-night-market.

  • SKILL.md
  • modules/belief-clarity.md
  • modules/cache-aligned-prefixes.md
  • modules/compression-strategies.md
  • modules/context-waiting.md
  • modules/findings-format.md
  • modules/log-debugging-hygiene.md
  • modules/mecw-assessment.md
  • modules/mecw-principles.md
  • modules/memory-tiers.md
  • modules/reversible-compression.md
  • modules/session-routing.md
  • modules/subagent-coordination.md

Open the folder on GitHubat commit 9f3eb00

Compare with similar skills

Context Optimization next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Context Optimization compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Context Optimization this skillathola/claude-night-market342—~1.4kAutomated safety check: PassMIT
Context Mode Output Sandboxmksglu/context-mode26k—~4.1kAutomated safety check: PassCustom licence
Context Mode for Antigravity CLImksglu/context-mode26k—~850Automated safety check: PassCustom licence
Base HelpChristopherKahler/base287—~2.6kAutomated safety check: PassCustom licence
LemmalogJordyZomer/lemmalog329—~2.8kAutomated safety check: PassMIT
Cortex Mem MCPsopaco/cortex-mem312—~2.8kAutomated safety check: PassMIT

Similar skills

  • Context Mode Output Sandbox

    mksglu/context-mode

    Routes large command, file, API and browser output through context-mode tools so only the needed result enters the agent's context, instead of dumping it via Bash.

    26k GitHub stars~4.1k tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Routing rules for using context-mode MCP tools in Antigravity CLI: sandboxed code runs, file analysis, indexed search and web fetches that keep large output out of the conversation.

    26k GitHub stars~850 tokensUpdated today
    Agent WorkflowsAuto-check passed
  • Base Help

    ChristopherKahler/base

    Coach mode for the base CLI: teaches what to do and why, rather than just answering.

    287 GitHub stars~2.6k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • Lemmalog

    JordyZomer/lemmalog

    Externalize working memory and logical state into the lemmalog Datalog engine (MCP).

    329 GitHub stars~2.8k tokensUpdated 6 days ago
    Agent WorkflowsAuto-check passed
  • Cortex Mem MCP

    sopaco/cortex-mem

    Persistent memory enhancement for AI agents. An agent skill from sopaco/cortex-mem.

    312 GitHub stars~2.8k tokensUpdated 2 mo ago
    Agent WorkflowsAuto-check passed
  • MCP Code Search Tool Selection

    Context-Engine-AI/Context-Engine

    Rules for choosing Qdrant-Indexer semantic search over grep or file reads when exploring code, debugging or asking where and why questions.

    402 GitHub stars~1.3k tokensUpdated 3 mo ago
    Agent WorkflowsAuto-check passed

More from athola/claude-night-market

All 160 skills in this repo
  • Night Market Diagnostics Toolkit

    athola/claude-night-market

    Run and interpret repo diagnostic scripts (ratchets, validators, token stats).

    342 GitHub stars~3.4k tokensUpdated yesterday
    Auto-check passed
  • Skills Eval

    athola/claude-night-market

    Evaluate Claude skill quality through auditing. An agent skill from athola/claude-night-market.

    342 GitHub stars~1.6k tokensUpdated yesterday
    Auto-check passed
  • Agent Teams

    athola/claude-night-market

    Coordinates Claude agent teams via filesystem protocol. An agent skill from athola/claude-night-market.

    342 GitHub stars~2.5k tokensUpdated yesterday
    Auto-check passed
  • Delegation Core

    athola/claude-night-market

    Delegates execution to eight CLIs (Gemini, Qwen, MiniMax, GLM, Muse, Codex, OpenCode, Glimmer).

    342 GitHub stars~2.5k tokensUpdated yesterday
    Auto-check passed
  • Elegant Code

    athola/claude-night-market

    Guide minimal code via a decision ladder with full safety, edge, and negative-case coverage.

    342 GitHub stars~2.1k tokensUpdated yesterday
    Auto-check passed
  • Skill Library Mission

    athola/claude-night-market

    Build a project skill library in .claude/skills/ via discovery, parallel authoring, and review.

    342 GitHub stars~1.6k tokensUpdated yesterday
    Auto-check passed

Categories

Questions about Context Optimization

What does Context Optimization do?

Optimizes context window via MECW principles and memory tiering. Context Optimization is an agent skill from athola/claude-night-market. Optimizes context window via MECW principles and memory tiering.

When should I use Context Optimization?

Context Optimization fits situations like: context exceeds 30%; before long multi-step tasks.

How do I install Context Optimization in Claude Code?

Run `npx skills add athola/claude-night-market --skill context-optimization -a claude-code`. Or copy the skill folder (plugins/conserve/skills/context-optimization in athola/claude-night-market) into .claude/skills/context-optimization in your project. Claude Code loads it when a task matches its description.

How do I install Context Optimization in Codex?

Run `npx skills add athola/claude-night-market --skill context-optimization -a codex`. Or copy the skill folder (plugins/conserve/skills/context-optimization in athola/claude-night-market) into .agents/skills/context-optimization in your project. Codex loads it when a task matches its description.

Can I use Context Optimization in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add athola/claude-night-market --skill context-optimization -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/context-optimization, .gemini/skills/context-optimization, .github/skills/context-optimization and .opencode/skills/context-optimization in your project.

What does Context Optimization need to run?

SKILL.md names no scripts, command-line tools or credentials: Context Optimization is instructions for the agent only. Our summary lists: Python 3.

Does Context Optimization access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Context Optimization safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Context Optimization use?

Context Optimization is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Context Optimization use?

About 1.4k tokens (SKILL.md is roughly 5.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Context Optimization?

Skills that share tags, products or a category with Context Optimization: Context Mode Output Sandbox (mksglu/context-mode, 26k stars), Context Mode for Antigravity CLI (mksglu/context-mode, 26k stars), Base Help (ChristopherKahler/base, 287 stars) and Lemmalog (JordyZomer/lemmalog, 329 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Context Optimization?

athola (a GitHub user) maintains it in athola/claude-night-market, which has 342 GitHub stars. The repository holds 160 skills in this directory. The repository was last updated on October 6, 2026.

Source: athola/claude-night-market on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.