Code quality analysis

From xD4O/praxis · View interactive version

Code quality analysis is an AI agent skill from the GitHub repository xD4O/praxis. MANDATORY code review protocol. You MUST invoke this skill when writing significant code (not one-liners), reviewing PRs or diffs, refactoring modules, or when code quality is requested. Runs 15 structural checks across readability, structure, safety, purity, and design. Complements TDD — tests veri

How to use this skill

Skill file

Code Quality Analysis Protocol

EXTREMELY_IMPORTANT: This is a MANDATORY protocol, not a suggestion. Follow every step.

Do not skip steps. Do not combine steps. Do not summarize. Work through each gate in order.

Tests verify that code WORKS. This protocol verifies that code is WELL-DESIGNED.

Run these checks on any significant code you write or review.

THE 15 CHECKS

Work through each. Mark PASS, FAIL, or N/A. Do not skip any applicable check.

Readability

1. NAMING — Does every variable, function, and class name reveal its intent?

2. FUNCTION SIZE — Does every function do exactly one thing?

Extract methods. (A long but irreducible unit — e.g. a flat dispatch table — can pass.)

3. NESTING DEPTH — Is anything nested deeper than 2 levels?

Flatten with guard clauses. Return early for invalid cases.

Structure

4. SINGLE RESPONSIBILITY — Does each module/class have exactly one reason to change?

5. COUPLING — Can you change module A without touching module B?

another object's internals (Law of Demeter).

6. COHESION — Is everything inside this module related to the same concern?

Safety

7. FAIL FAST — Do errors surface immediately with clear messages?

8. IDEMPOTENCY — What happens if this operation runs twice?

9. INPUT VALIDATION — Are all inputs validated at the boundary?

Purity

10. COMMAND-QUERY SEPARATION — Does every function either return data OR change state?

11. IMMUTABILITY — Is data mutated, or are new copies created?

under them. Return new objects, unless the function's documented contract is in-place

mutation for a measured hotspot.

12. SURPRISE CHECK — Would a reader be surprised by ANY behavior?

Design

13. COMPOSITION — Is inheritance used where composition would work?

implementation — a change anywhere ripples everywhere. Refactor to composition.

14. ORTHOGONALITY — If you change feature X, how many other files change?

15. SIMPLICITY — Is this the simplest approach that solves the problem?

Output format

After completing all checks:

CODE QUALITY ANALYSIS
├── Readability:  Naming [P/F] | Size [P/F] | Nesting [P/F]
├── Structure:    SRP [P/F] | Coupling [P/F] | Cohesion [P/F]
├── Safety:       FailFast [P/F] | Idempotent [P/F] | Validation [P/F]
├── Purity:       CQS [P/F] | Immutable [P/F] | NoSurprise [P/F]
├── Design:       Composition [P/F] | Orthogonal [P/F] | Simple [P/F]
├── Score:        [X/15 passed]
└── Action items: [list any FAIL items with specific fix]

<HARD-GATE>

Code with 3+ FAIL items in the Safety or Structure categories should not

ship without remediation. Flag these as blocking issues in code review.

Rationalizations this skill catches:

</HARD-GATE>

Superpowers handoff

After the 15-check analysis is complete:

If Superpowers is installed → pass the quality report to Skill(superpowers:requesting-code-review)

or the active Superpowers review workflow. FAIL items become required fixes in the review.

Safety and Structure FAILs are blocking items that Superpowers' code reviewer should enforce.

If Superpowers is NOT installed → present the report to the user with specific fix

recommendations for each FAIL item.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.