Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
pproenca avatar

Algorithmic Complexity Review

  • 83 installs
  • 191 repo stars
  • Updated July 24, 2026
  • pproenca/dot-skills

algorithmic-complexity-review is a Claude Code skill for ai & agent building.

About

algorithmic-complexity-review is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.

  • algorithmic-complexity-review
  • AI & Agent Building
  • AI-coding skill

Algorithmic Complexity Review by the numbers

  • 83 all-time installs (skills.sh)
  • +6 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #5,111 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/pproenca/dot-skills --skill algorithmic-complexity-review

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs83
repo stars191
Last updatedJuly 24, 2026
Repositorypproenca/dot-skills

How do I helps with ai & agent building tasks during AI-assisted development.?

Helps with ai & agent building tasks during AI-assisted development.

Who is it for?

Best when you're working on ai & agent building and need structured help with algorithmic complexity review.

Skip if: Teams with no ai & agent building needs, or anyone wanting a generic chat assistant without this specific workflow.

When should I use this skill?

When you need to helps with ai & agent building tasks during AI-assisted development., or when algorithmic-complexity-review is a claude code skill for ai & agent building.

What you get

Structured output aligned to algorithmic-complexity-review: algorithmic-complexity-review, AI & Agent Building.

Files

SKILL.mdMarkdownGitHub ↗

dot-skills Algorithmic Complexity (Big-O) Best Practices

Find, classify, and fix algorithmic complexity (Big-O) problems in code — language-agnostic. The 39 rules across 8 categories cover the patterns responsible for the vast majority of accidental quadratic, exponential, and N+1 blowups in production code: nested iteration, loop-invariant I/O, data-structure mismatch, recursion explosions, redundant computation, collection-building anti-patterns, search/sort selection, and space traps.

When to Apply

Use this skill when:

  • Reviewing a pull request or function for performance regressions
  • Asked "why is this slow?" or "can we make this faster?"
  • Refactoring a hot path or a function that handles user-scaled input
  • Reading code that contains: nested loops, .includes/.find/x in list inside iteration, ORM access in a loop, recursion without memoization, string/array building via += or spread, file/database I/O inside iteration
  • Reviewing code that processes lists, trees, or streams whose size will grow

Workflow: Find, Classify, Fix

The skill is structured for a three-step workflow on any code under review:

1. Find — Scan for the Suspicion Patterns

Look for these structural signals first (highest hit rate):

SignalLikely CategoryFirst Rule to Check
Two nested for loopsnested-nested-explicit-quadratic-loops
.includes / .find / x in list inside a loopnested-nested-includes-in-loop
ORM access inside a loop (for o in orders: o.customer.x)io-io-n-plus-one-query
await fetch in for-ofio-io-sequential-await-in-loop
array.find to "join" two arraysds-ds-hashmap-for-keyed-access
Recursive function with overlapping argumentsrec-rec-memoize-overlapping-subproblems
s = s + part or [...acc, x] in a loopbuild-build-avoid-quadratic-string-concat, build-avoid-spread-in-reducer
sorted(...) called inside a loopsearch-search-sort-once-outside-loop
readlines() / loading whole filesspace-space-stream-dont-load

2. Classify — Derive the Big-O

Compute complexity from the code structure:

StructureComplexity
Single loop over n items, O(1) bodyO(n)
Two nested loops over n / m itemsO(n*m)
Loop calling an O(n) operation (.includes, .find, x in list)O(n*m), often misread as O(n)
Recursive f(n) = f(n-1) + f(n-2) without memoizationO(2ⁿ)
Recursive f(n) = 2*f(n/2) + O(n)O(n log n)
Recursive f(n) = 2*f(n/2) + O(1)O(n) (full tree traversal)
Recursive f(n) = f(n/2) + O(1)O(log n)
s = s + part in a loopO(n²) (string immutability)
[...acc, x] in a reduceO(n²) (copy-on-spread)
Query/RPC inside loop over n itemsO(n) round trips

When in doubt, ask: "As input doubles, does runtime roughly double (linear), quadruple (quadratic), or do something worse (exponential)?" That's the practical complexity class.

3. Fix — Apply the Pattern From the Matching Rule

Each reference file in references/ is a {category}-{slug}.md containing:

  • WHY the pattern matters (the cascade effect)
  • An Incorrect code example with the cost annotated
  • A Correct example with the minimal diff
  • When NOT to apply the fix (the rule has exceptions)

The minimal diff philosophy is intentional: the goal is for the agent to see exactly how few lines need to change to flip the complexity class.

Rule Categories by Priority

#CategoryPrefixImpactRules
1Nested Iteration Patternsnested-CRITICAL6
2Loop-Invariant I/O and N+1io-CRITICAL5
3Data Structure Mismatchds-HIGH6
4Recursion Complexityrec-HIGH5
5Redundant Computationcompute-MEDIUM-HIGH5
6Collection Buildingbuild-MEDIUM4
7Search & Sort Selectionsearch-MEDIUM4
8Space Complexity Trapsspace-LOW-MEDIUM4

See `references/_sections.md` for the full ordering rationale.

Quick Reference

1. Nested Iteration Patterns (CRITICAL)

  • `nested-explicit-quadratic-loops` — Replace pairwise loops with hash-based single passes
  • `nested-includes-in-loop` — Avoid .includes() / .indexOf() inside a loop
  • `nested-find-in-loop` — Pre-index lookups instead of .find() per iteration
  • `nested-cartesian-comparison` — Group by key instead of cartesian comparison
  • `nested-set-operations-on-arrays` — Use sets for intersection, union, difference
  • `nested-substring-search-in-loop` — Tokenize once instead of re-scanning per pattern

2. Loop-Invariant I/O and N+1 Queries (CRITICAL)

  • `io-n-plus-one-query` — Eliminate N+1 queries by fetching related data in one round trip
  • `io-sequential-await-in-loop` — Run independent async operations in parallel
  • `io-batch-instead-of-per-item` — Use batch endpoints instead of per-item calls
  • `io-file-read-in-loop` — Read or stat files outside tight loops
  • `io-missing-eager-load` — Eager-load ORM relations you will access

3. Data Structure Mismatch (HIGH)

  • `ds-hashmap-for-keyed-access` — Store records keyed in a hashmap, not as parallel arrays
  • `ds-heap-for-top-k` — Use a heap for top-k, not full sort + slice
  • `ds-deque-for-front-operations` — Use a deque for front insertions and removals
  • `ds-counter-for-histograms` — Use Counter / multiset for frequency counting
  • `ds-sorted-structure-for-range-queries` — Use a sorted structure for range queries
  • `ds-trie-for-prefix-search` — Use a trie for prefix search

4. Recursion Complexity (HIGH)

  • `rec-memoize-overlapping-subproblems` — Memoize recursion with overlapping subproblems
  • `rec-tabulate-bottom-up` — Tabulate bottom-up to eliminate recursion overhead
  • `rec-iterative-for-deep-recursion` — Use an explicit stack instead of deep recursion
  • `rec-prune-with-bounds` — Prune recursive search with bounds and constraints
  • `rec-share-memo-across-top-level-calls` — Share memoization across top-level calls

5. Redundant Computation (MEDIUM-HIGH)

  • `compute-hoist-loop-invariants` — Hoist loop-invariant computation outside the loop
  • `compute-precompile-regex` — Pre-compile regex patterns
  • `compute-cache-expensive-pure-results` — Cache expensive pure-function results
  • `compute-cache-property-lookup` — Cache repeated property lookups in hot loops
  • `compute-defer-or-short-circuit` — Defer or short-circuit work you might not need

6. Collection Building (MEDIUM)

  • `build-avoid-quadratic-string-concat` — Build strings with joins or builders, not repeated concatenation
  • `build-avoid-spread-in-reducer` — Push to a mutable accumulator instead of spreading
  • `build-avoid-immutable-object-spread` — Use a plain object build phase, then freeze
  • `build-presize-when-length-known` — Pre-size collections when the length is known

7. Search & Sort Selection (MEDIUM)

  • `search-binary-search-on-sorted` — Use binary search on sorted data
  • `search-sort-once-outside-loop` — Sort once outside the loop, not on every iteration
  • `search-quickselect-not-full-sort` — Use quickselect for the k-th element, not full sort
  • `search-build-index-once-amortize` — Build the index once when queries dominate

8. Space Complexity Traps (LOW-MEDIUM)

  • `space-stream-dont-load` — Stream large inputs instead of loading them whole
  • `space-generators-over-intermediate-lists` — Pipe through generators instead of materializing intermediate lists
  • `space-shallow-not-deep-copy` — Use shallow copies (or no copy) instead of deep clones
  • `space-release-retained-references` — Release references that prevent garbage collection

How to Use

1. Start with the Find signal table above to locate the most likely pattern. 2. Open the matching reference file for the WHY and the minimal-diff fix. 3. If you're classifying complexity from scratch, use the Classify table to derive Big-O from code structure. 4. When proposing a fix, quote the rule by file path so reviewers can verify the reasoning. 5. See `references/_sections.md` for category ordering rationale, and `assets/templates/_template.md` when adding new rules.

Reference Files

FileDescription
references/_sections.mdCategory definitions, impact levels, and ordering rationale
assets/templates/_template.mdTemplate for adding new rules
metadata.jsonDiscipline, type, and source references

Related Skills

  • bug-review — Multi-pass PR bug review (this skill is a focused complement for performance issues specifically)
  • A language-specific best-practices skill (React, Python, Go) — covers idioms beyond Big-O; pair with this skill for performance-critical reviews

Related skills

FAQ

What does algorithmic-complexity-review do?

algorithmic-complexity-review is a Claude Code skill for ai & agent building.

When should I use algorithmic-complexity-review?

When you need to helps with ai & agent building tasks during AI-assisted development., or when algorithmic-complexity-review is a claude code skill for ai & agent building.

What are the main capabilities?

algorithmic-complexity-review; AI & Agent Building; AI-coding skill.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.