No slash command · from code-foundations
Audits and restructures control flow using Code Complete rules: deep nesting, cyclomatic complexity, guard clauses, boolean simplification, loop design, and index naming. For statement-level flow inside routines.
Ships in code-foundations. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
| Threshold | Value | Source |
|---|---|---|
| Max nesting depth | 3 levels | Yourdon 1986a |
| McCabe complexity | >10 decision points → redesign | McCabe 1976 |
| Else-clause consideration | 50–80% of ifs need an else | Elshoff 1976 |
| Loop-with-exit comprehension | 25% better than top/bottom test | Soloway 1983 |
| Mental entity limit | 5–9 items | Miller 1956 |
The full audit checklists (conditionals, structure, loops, tables): Read(${CLAUDE_SKILL_DIR}/checklists/conditionals-and-structure.md) and Read(${CLAUDE_SKILL_DIR}/checklists/loops-and-advanced.md).
Principles:
true/false, not 0/1, for booleans.for/foreach when the iteration count is known; while when not.if, the error case in else — except guard clauses, which invert this intentionally.Guard clauses are an exception pattern: error/invalid cases exit early at the top so the nominal path flows without nesting. Use them at function entry; use "nominal in if" for conditionals within the body.
// BEFORE: arrow-shaped (4 levels), nominal case buried
if (file.validName()) {
if (file.open()) {
if (encryptionKey.valid()) {
if (file.decrypt(encryptionKey)) { /* lots of code */ }
}
}
}
// AFTER: guard clauses flatten it
if (!file.validName()) return;
if (!file.open()) return;
if (!encryptionKey.valid()) return;
if (!file.decrypt(encryptionKey)) return;
// lots of code (nominal case at top level)
bool printerCanPrint = printerReady && !printerBusy &&
paperAvailable && paperLevel > MIN_PAPER;
bool documentCanBePrinted = documentValid && !documentEmpty &&
documentSize < MAX_SIZE;
if (inputStatus == SUCCESS && printerCanPrint && documentCanBePrinted) { print(); }
// BEFORE: transaction[j][i][k] — is this right? who knows
// AFTER: self-documenting and verifiable
for (int payCodeIdx = 0; payCodeIdx < numPayCodes; payCodeIdx++)
for (int month = 0; month < 12; month++)
for (int divisionIdx = 0; divisionIdx < numDivisions; divisionIdx++)
sum += transaction[month][payCodeIdx][divisionIdx];
Putting a test into a well-named function improves readability, and that alone justifies it — even for a single use [p.433].
bool isProcessableLetter(char c) {
bool isLetter = (('a' <= c) && (c <= 'z')) || (('A' <= c) && (c <= 'Z'));
bool isExcluded = (c == 'X') || (c == 'x');
return isLetter && !isExcluded;
}
if (isProcessableLetter(inputChar)) { processLetter(inputChar); }
if (MIN_VALUE <= count && count <= MAX_VALUE) // in-range: variable between bounds
if (count < MIN_VALUE || MAX_VALUE < count) // out-of-range: variable on the outside
while (!done) // boolean: compare implicitly
while (balance != 0) // numeric: compare explicitly
while (*charPtr != '\0') // character: compare to the terminator
while (bufferPtr != NULL) // pointer: compare to NULL
// AFTER: while(true) + break eliminates the duplicated read at top and bottom
while (true) {
GetNextRating(&ratingIncrement);
rating += ratingIncrement;
if (!((score < targetScore) && (ratingIncrement != 0))) break;
GetNextScore(&scoreIncrement);
score += scoreIncrement;
}
for/foreach, else while.do-while)/MIDDLE, else test at BEGINNING.foreach (eliminates housekeeping arithmetic errors).while(true) + break).#5 and #6 are context-dependent, not ranked: tables can be simpler than polymorphism. "The fact that a design uses inheritance and polymorphism doesn't make it a good design" [p.423].
Consider a table instead of branching logic when: writing the 4th+ branch in an if-else chain for the same classification; creating a subclass just to change a data value; rules change often without wanting code changes; or the same lookup is duplicated in several places.
Access method: direct (data keys straight into the table, e.g. month 1–12) → indexed (large/sparse keyspace, few entries) → stair-step (entries valid for ranges, e.g. grade thresholds).
Count: start at 1, add 1 per if/while/for/and/or and per case branch.
| Count | Verdict |
|---|---|
| 0–5 | Probably fine |
| 6–10 | Start simplifying |
| 10–20 | Strong justification needed; review for extraction |
| 20+ | Mandatory refactor |
A routine in the 10–20 range is acceptable only when all of: it's a flat dispatch (switch/case, no nesting within cases); each case is ≤3 lines (ideally a single call); cases are exhaustive and unlikely to grow unboundedly; and cognitive complexity is low. Inherent-complexity or "just a big if-else chain" do not qualify — extract instead.
The same flatten-the-structure principle applies beyond Code Complete's era: async/await replaces callback nesting, and exhaustiveness-checked pattern matching is the valid high-McCabe flat dispatch.
What SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (ryanthedev/code-foundations) — no native marketplace selected
npx claudepluginhub p/ryanthedev-code-foundations20 skills in this plugin
/aposd-designing-deep-modulesGuides module and API design using APOSD principles: generates multiple design alternatives, compares them on information hiding and interface depth, and produces a documented design decision. For creating new module/API design; not for assessing existing designs (use aposd-reviewing-module-design) or routine-level design (use cc-routine-and-class-design)./aposd-reviewing-module-designAssesses existing module and interface design for complexity symptoms: information leakage, shallow interfaces, pass-through layers, and unknown unknowns. Produces a structured assessment — not transformations (use aposd-simplifying-complexity to edit) and not new-design generation (use aposd-designing-deep-modules)./aposd-simplifying-complexityTransforms complex code by applying APOSD's pull-complexity-downward principle: resolves error hierarchies, collapses configuration, and moves caller-side logic into modules. Produces edited code; not for assessment-only review (use aposd-reviewing-module-design) or designing new modules from scratch (use aposd-designing-deep-modules)./aposd-verifying-correctnessVerifies implementation completeness across functional correctness, error handling, concurrency, and security dimensions using APOSD's post-implementation checklist. Run after a coding task is nominally complete, not during active bug investigation (use cc-debugging)./ca-architecture-boundariesApplies Clean Architecture's dependency-direction and SRP-by-actor rules to system-level boundary design: separates business logic from infrastructure, identifies actor-coupling risks, and enforces inward-pointing dependency arrows. For system scope (multiple components, layers, or services), not routine or module scope (use cc-routine-and-class-design)./cc-debuggingApplies Code Complete's scientific debugging method: STABILIZE → LOCATE → HYPOTHESIZE → EXPERIMENT → FIX → TEST → SEARCH. For active bug investigation, not QA process design or test coverage planning (use cc-quality-practices).Other plugins' skills for the same job