Skip to content
Development
Command

/optimize-context

Analyze context window usage against MECW principles and recommend reductions

From plugin
claude-night-market
343162 skills60 agents162 commands1 MCP
> /plugin marketplace add athola/claude-night-market

Command definition

optimize-context.md
name: optimize-context
description: Analyze context window usage against MECW principles and recommend reductions
usage: /optimize-context [path]

Context Window Usage Review

Analyzes context window usage and provides optimization recommendations based on Maximum Effective Context Window (MECW) principles.

Usage

# Analyze current session context
/optimize-context

# Analyze specific skill or directory
/optimize-context skills/my-skill

# Deep analysis with recommendations
/optimize-context --detailed

What It Does

1. **Context Pressure Assessment**: Evaluates current context utilization 2. **MECW Compliance Check**: Validates against MECW principles 3. **Optimization Recommendations**: Suggests specific improvements 4. **Token Budget Analysis**: Breaks down token usage by component

MECW Thresholds

| Utilization | Status | Action | |-------------|--------|--------| | < 30% | Optimal | No action needed | | 30-50% | Good | Monitor growth | | 50-70% | Warning | Consider optimization | | > 70% | Critical | Immediate action required |

Examples

/optimize-context
# Output:
# Context Optimization Report
# ==========================
# Current Usage: 45% (Good)
# Estimated Tokens: 12,500
#
# Recommendations:
# - Consider extracting code examples to scripts/
# - 3 skills exceed recommended token budget

/optimize-context skills/context-optimization --detailed
# Full breakdown with per-module analysis

Headless Mode (Non-Interactive)

For reading context in headless/automated Claude Code sessions:

# Get context breakdown with JSON output
claude -p "run /context" --verbose --output-format json

# Two-call pattern for reliable execution
# (Claude doesn't always execute /context on first prompt)
SESSION_ID=$(claude -p "ready" --output-format json | jq -r '.session_id')
claude --continue "$SESSION_ID" -p "/context" --verbose --output-format json

**Key flags:**

  • `--verbose`: Includes categorical token breakdown
  • `--output-format json`: Machine-parseable output
  • `--continue`: Resumes existing session for reliable command execution

**Example JSON output:**

{
  "context": {
    "total_tokens": 45000,
    "usage_percent": 22.5,
    "breakdown": {
      "system": 8000,
      "conversation": 32000,
      "tools": 5000
    }
  }
}

Integration

Works with conservation plugin skills:

  • `context-optimization` - Core MECW implementation
  • `token-conservation` - Token reduction strategies

Implementation

python3 ${CLAUDE_PLUGIN_ROOT}/scripts/growth_analyzer.py "${1:-.}"
Read more
@athola
Ships withclaude-night-market

A plugin marketplace for Claude Code. Install only the plugins you need to run git workflows, code review, spec-driven development, and autonomous agents from inside your Claude Code session.

343200 skills60 agents1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
343
Star history of athola/claude-night-market on GitHub, a chart by star-history.com

Other commands on claude-night-market.

More commands from other plugins.

build
Auto-invoked

build

Command

Implement tasks incrementally — build, test, verify, commit. Add "auto" to run the whole plan in one approved pass.

@addyosmani@addyosmaniInstall Command