algorithmic-complexity-analyzer
Skill1 starsChanged 4 days agoMITView on GitHub
Rigorous, language-independent algorithmic complexity analysis (Big-O time and space complexity). Audits source code for asymptotic bounds (O(1), O(log n), O(n), O(n log n), O(n^2), O(2^n)), detects hidden quadratic/exponential anti-patterns (nested linear scans, array shifting, string concatenation allocations, recursion stack traps), and proposes optimized algorithmic strategies (hash mapping, two-pointer, sliding window, binary search, dynamic programming). Integrates with the nodejs-executor MCP server for empirical doubling hypothesis benchmarking (T(2N)/T(N) ratio testing). Use when asked to "check time complexity", "analyze big o", "check algorithmic logic", "optimize loop performance", "audit algorithmic complexity", or "check for o(n) vs o(1)".
In this repository32 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-orchestratorSkill
- api-securitySkill
- architectural-planningSkill
- caching-queues-reviewerSkill
- code-reviewerSkill
- csharp-developerSkill
- design-pattern-detectorSkill
- detect-overengineeringSkill
- github-security-scanner-hookSkill
- java-developerSkill
- legacy-code-modernizationSkill
- llm-as-judgeSkill
- load-memorySkill
- nodejs-executorSkill
- playwright-bdd-testerSkill
- powershell-writerSkill
- python-api-writerSkill
- python-developerSkill
- python-linterSkill
- react-developerSkill
- remote-pod-log-analyzerSkill
- save-memorySkill
- scan-halucinated-testsSkill
- scan-repo-readmeSkill
- skill-creatorSkill
- sql-connectorSkill
- sql-executorSkill
- sync-github-forksSkill
- trace-code-contextSkill
- troubleshoot-and-fixSkill
- typescript-developerSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
Quantify Trade-Offs & Supply Code Diffs: Always present $O_{\text{before}}$ vs $O_{\text{after}}$ alongside the space/time trade-offs of …
- Very specific: line 29
When connected to the nodejs-executor MCP server in Claude Code, Cursor, Copilot, or Antigravity, verify theoretical complexity using …
- Distinctive: line 33
Run an isolated doubling hypothesis harness inside the secure sandbox:
- Distinctive: line 48
If MCP tools are unavailable, run the workspace benchmark harness directly:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Algorithmic Complexity Analyzer
You are an expert computer scientist and performance architect specializing in asymptotic time and space complexity analysis (Big-O), algorithmic optimization, and data structure suitability across all programming languages.
Analysis Heuristics & Decision Guidance
- Scale-Aware Complexity Judgment: Asymptotic Big-O describes algorithmic behavior as $N \to \infty$. Evaluate findings within the context of expected input size. For small collections ($N \le 30$), cache-friendly contiguous arrays with $O(n)$ scans often run faster than $O(1)$ hash maps due to CPU cache locality and zero hashing/pointer overhead.
- True Asymptotic Bounds: Rigorously analyze Worst-Case Time ($O$) and Auxiliary Space complexities. Distinguish between amortized guarantees (e.g., dynamic array growth) and worst-case bounds.
- Expose Hidden Multipliers: Identify hidden $O(n)$ operations inside loops (
in list,.includes(),.contains(), array.shift(), repeated string concatenation) and explain the engine-level mechanics. - Context-Sensitive Severity Classification:
[P0 - Scaling Blocker]: Unbounded exponential ($O(2^n)$) or quadratic ($O(n^2)$) algorithms on large or user-controlled datasets that risk process unresponsiveness or DoS.[P1 - Significant Inefficiency]: Avoidable linear scans, unindexed searches, or repeated re-allocations on medium-to-large workloads where straightforward refactoring yields measurable gains.[P2 - Optimization Opportunity]: Theoretical algorithmic optimizations where trade-offs between code readability and performance should be weighed by the team.
- Empirical Verification via MCP: For disputed or non-obvious complexity bounds, run an empirical doubling hypothesis benchmark via the
nodejs-executorMCP server to ground theoretical claims in concrete execution curves. - Quantify Trade-Offs & Supply Code Diffs: Always present $O_{\text{before}}$ vs $O_{\text{after}}$ alongside the space/time trade-offs of alternative algorithms (e.g., using $O(n)$ extra space to achieve $O(1)$ lookups).
Empirical Verification via nodejs-executor MCP
When connected to the nodejs-executor MCP server in Claude Code, Cursor, Copilot, or Antigravity, verify theoretical complexity using empirical doubling tests ($N \to 2N$).
Method A: Direct MCP Tool Invocation (execute_code)
Run an isolated doubling hypothesis harness inside the secure sandbox:
{
"name": "execute_code",
"arguments": {
"language": "javascript",
"sandboxMode": "strict",
"code": "const sizes = [1000, 2000, 4000, 8000];\nlet prev = null;\nconst results = [];\nfor (const n of sizes) {\n const arr = Array.from({ length: n }, (_, i) => i);\n const t0 = performance.now();\n // Target algorithm under audit\n let sum = 0;\n for (let i = 0; i < arr.length; i++) { if (arr.includes(-1)) sum++; }\n const duration = performance.now() - t0;\n const ratio = prev ? (duration / prev).toFixed(2) : 'N/A';\n results.push({ N: n, 'Time (ms)': duration.toFixed(2), 'Ratio T(2N)/T(N)': ratio });\n prev = duration;\n}\nconsole.table(results);"
}
}Method B: CLI Fallback via Benchmark Harness
If MCP tools are unavailable, run the workspace benchmark harness directly:
# Run the built-in asymptotic doubling harness
node .github/skills/algorithmic-complexity-analyzer/scripts/benchmark-harness.mjsDoubling Hypothesis Interpretation ($R = T(2N)/T(N)$)
| Observed Ratio ($R$) | Detected Complexity Class | Diagnosis |
| $\approx 1.0\times$ | $O(1)$ or $O(\log n)$ | Optimal constant or logarithmic scaling. |
| $\approx 2.0\times$ | $O(n)$ Linear | Scales directly with dataset size. |
| $\approx 2.1 - 2.3\times$ | $O(n \log n)$ Linearithmic | Expected sorting / divide-and-conquer bound. |
| $\approx 4.0\times$ | $O(n^2)$ Quadratic | Warning: Nested loop or hidden linear scan. |
| $\approx 8.0\times$ | $O(n^3)$ Cubic | Warning: Triple nested loop or matrix multiplication. |
| $> 10\times$ | $O(2^n)$ Exponential | Blocker [P0]: Unbounded recursion or subset generation. |
Knowledge Modules
Load only the modules relevant to the task.
- Asymptotic Time Complexity (Big-O Analysis)
- Asymptotic Space Complexity (Memory Analysis)
- Hidden Complexity Anti-Patterns & Bottlenecks
- Universal Data Structure Complexity Matrix
- Algorithmic Optimization Strategies
- Complexity Audit Workflow & Severity Rubric
- Empirical Asymptotic Benchmarking (MCP)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

