Skills

Complexity Optimizer

Analyze a software codebase for algorithmic complexity and performance hotspots, then...

Install

npx skills add Kappaemme-git/codex-complexity-optimizer --skill complexity-optimizer -g -a claude-code -y
Category
Testing
Updated
6mo ago
License
MIT
Context cost
Lightabout 1,180 tokens
Runs scripts
Yes, review before use

What it does

Analyze a software codebase for algorithmic complexity and performance hotspots, then propose or implement safe optimizations without breaking behavior. Use when Codex is asked to scan many files, find inefficient loops, nested iteration, repeated scans, costly rendering/recomputation, N+1 queries, avoidable O(n^2) or O(n) operations, or reduce complexity such as O(n^2) to O(n log n) / O(n), while preserving tests, APIs, outputs, and maintainability.

Complexity Optimizer

Core Rule

Optimize only when the current behavior is understood and can be preserved. Prefer a small, proven improvement with tests over a broad rewrite with unclear correctness.

Default Behavior

When the user asks to analyze, scan, audit, review, or "give me a report" for a codebase, produce the full complexity report automatically. Do not require the user to specify report fields.

Default report contents:

  • Scope analyzed and detected stack/test commands.
  • Top findings ranked by likely impact.
  • File and line for each finding.
  • Current pattern and why it may be costly.
  • Estimated current complexity.
  • Recommended change.
  • Estimated complexity after the change.
  • Risk level.
  • Tests, benchmarks, or manual checks needed.
  • Clear statement that no files were modified, unless the user explicitly requested implementation.

Only edit files when the user asks to implement, fix, optimize, apply, change, refactor, or otherwise clearly requests code modification. If the user only asks for analysis or a report, do not modify files.

Workflow

  1. Establish the baseline:

    • Identify the language, framework, test command, build command, and performance-sensitive paths.
    • Inspect existing tests before touching code.
    • Run scripts/analyze_complexity.py <repo> for a first-pass hotspot list when scanning a repository.
  2. Rank opportunities:

    • Prioritize code on hot paths, large input paths, rendering loops, database/API loops, and shared utilities.
    • Separate algorithmic complexity from constant-factor cleanup.
    • Do not patch every warning. Treat scanner output as leads, not proof.
    • For report-only requests, inspect enough surrounding code to estimate current and proposed complexity; do not stop at raw scanner output.
Read the whole SKILL.md on GitHub

More in Testing