complexity-coach

A teaching guide for working out how much time and memory an algorithm uses from its actual code. Big-O is a shorthand for how that cost grows as the input gets larger.

In plain words
What is it for?
Use it for focused practice on time and space complexity, including nested loops, recursive algorithms, and amortized cost, where occasional expensive operations are averaged over many operations.
Why use it?
It helps learners derive complexity from loops, recursion, and repeated work instead of recalling a label for a familiar pattern. It focuses on the reasoning, not on fixing or redesigning the algorithm.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/far-200/think-before-code/complexity-coach
Any agent
npx skills add Far-200/think-before-code --skill complexity-coach
Clone the repo
git clone --depth 1 https://github.com/Far-200/think-before-code

Made for: Claude Code, Codex.

Per session 77 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,020 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00077 $0.01020
Opus 5 $0.00039 $0.00510
Sonnet 5 $0.00015 $0.00204
Haiku 4.5 $0.00008 $0.00102

Measured 2d ago against content hash a9de41520ba9, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

complexity-coach scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/complexity-coach/SKILL.md · 101 lines

How it starts

The opening of the file, as written. The whole thing — 101 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Complexity Coach

Why this exists

dsa-tutor asks about complexity once, as one item among several during verification. That's enough to check the box, but it's not enough to build the skill of derivation — most learners answer with the complexity they've memorized for a pattern name, not one they worked out from the actual code in front of them. This skill exists to drill the derivation itself, either standalone or as a deeper follow-up to that single verification question.

This skill does not evaluate whether the algorithm is correct, and it does not suggest a better approach. If the learner's approach itself is in question, that's dsa-tutor's job. A broad review of existing code — correctness, maintainability, design — is code-review-coach's session; this skill applies when complexity derivation is the question itself, even if it arrived as one lens of such a review.

Circuit breaker

Never state the Big-O for the learner. If they state one first, treat it as a claim to be justified, not a fact to confirm.

Has the learner derived the complexity from the actual structure of
their code or approach — loop bounds, recursion depth, or amortized
cost — rather than recalled it from the pattern's name?

  NO  → ask them to derive it. Don't confirm or correct yet.
  YES → check it against a degenerate input before accepting it.

Protocol

  1. Identify every loop and recursive call, and ask the learner to state its bound in terms of the input size — not "it loops a bit," an actual expression.
  2. For nested structures, ask the learner to derive the total work as a sum over iterations rather than reciting a shape like "nested loop = O(n²)." A nested loop whose inner bound changes each pass is not automatically a different complexity — a loop that runs n + (n-1) + (n-2) + ... + 1 times is still Θ(n²), just arrived at through a sum instead of a flat multiplication. The point isn't to memorize which shapes are which; it's to make the learner actually sum or multiply the bounds instead of guessing from the shape.
  3. For recursion, ask them to write the recurrence relation (T(n) = ...) before reaching for a name. Then ask whether they can solve it by unrolling it a few levels, or whether they recognize a Master Theorem case — don't supply which case applies.
  4. For amortized structures (dynamic arrays, union-find with path compression, a two-pointer scan that never backtracks), ask them to reason about total work across all operations, not the worst single one.
  5. Ask space separately from time. Auxiliary space vs. input space, and whether the call stack from recursion counts (it does).
  6. Stress-test the claim against a degenerate input: does the complexity change for an already-sorted array, all-duplicate values, or an empty input? If the learner hasn't considered this, ask rather than tell.

Read the full file on GitHub · 101 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 101 lines · 77 tokens per session scan A a9de41520ba9

Subscribe to this mod's changes

complexity-coach is a skill published in the GitHub repository Far-200/think-before-code (8 stars, last pushed 17d ago), licensed MIT. It adds 77 tokens to every session and 1,020 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

configure-profile

Create or update the global learner profile. Interviews the learner using the measurement checklist in references/PROFILE-TEMPLATE.md and writes the structured result to profile/PROFILE.md. Use when a new learner sets up Upstack for the first time, or after completing a course to update skills and Dreyfus levels.

ishands/upstack · 64 tokens

create-course

Scaffold a new course directory from the COURSE.md schema. Creates the directory structure, populates COURSE.md with YAML frontmatter and markdown template sections, and creates stub assignment directories. Use for curated courses (core/courses/) or personal courses (custom/courses/) in any domain.

ishands/upstack · 60 tokens

start-course

Initialise a learning session. Checks for an existing journal in progress/ /journal.md, creates one from the template if missing, loads the course definition, and calibrates to the learner's declared context. Use when starting a new course or resuming after a break.

ishands/upstack · 60 tokens

start-learning-path

Enrol in a curated learning path. Discovers available paths, presents project options in plain language, records the learner's choice, initialises the integration journal, and displays the full course roadmap. Run once at the start of the path — not at the start of each course. Distinguishes enrolment (path level…

ishands/upstack · 83 tokens

complete-assignment

Run the reasoning review gate for a completed assignment. Asks 2-3 Reasoning Review Prompts from COURSE.md, verifies genuine understanding, and only marks the assignment complete if the learner demonstrates conceptual grasp. Use when a learner finishes an assignment and is ready for verification.

ishands/upstack · 59 tokens

check-progress

Display current completion state for one or all active courses. Runs collect-progress.js to parse journals and extract completion percentages with git timestamps. Use when the learner asks about their progress or at the start of a session.

ishands/upstack · 45 tokens