agentleFS
jggomezjggomez/expert-ai-developer-skills/skills/code-critic/SKILL.md

code-critic

Skill30 starsChanged 4 days agoApache-2.0View on GitHub

Independent code review inspecting cyclomatic complexity, DRY, SOLID, anti-patterns, maintainability, and interface robustness.

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 9 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    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
  1. Distinctive:

    Single Responsibility (SRP): Ensure each class or module has one, and only one, reason to change.

    line 65
  2. Distinctive:

    Open/Closed (OCP): Verify extensibility via polymorphism, strategy patterns, or dependency injection without modifying existing core logic.

    line 66
  3. Distinctive:

    Liskov Substitution (LSP): Verify subtypes can substitute for their base types without breaking invariants.

    line 67
  4. Distinctive:

    Interface Segregation (ISP): Ensure clients are not forced to depend on methods they do not use.

    line 68
  5. Distinctive:

    Dependency Inversion (DIP): Verify high-level modules depend on abstractions, not concrete implementations.

    line 69
  6. Distinctive:

    Verify function length stays within clean bounds (ideally $\le 30-40$ lines).

    line 76
  7. Distinctive:

    Ensure variable, parameter, and function names are written in unambiguous English.

    line 77
  8. Distinctive:

    Verify that code is self-documenting.

    line 78
  9. Distinctive:

    Verify boundaries: sanitize external inputs, validate preconditions, and handle edge states.

    line 82

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Code Critic & Independent Architectural Review Skill

Overview

This skill provides an uncompromising, independent architectural code review discipline. Operating as an objective Senior Code Critic, it systematically inspects source code for excessive cyclomatic complexity, code duplication (DRY violations), SOLID principles non-conformance, object-oriented and architectural anti-patterns, maintainability friction, and interface brittleness.

Unlike conventional linters or superficial PR approvals, this skill conducts deep structural evaluations, calculates an empirical quality score, and publishes a formal review deliverable to docs/<feature-name>/critic-review.md.


When to Use

Trigger Scenarios

  • Conducting independent code reviews on completed feature implementations or refactorings before merge.
  • Evaluating complex modules exhibiting high churn, fragile test setups, or recurring regressions.
  • Auditing adherence to SOLID principles, DRY standards, and Clean Architecture layer boundaries.
  • Inspecting cyclomatic complexity and cognitive depth across modified files.
  • Producing a formal architectural critique deliverable (docs/<feature-name>/critic-review.md) during State 3/4 verification workflows.

When NOT to Use

  • Authoring production code or fixing defects: Route implementation tasks to code-implementer.
  • Executing automated unit or E2E tests: Route test runners to qa-tester or testing-expert.
  • Black-box visual/browser flow inspection: Route browser verification to blackbox-tester.
  • Adversarial stress and fuzzing probing: Route fuzzing and fault injection to adversarial-challenger.
  • Static security scanning and secret leak detection: Route vulnerability scanning to compliance-verifier and security-audit.

Process

The code critique process evaluates code across six structural dimensions and produces the standard artifact at docs/<feature-name>/critic-review.md.

flowchart TD
    START["Inspect Git Diff / Modified Files"] --> D1["1. Cyclomatic Complexity & Nesting"]
    D1 --> D2["2. DRY & Duplication Elimination"]
    D2 --> D3["3. SOLID Principles Adherence"]
    D3 --> D4["4. Anti-Patterns & Code Smells"]
    D4 --> D5["5. Maintainability & Cognitive Load"]
    D5 --> D6["6. Interface Robustness & Error Paths"]
    D6 --> RUBRIC["Calculate Quality Score (0 - 100%)"]
    RUBRIC --> VERDICT{"Evaluate Thresholds"}
    VERDICT -->|">=85% (No Dim <3)"| PASS["PASSED: Author docs/<feature-name>/critic-review.md"]
    VERDICT -->|"70-84% (No Dim <2)"| COND["CONDITIONAL PASS: Actionable tech-debt log"]
    VERDICT -->|"<70% or Critical Blocker"| REJECT["REJECTED: Detailed blocker remediation plan"]

Phase 1: Dimension Inspection

  1. Cyclomatic Complexity & Control Flow:
    • Assess McCabe cyclomatic complexity: Target $CC \le 10$ per function/method.
    • Enforce nesting depth $\le 3$ (loops, branches, and callback depth).
    • Identify convoluted boolean conditions, deeply nested if/else ladders, and arrow-shaped code.
  2. DRY (Don't Repeat Yourself) & Redundancy:
    • Detect duplicate algorithms, validation blocks, and copied utility functions.
    • Differentiate between incidental similarity and true domain duplication.
    • Flag parallel inheritance hierarchies and repetitive boilerplate.
  3. SOLID Principles Adherence:
    • Single Responsibility (SRP): Ensure each class or module has one, and only one, reason to change.
    • Open/Closed (OCP): Verify extensibility via polymorphism, strategy patterns, or dependency injection without modifying existing core logic.
    • Liskov Substitution (LSP): Verify subtypes can substitute for their base types without breaking invariants.
    • Interface Segregation (ISP): Ensure clients are not forced to depend on methods they do not use.
    • Dependency Inversion (DIP): Verify high-level modules depend on abstractions, not concrete implementations.
  4. Architectural Anti-Patterns & Code Smells:
    • Detect God Classes, Feature Envy, Primitive Obsession, Shotgun Surgery, Inappropriate Intimacy, and Leaky Abstractions.
    • Identify dead code, speculative generality (YAGNI violations), and circular dependencies.
  5. Maintainability & Cognitive Load:
    • Verify function length stays within clean bounds (ideally $\le 30-40$ lines).
    • Ensure variable, parameter, and function names are written in unambiguous English.
    • Verify that code is self-documenting; reject comments explaining what instead of why.
  6. Interface Robustness, Error Handling & Type Safety:
    • Enforce explicit type annotations and strict null/undefined checks.
    • Verify boundaries: sanitize external inputs, validate preconditions, and handle edge states.
    • Enforce zero swallowed exceptions (try/except without logging or re-raising).

Phase 2: Scoring Rubric & Thresholds

Each dimension is scored from 1 (unacceptable) to 5 (exemplary). The weighted score is compiled into a 30-point baseline and normalized to a 100% scale.

DimensionWeightMax PointsPassing Standard (>= 4)
1. Cyclomatic Complexity & Control Flow20%5$CC \le 10$, nesting depth $\le 3$, flat control flow
2. DRY & Duplication Elimination15%5Reusable abstractions, zero duplicate validation or business logic
3. SOLID Principles Adherence25%5Clean SRP boundaries, dependency injection, pure interface contracts
4. Architectural Anti-Patterns15%5Zero God classes, no feature envy or leaky abstractions
5. Maintainability & Cognitive Load10%5Concise functions ($\le 30$ lines), clear English naming, high readability
6. Interface Robustness & Error Paths15%5Complete type hints, exhaustive validation, robust error propagation

Scoring Thresholds

  • PASSED ($\ge 85%$, no dimension $< 3$): Implementation is clean, robust, and maintainable. Recommended for immediate release.
  • CONDITIONAL PASS ($70% - 84%$, no dimension $< 2$): Implementation is functionally sound but carries non-critical debt. Non-blocking recommendations recorded.
  • REJECTED ($< 70%$ OR any dimension $= 1$ OR critical blocker present): Unacceptable complexity, critical SOLID breach, or severe fragility. Handoff to code-implementer with concrete line-by-line remediation steps.

Phase 3: Zero-Fluff Deliverable Generation (docs/<feature-name>/critic-review.md <= 50 lines)

Create the target directory docs/<feature-name>/ if not present. Generate a Zero-Fluff review artifact strictly capped at <= 50 lines (<= 20 lines on clean passes) conforming to the Critic Review Template. Omit empty dimension prose sections—output ONLY the compact metadata header, the 6-dimension rubric summary table, and actionable defects (or None. when clean):

# Critic Code Review Report

- **Feature**: `<feature-name>` | **Date**: `YYYY-MM-DD` | **Diff Ref**: `HEAD`
- **Reviewer**: `critic` | **Verdict**: `[PASSED | CONDITIONAL PASS | REJECTED]` | **Score**: `[XX.X]/30 ([XX]%)`

## 1. Quality Scoring Summary
| Dimension | Weight | Score (1-5) | Weighted | Key Metric / Threshold |
| :--- | :---: | :---: | :---: | :--- |
| **1. Cyclomatic Complexity** | 20% | `[1-5]` | `[X.X]` | Max `CC <= 10`, nesting `<= 3` |
| **2. DRY & Duplication** | 15% | `[1-5]` | `[X.X]` | Zero duplicated domain/validation logic |
| **3. SOLID Principles** | 25% | `[1-5]` | `[X.X]` | SRP, OCP, LSP, ISP, DIP invariants |
| **4. Anti-Patterns & Smells** | 15% | `[1-5]` | `[X.X]` | Zero God classes, Feature Envy, leaky layers |
| **5. Maintainability** | 10% | `[1-5]` | `[X.X]` | Functions `<= 30-40` LOC, clear English names |
| **6. Interface Robustness** | 15% | `[1-5]` | `[X.X]` | Strict typing, zero swallowed exceptions |
| **Total** | **100%** | — | **`[XX.X]/30`** | `PASSED >= 85%` \| `CONDITIONAL 70-84%` \| `REJECTED < 70%` |

## 2. Actionable Defects (Write `None.` on clean `PASSED`)
| Priority | Dimension | File & Line | Defect Summary | Required Remediation |
| :---: | :---: | :--- | :--- | :--- |
| `P0` | SOLID / SRP | `path/to/file:L#` | God method handling multi-domain logic | Split into dedicated service classes |

Usage

Invocations & Inspection Techniques

Reviewers inspect code using AST analysis tools, diff inspectors, and complexity metrics:

# Measure cyclomatic complexity with radon (Python)
radon cc src/ -s -a

# Measure maintainability index with radon (Python)
radon mi src/ -s

# Run ESLint complexity and maintainability rules (TypeScript/JavaScript)
npx eslint src/ --rule "complexity: [error, 10]" --rule "max-depth: [error, 3]"

# Dart complexity analysis
dart analyze --fatal-infos

Example Prompts

  • "Perform an independent code critique on the newly implemented authentication flow and produce docs/auth-flow/critic-review.md."
  • "Evaluate the order checkout service against SOLID principles, calculate our cyclomatic complexity score, and provide remediation steps."
  • "Audit this pull request diff for code smells, God methods, and swallowed error blocks."

Host Execution Instructions

  • Claude Code: Invoke as critic subagent; inspect files using Read and Grep; generate docs/<feature-name>/critic-review.md using Write.
  • Antigravity: Launch as the critic subagent; inspect code using view_file and grep_search; calculate scores and write the report to disk.

Red Flags

  • Giving rubber-stamp "LGTM" approvals without inspecting control flow and complexity metrics.
  • Overlooking swallowed exceptions (except: pass or empty catch blocks).
  • Tolerating cyclomatic complexity $> 15$ or nesting depth $> 4$.
  • Writing code changes or modifying production files directly (violates reviewer separation of concerns).
  • Reporting vague subjective critiques without concrete file:line locations and actionable remediations.
  • Producing bloated review prose exceeding the strict <= 50 lines Zero-Fluff cap (<= 20 lines on clean passes).
  • Failing to create the destination directory before saving docs/<feature-name>/critic-review.md.

Verification

  • Ensure all 6 critique dimensions are thoroughly inspected.
  • Ensure cyclomatic complexity ($CC$) and nesting depth are computed and documented.
  • Ensure SOLID violations are categorized with exact file:line references.
  • Ensure the scoring rubric is filled out with a clear verdict (PASSED, CONDITIONAL PASS, or REJECTED).
  • Ensure docs/<feature-name>/critic-review.md adheres strictly to the <= 50 lines Zero-Fluff cap (<= 20 lines when clean, omitting empty prose sections).
  • Ensure non-passing verdicts include a prioritized remediation table for code-implementer.

References

  • Standard Review Deliverable Template: references/critic-review-template.md

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.