Marketplace

Unnamed Skill

Reduce context usage with MECW principles (keep under 50% of total window).Triggers: context pressure, token usage, MECW, context window, optimization,decomposition, workflow splitting, context management, token optimizationUse when: context usage approaches 50% of window, tasks need decomposition,complex multi-step operations planned, context pressure is highDO NOT use when: simple single-step tasks with low context usage.DO NOT use when: already using mcp-code-execution for tool chains.Use this skill BEFORE starting complex tasks. Check context levels proactively.

$ 安裝

git clone https://github.com/athola/claude-night-market /tmp/claude-night-market && cp -r /tmp/claude-night-market/plugins/conserve/skills/context-optimization ~/.claude/skills/claude-night-market

// tip: Run this command in your terminal to install the skill


name: context-optimization description: |

Triggers: context, optimization Reduce context usage with MECW principles (keep under 50% of total window).

Triggers: context pressure, token usage, MECW, context window, optimization, decomposition, workflow splitting, context management, token optimization

Use when: context usage approaches 50% of window, tasks need decomposition, complex multi-step operations planned, context pressure is high

DO NOT use when: simple single-step tasks with low context usage. DO NOT use when: already using mcp-code-execution for tool chains.

Use this skill BEFORE starting complex tasks. Check context levels proactively. category: conservation token_budget: 150 progressive_loading: true

Claude Code 2.1.0+ lifecycle hooks

hooks: PreToolUse: - matcher: "Read" command: | echo "[skill:context-optimization] 📊 Context analysis started: $(date)" >> /tmp/skill-audit.log once: true PostToolUse: - matcher: "Bash" command: | # Track context analysis tools if echo "$CLAUDE_TOOL_INPUT" | grep -qE "(wc|tokei|cloc|context)"; then echo "[skill:context-optimization] Context measurement executed: $(date)" >> /tmp/skill-audit.log fi Stop: - command: | echo "[skill:context-optimization] === Optimization completed at $(date) ===" >> /tmp/skill-audit.log # Could export: context pressure events over time

Table of Contents

Context Optimization Hub

Quick Start

Basic Usage

```bash

Run the main command

python -m module_name

Show help

python -m module_name --help ```

Verification: Run with --help flag to confirm installation.

When to Use

  • Automatic: Keywords: context, tokens, optimization, MECW.
  • MECW Threshold: When context usage approaches 50% of total window size.
  • Complex Tasks: For tasks requiring multiple steps or analysis.

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 now saved to disk instead of truncated, with file references 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

  • Don't pre-emptively read: Large outputs are referenced, not loaded into context
  • Read selectively: Use head, tail, or grep on file references
  • Leverage full data: Quality gates can now access complete test results
  • Monitor growth: File references are cheap, but reading them 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

For implementation details:

  • MECW Theory: See modules/mecw-principles.md for core concepts and 50% rule.
  • Context Analysis: See modules/mecw-assessment.md for risk identification.
  • Workflow Delegation: See modules/subagent-coordination.md for decomposition patterns.

Troubleshooting

Common Issues

Command not found Ensure all dependencies are installed and in PATH

Permission errors Check file permissions and run with appropriate privileges

Unexpected behavior Enable verbose logging with --verbose flag