Agent skill

Complexity Optimizer

by pproenca in pproenca/dot-skills

Analyze a software codebase for algorithmic complexity and performance hotspots, then propose or implement safe optimizations without breaking behavior.

MITAuto-check passedDevelopment

Install Complexity Optimizer

skills CLI
$ npx skills add pproenca/dot-skills --skill complexity-optimizer -a claude-code

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

GitHub CLI
$ gh skill install pproenca/dot-skills complexity-optimizer --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/pproenca/dot-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.experimental/complexity-optimizer .claude/skills/complexity-optimizer && 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
complexity-optimizer
GitHub stars
215
Token cost
~2.2k tokens
SKILL.md length
1,008 words
Files
9 (incl. scripts, references)
Skills in repo
41
Repo updated
First seen
Licence
MIT

At a glance

Analyze a software codebase for algorithmic complexity and performance hotspots, then propose or implement safe optimizations without breaking behavior.

  • Works in 5 steps: Baseline → Rank → Prove behavior → …
  • The user asks to scan many files
  • SKILL.md covers When to Apply, Workflow Overview, Core Rule and Default Behavior, plus 5 more sections
  • Runs Python scripts from its folder; calls python3 and git

What it does

Complexity Optimizer is an agent skill from pproenca/dot-skills. Analyze a software codebase for algorithmic complexity and performance hotspots, then propose or implement safe optimizations without breaking behavior. Use when the user asks 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.

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 10 other files, including scripts and reference files (for example `hooks.json`, `metadata.json` and `references/false-positives.md`).

It sits in Development, covering Code simplification. The repository describes itself as: A collection of AI agent skills following the Agent Skills open format. The licence is MIT.

When your agent uses it

  • The user asks to scan many files
  • Find inefficient loops
  • Nested iteration
  • Costly rendering/recomputation

Example prompts

  • “/complexity-optimizer”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Baseline
  2. Rank
  3. Prove behavior
  4. Optimize (only on explicit request)
  5. Verify

What it can do on your machine

Read from SKILL.md and the folder at commit cf93c57. 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

    Ships 3 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python3
    • git

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

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    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

Complexity Optimizer loads about 2.2k tokens when it runs, and up to ~4.5k if it reads all its reference files. Until then it costs about 119 tokens; SKILL.md has 1,008 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~119
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.5k

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); the scripts in this folder are not scanned.

SKILL.md

The full file from pproenca/dot-skills at commit cf93c57, republished under its MIT licence (© pproenca). 1,008 words, ~2,233 tokens.

Download SKILL.mdSave it as .claude/skills/complexity-optimizer/SKILL.md (or your agent's skills folder). This skill also uses 8 other files; get the full folder from GitHub.
name
complexity-optimizer
description
Analyze a software codebase for algorithmic complexity and performance hotspots, then propose or implement safe optimizations without breaking behavior. Use when the user asks 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

Find algorithmic complexity hotspots in a codebase and produce a structured report. Optionally implement low-risk optimizations after explicit consent.

When to Apply

Use this skill when the user asks to:

  • Analyze, audit, scan, or review a codebase for performance hotspots or algorithmic complexity
  • Find inefficient loops, nested iteration, N+1 queries, sort-in-loop, render-path recomputation
  • Reduce complexity (e.g. O(n^2) → O(n log n) or O(n))
  • "Give me a report" on a codebase's complexity profile

Do not use this skill for:

  • Micro-optimizations on cold code paths
  • Memory tuning (this skill targets time complexity, not allocation profiles)
  • Code style refactoring unrelated to complexity

Workflow Overview

Baseline → Rank → Prove behavior → Optimize (opt-in) → Verify
   ↓           ↓                       ↓
 scanner   prioritize hot          rollback if
 + manual  paths & large I/O       tests regress
StepActionToolRisk
1Establish baseline: detect stack, test command, hot pathsscripts/analyze_complexity.py + manual inspectionread-only
2Rank opportunities by impact, separating algorithmic wins from constant-factor cleanupreasoningread-only
3Locate or add tests covering the function/componentRead + test frameworkread-only
4Apply optimization (ONLY when user explicitly requests)Edit/Writedestructive
5Run tests, lint, type-check, and a benchmark when warranted; report before/after complexityBash test commandsread-only

Core Rule

Optimize only when 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 (see references/report-template.md):

  • 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 and estimated complexity after
  • 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 uses an explicit edit verb: implement, fix, optimize, apply, change, refactor. If the request is analysis-only or a report-only request, do not modify files.

Workflow Detail

1. Baseline
  • Identify language, framework, test command, build command, and performance-sensitive paths.
  • Inspect existing tests before touching code.
  • Run python3 scripts/analyze_complexity.py <repo> for a first-pass hotspot list when scanning a repository.
2. Rank
  • Prioritize hot paths, large-input paths, rendering loops, database/API loops, shared utilities.
  • Separate algorithmic complexity from constant-factor cleanup.
  • 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.
3. Prove behavior
  • Locate or add focused tests for the function/component being changed.
  • Capture edge cases: empty input, duplicates, ordering stability, null/missing values, errors, permissions, pagination, time zones, mutation side effects.
  • If tests are absent and behavior is ambiguous, make the smallest possible refactor or ask for expected behavior before changing semantics.
4. Optimize (only on explicit request)
  • Replace repeated linear lookup with maps/sets when key equality is stable.
  • Replace nested scans with indexing, grouping, two-pointer scans, sweep-line logic, binary search, memoization, batching, or precomputation — only when the data shape supports it.
  • In UI code, reduce unnecessary renders with stable props, memoized derived data, virtualization, debounced work, and moving expensive work out of render paths.
  • In data access code, remove N+1 with bulk fetches, joins, preloading, caching, or batching while preserving authorization and filtering.
5. Verify
  • Run relevant tests and type/lint/build commands.
  • Add a micro-benchmark or measurement when the complexity improvement is non-obvious or performance-critical.
  • Report original complexity, new complexity, files changed, tests run, and any residual risk.
Show full SKILL.md (456 more words)Show less

First-Pass Scanner

bash
python3 scripts/analyze_complexity.py /path/to/repo --format markdown
python3 scripts/analyze_complexity.py /path/to/repo --format json
python3 scripts/analyze_complexity.py /path/to/repo --changed-only --base origin/main

--changed-only restricts the scan to files changed vs --base (default HEAD~1). Use it for PR-focused complexity review.

Language depth:

  • Python (.py) — AST-based analysis. High precision: nested loops, sort/membership in loops, query/I/O in loops, all tracked per-function via the Python ast module.
  • All other supported languages (.js, .ts, .jsx, .tsx, .java, .go, .rb, .php, .cs, .c, .cpp, .swift, .vue, .svelte, .kt, .rs, .dart, .scala) — regex-based pattern matching with indent + function-boundary heuristics. Treat findings as leads; verify by reading the surrounding code before recommending fixes.

If the scanner reports nothing, still inspect known hot paths manually. Rendering churn, database query patterns, and framework lifecycle issues often need repository-specific context the scanner cannot see.

Exit codes: 0 = scanned successfully, 2 = bad input (non-existent path / file instead of directory / git error), 3 = zero files matched, 130 = interrupted.

Triage before reporting: consult references/false-positives.md to dismiss known noise patterns (single-call predicates, Redux selectors, SQL-builder fluent methods, render-derived work on small static arrays) before recommending fixes.

Testing the scanner: python3 scripts/test_analyze_complexity.py runs 13 regression tests that pin the false-positive fixes. Run after modifying the scanner.

Optimization Safety Checklist

Before editing:

  • Confirm the data sizes are large enough for complexity to matter.
  • Confirm the optimization preserves output ordering where callers may rely on it.
  • Confirm object identity, mutability, and reference sharing are not part of public behavior.
  • Confirm caches have a valid invalidation strategy.
  • Confirm deduplication does not collapse distinct records that share a display label.
  • Confirm database batching preserves tenant, permission, soft-delete, pagination, and sorting constraints.

After editing:

  • Run the narrowest relevant test first, then the broader build/lint/typecheck.
  • Compare before/after benchmark numbers when a benchmark exists or was added.
  • Keep the patch localized — avoid formatting churn in unrelated files.

Rollback

If the optimization breaks a test or changes observable behavior:

  1. Revert the changed file(s) immediately:

    bash
    git restore <file>           # restore a single file
    git restore -SW <file>       # restore both index and working tree

    If multiple files were modified: git restore -SW . (only within the affected directory).

  2. Re-run the failing test to confirm restoration.

  3. Report the failure to the user with:

    • The exact test/assertion that failed
    • The semantics that diverged (ordering, mutation, key equality, etc.)
    • Whether to retry with a different transformation, or stay with the original code
  4. Do not re-attempt the same optimization with a small tweak. If a transformation breaks behavior, either the data shape doesn't support it, or there's an unstated invariant — re-read the code before trying again.

References

  • references/optimization-playbook.md — common O(n^2) → O(n log n) / O(n) transformations, framework-specific patterns, and "What Not To Do".
  • references/report-template.md — structure for the final analysis or audit output.
  • references/false-positives.md — catalog of scanner findings that look real but aren't. Consult before recommending fixes.
  • scripts/_sections.md — scanner invocation, flags, exit codes, and limitations.

© pproenca, 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 8 other files (scripts, references) in skills/.experimental/complexity-optimizer of pproenca/dot-skills.

  • SKILL.md
  • hooks.json
  • metadata.json
  • references/false-positives.md
  • references/optimization-playbook.md
  • references/report-template.md
  • scripts/_sections.md
  • scripts/analyze_complexity.py
  • scripts/test_analyze_complexity.py

Open the folder on GitHubat commit cf93c57

Compare with similar skills

Complexity Optimizer 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.

Complexity Optimizer compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Complexity Optimizer this skillpproenca/dot-skills215—~2.2kAutomated safety check: PassMIT
PonytailDavidObando/gsharp5658 repos~1.7kAutomated safety check: PassMIT
Ponytail Reviewkortix-ai/suna20k4 repos~593Automated safety check: PassCustom licence
Ponytail Lazy Developer ModeDietrichGebert/ponytail158k—~871Automated safety check: PassMIT
Code Simplification for ego-litecitrolabs/ego-lite17k—~1.2kAutomated safety check: PassMIT
Refactor Pass for Simplicitystar-history/star-history9.6k1 repos~168Automated safety check: PassMIT

Similar skills

  • Ponytail

    DavidObando/gsharp

    Forces the laziest solution that actually works, simplest, shortest, most minimal.

    565 GitHub starsUsed in 8 repos~1.7k tokens
    DevelopmentAuto-check passed
  • Ponytail Review

    kortix-ai/suna

    Code review focused exclusively on over-engineering. An agent skill from kortix-ai/suna.

    20k GitHub starsUsed in 4 repos~593 tokens
    DevelopmentAuto-check passed
  • Ponytail Lazy Developer Mode

    DietrichGebert/ponytail

    Makes the agent pick the laziest solution that works: skip unneeded work, reuse what exists, prefer the standard library and platform features, and keep diffs small.

    158k GitHub stars~871 tokensUpdated today
    DevelopmentAuto-check passed
  • Finds and implements evidence-backed simplifications in the ego-lite repository, such as dead code, duplicated state and speculative abstractions, without hiding behavior changes.

    17k GitHub stars~1.2k tokensUpdated 15 days ago
    DevelopmentAuto-check passed
  • Refactor Pass for Simplicity

    star-history/star-history

    Perform a refactor pass focused on simplicity after recent changes. Use when the user asks for a refactor/cleanup pass, simplification, or dead-code removal…

    9.6k GitHub starsUsed in 1 repo~168 tokens
    DevelopmentAuto-check passed
  • Over-Engineering Review

    DietrichGebert/ponytail

    Reviews a diff only for unnecessary complexity and lists what to delete or shrink, one numbered line per finding with the location, the cut and its replacement.

    158k GitHub stars~1.3k tokensUpdated today
    DevelopmentAuto-check passed

More from pproenca/dot-skills

All 41 skills in this repo
  • Audio Voice Recovery

    pproenca/dot-skills

    Audio forensics and voice recovery guidelines for CSI-level audio analysis.

    215 GitHub stars~3.3k tokensUpdated 1 mo ago
    Auto-check passed
  • Codemod React Pipeline

    pproenca/dot-skills

    Guided, scripted pipeline for running JSX/TSX/React codemods safely across large legacy codebases.

    215 GitHub stars~1.6k tokensUpdated 1 mo ago
    Auto-check passed
  • Dev Rfc

    pproenca/dot-skills

    Create well-structured RFCs and technical proposals for software projects.

    215 GitHub stars~3.8k tokensUpdated 1 mo ago
    Auto-check passed
  • Dx Harness

    pproenca/dot-skills

    Developer-experience friction auditing and fixing — slow onboarding, repeated manual setup steps, missing bootstrap/reset/seed scripts, undiscoverable conventions.

    215 GitHub stars~1.5k tokensUpdated 1 mo ago
    Auto-check passed
  • Language Spec Author

    pproenca/dot-skills

    Turn a rough idea for a language into a complete, implementable specification — a DSL, query, config/data, template, or protocol language — by interviewing the author dimension by dimension until…

    215 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Python Pep Author

    pproenca/dot-skills

    Drafting Python Enhancement Proposals (PEPs) — proposing a Python language feature, a standard library change, an interoperability standard, or an informational/process document for the Python…

    215 GitHub stars~2.1k tokensUpdated 1 mo ago
    Auto-check passed

Categories

Questions about Complexity Optimizer

What does Complexity Optimizer do?

Analyze a software codebase for algorithmic complexity and performance hotspots, then propose or implement safe optimizations without breaking behavior. Complexity Optimizer is an agent skill from pproenca/dot-skills. Analyze a software codebase for algorithmic complexity and performance hotspots, then propose or implement safe optimizations without breaking behavior.

When should I use Complexity Optimizer?

Complexity Optimizer fits situations like: the user asks to scan many files; find inefficient loops; nested iteration; costly rendering/recomputation.

How do I install Complexity Optimizer in Claude Code?

Run `npx skills add pproenca/dot-skills --skill complexity-optimizer -a claude-code`. Or copy the skill folder (skills/.experimental/complexity-optimizer in pproenca/dot-skills) into .claude/skills/complexity-optimizer in your project. Claude Code loads it when a task matches its description.

How do I install Complexity Optimizer in Codex?

Run `npx skills add pproenca/dot-skills --skill complexity-optimizer -a codex`. Or copy the skill folder (skills/.experimental/complexity-optimizer in pproenca/dot-skills) into .agents/skills/complexity-optimizer in your project. Codex loads it when a task matches its description.

Can I use Complexity Optimizer 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 pproenca/dot-skills --skill complexity-optimizer -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/complexity-optimizer, .gemini/skills/complexity-optimizer, .github/skills/complexity-optimizer and .opencode/skills/complexity-optimizer in your project.

What does Complexity Optimizer need to run?

Going by SKILL.md and its folder, Complexity Optimizer needs Python for the scripts in its folder and the command-line tools its instructions call (python3 and git). Our summary lists: Python 3.

Does Complexity Optimizer access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Complexity Optimizer 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. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Complexity Optimizer use?

Complexity Optimizer 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 Complexity Optimizer use?

About 2.2k tokens (SKILL.md is roughly 8.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2.2k tokens, read only when the agent opens those files.

What are the alternatives to Complexity Optimizer?

Skills that share tags, products or a category with Complexity Optimizer: Ponytail (DavidObando/gsharp, 565 stars), Ponytail Review (kortix-ai/suna, 20k stars), Ponytail Lazy Developer Mode (DietrichGebert/ponytail, 158k stars) and Code Simplification for ego-lite (citrolabs/ego-lite, 17k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Complexity Optimizer?

pproenca (a GitHub user) maintains it in pproenca/dot-skills, which has 215 GitHub stars. The repository holds 41 skills in this directory. The repository was last updated on August 15, 2026.

Source: pproenca/dot-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.