algorithm-pseudocode-design
Skill3 starsChanged 38 days agoApache-2.0View on GitHub
Use when an algorithm is non-trivial enough that getting the logic right matters more than the syntax — concurrency-sensitive code, a non-obvious data-structure choice, or anything where a subtle off-by-one or complexity mistake is expensive to find after implementation. Write the algorithm in language-agnostic pseudocode with an explicit complexity analysis before writing real code. Skip for straightforward CRUD or glue code where the implementation is a direct restatement of the requirement — pseudocode would just be the code with different syntax.
In this repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- brainstormingSkill
- openapi-documentationSkill
- pmSkill
- requirements-specificationSkill
- system-architecture-designSkill
- systematic-debuggingSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 26
Keep it language-agnostic — no language-specific syntax, so the logic reads the same regardless of what it'll be implemented in:
- Distinctive: line 103
When a pattern (Strategy, Observer, etc.) clarifies the structure, sketch the interface and key methods in pseudocode before implementation …
≈ “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
Algorithm & Pseudocode Design
Design the algorithm before committing to a language's syntax. Pseudocode forces you to separate "what is the logic" from "how does this language express it" — bugs found at this stage are far cheaper than bugs found after a full implementation.
When to use
- The algorithm is non-trivial: non-obvious data structure choice, tricky control flow, concurrency, or a correctness property that's easy to get subtly wrong (rate limiting, cache eviction, ranking/scoring).
- Complexity matters and hasn't been thought through yet — "this might be O(n²) on the hot path" is worth catching on paper.
- Skip for code that's a direct, obvious translation of the requirement (simple CRUD, straightforward glue/plumbing) — pseudocode adds no value there.
Structure and syntax
Keep it language-agnostic — no language-specific syntax, so the logic reads the same regardless of what it'll be implemented in:
ALGORITHM: AuthenticateUser
INPUT: email (string), password (string)
OUTPUT: user (User object) or error
BEGIN
IF email is empty OR password is empty THEN
RETURN error("Invalid credentials")
END IF
user ← Database.findUserByEmail(email)
IF user is null THEN
RETURN error("User not found")
END IF
isValid ← PasswordHasher.verify(password, user.passwordHash)
IF NOT isValid THEN
SecurityLog.logFailedLogin(email)
RETURN error("Invalid credentials")
END IF
session ← CreateUserSession(user)
RETURN {user: user, session: session}
ENDData structure selection
Name the structure, its complexity per operation, and why it was chosen over the alternatives — not just what it is:
UserCache:
Type: LRU cache with TTL
Purpose: reduce DB queries for active users
Operations: get O(1), set O(1), evict O(1)
PermissionTree:
Type: trie (prefix tree)
Purpose: efficient hierarchical permission checks
Operations: hasPermission(path) O(m), m = path lengthAlgorithm patterns worth writing out explicitly
Patterns where the naive implementation is subtly wrong are worth a full pseudocode pass — e.g. a token-bucket rate limiter (refill math has to account for elapsed time correctly, not just decrement a counter), or a scored-ranking search (weighting, recency boost, tie-breaking all need to be decided before code, not discovered by trial and error in review).
Complexity analysis
For every algorithm designed this way, state time and space complexity per step, then the total — and call out the dominant term:
Time Complexity:
Query preprocessing: O(m) m = query length
Index lookup: O(k log n) k = token count
Scoring: O(p) p = candidate count
Sorting: O(p log p)
Total: O(p log p), dominated by sorting
Optimization notes:
- Use an inverted index for O(1) token lookup
- Consider approximate ranking above ~10k candidatesSkipping this step is how an algorithm that's fine at test scale becomes a production incident at real scale.
Design patterns in pseudocode
When a pattern (Strategy, Observer, etc.) clarifies the structure, sketch the interface and key methods in pseudocode before implementation — it surfaces interface mismatches early, when they're a five-minute fix instead of a refactor.
Best practices
- Language-agnostic — no language-specific syntax; the logic should read the same in any implementation language.
- Clear logic over cleverness — focus on algorithm flow, not implementation tricks.
- Handle edge cases in the pseudocode itself — null inputs, empty collections, concurrent access — not as an afterthought during coding.
- Always state complexity — time and space, for every non-trivial algorithm.
- Meaningful names — variable names should explain purpose even without types.
- Break complex algorithms into subroutines — a 100-line BEGIN/END block is as hard to review as a 100-line function.
Handoff
Once the algorithm and its complexity are pinned down, implement it
following superpowers:test-driven-development — write the failing test
from the pseudocode's stated behavior first, then implement.
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.

