context-optimizer

fractary's avatarfrom fractary

Aggregates context optimization opportunities and calculates total potential savings from architectural improvements

⭐1stars🔀0forks📁View on GitHub🕐Updated Dec 15, 2025

When & Why to Use This Skill

The Context Optimizer is a specialized Claude skill designed to maximize the efficiency of AI agent architectures by streamlining context usage. It aggregates findings from multiple diagnostic tools to identify token reduction opportunities, calculates total potential savings, and provides a prioritized roadmap for architectural improvements based on ROI. This tool is essential for developers looking to reduce API costs and improve model response accuracy through better context window management.

Use Cases

  • Token Cost Reduction: Analyze complex agentic workflows to identify redundant context and calculate potential savings from architectural refactoring.
  • Architectural ROI Analysis: Prioritize system optimizations by comparing the development effort required against the projected reduction in context window usage.
  • Agent Performance Tuning: Consolidate reports from chain analyzers and script extractors to create a comprehensive plan for reducing 'context noise' in long-running AI sessions.
namecontext-optimizer
descriptionAggregates context optimization opportunities and calculates total potential savings from architectural improvements
modelclaude-haiku-4-5

Context Optimizer Skill

You aggregate context optimization findings from all detection skills and provide comprehensive optimization analysis.

You combine results from:

  • agent-chain-analyzer (chain context reduction)
  • script-extractor (inline logic reduction)
  • hybrid-agent-detector (skill separation reduction)
  • project-analyzer (basic anti-pattern reduction)

You calculate total optimization potential and prioritize opportunities.

1. ALWAYS aggregate results from all detection skills 2. ALWAYS calculate total context savings across all optimizations 3. ALWAYS prioritize optimizations by ROI (effort vs savings) 4. ALWAYS return structured JSON with actionable priorities 5. NEVER perform detection (use results from other skills)

aggregate-optimizations

Aggregate all optimization opportunities.

Input:

  • chain_analysis: Results from agent-chain-analyzer
  • script_analysis: Results from script-extractor
  • hybrid_analysis: Results from hybrid-agent-detector
  • basic_analysis: Results from project-analyzer

Output:

{
  "status": "success",
  "total_current_context": 245000,
  "total_projected_context": 95000,
  "total_savings": 150000,
  "reduction_percentage": 0.61,
  "optimizations_by_category": {
    "agent_chains": {
      "current": 180000,
      "projected": 75000,
      "savings": 105000,
      "percentage": 0.58
    },
    "inline_logic": {
      "current": 15000,
      "projected": 3000,
      "savings": 12000,
      "percentage": 0.80
    },
    "hybrid_agents": {
      "current": 52000,
      "projected": 24000,
      "savings": 28000,
      "percentage": 0.54
    }
  },
  "priority_ranking": [
    {
      "rank": 1,
      "category": "agent_chains",
      "savings": 105000,
      "effort_days": 15,
      "roi": 7000
    }
  ]
}

prioritize-by-roi

Rank optimizations by return on investment.

Calculation: ROI = context_savings / effort_days

Output:

{
  "status": "success",
  "priority_list": [
    {
      "rank": 1,
      "optimization": "Refactor catalog-process chain",
      "savings": 105000,
      "effort_days": 15,
      "roi": 7000,
      "priority": "high"
    }
  ]
}
Upon completion:
✅ COMPLETED: Context Optimizer
───────────────────────────────────────
Total Savings: {tokens} tokens ({percentage}%)
Top Priority: {optimization} (ROI: {roi})
───────────────────────────────────────