AH
Ali Hasan
← Back to Agentic AI Architecture
Quality Gatekeeper Code Quality Role: Code Reviewer

elevate-code

Interactive Clean Code Mentor & SOLID Architecture Gate

$ invoke_subagent('elevate-code')
Trigger Scenarios (When Needed)
  • When reviewing pull requests or newly written code for clean architecture and SOLID compliance.
  • When refactoring legacy spaghetti code into decoupled, testable design patterns.
  • When learning clean code principles through guided, hands-on interactive exercises.
  • When auditing software for security anti-patterns (injection vectors, hardcoded secrets).
Activation & Guardrails

Trigger: Activated when the user requests a clean code review, SOLID principle analysis, or interactive code quality mentoring.

Execution Rules:
Must ask for scope (file, directory, full project) and mode (Tutorial Mode vs Auto-Apply Mode).
Categorizes every finding strictly as [MUST-FIX] (security, severe coupling, bug) or [NICE-TO-HAVE] (naming, minor DRY).
In tutorial mode, reveals one finding at a time, challenging the developer to fix it before demonstrating the design pattern.
Never suggests disabling security features or test coverage thresholds to make code cleaner.
Example Prompt: "Review this service for SOLID principles and clean code violations."
Technical Architecture & Data Contracts
Execution Pattern

Interactive Socratic Mentorship & 12-Dimension Quality Analysis

Context Budget

100,000 token budget focused strictly on target diffs and relevant domain interfaces.

State Management

Archives formal audit reports to docs/reviews/review-[date].md.

Input Contracts
Source Code File, Directory, or Pull Request Diff Selected Mode: Tutorial Mode vs Auto-Apply Mode
Output Contracts
Refactored, Production-Grade Source Code Interactive Design Pattern Insights & Rationales docs/reviews/review-[date].md (Audit Trail)
Bundled Scripts & Reference Resources

Reference Specifications (`references/`)

analysis-checklist.md Review Checklist

12-dimension evaluation checklist covering SRP, OCP, LSP, ISP, DIP, DRY, and cyclomatic complexity.

teaching-flow.md Instructional Protocol

Detailed instructional workflows for both Tutorial Mode and Auto-Apply Mode.

review-report-template.md Audit Template

Standardized audit report markdown template saved to docs/reviews/.

Executive Overview

Linters catch syntax errors and formatting discrepancies, but they cannot evaluate whether a class violates the Single Responsibility Principle, whether tight coupling will break downstream tests, or whether an abstraction introduces dangerous side-effects.

elevate-code is an interactive clean code mentor and architectural quality gate. It analyzes code through 12 rigorous software design dimensions and operates in two distinct modes.


Dual Operating Modes

1. Tutorial Mode (The Mentor Approach)

Designed for active skill elevation and architectural learning:

  1. Presents the Smell: Identifies a specific violation (e.g., “This OrderService method handles both database transactions and third-party SMS dispatch”).
  2. Issues the Challenge: Asks the developer: “How would you decouple this notification logic using the Dependency Inversion Principle?”
  3. Evaluates & Teaches: Analyzes the developer’s attempt, explains the underlying OOP design pattern (e.g., Strategy or Observer), and presents the idiomatic solution.

2. Auto-Apply Mode (The Production Gatekeeper)

Designed for rapid CI/CD pipelines and high-velocity development:

  • Automatically diagnoses code smells, categorizes findings into [MUST-FIX] and [NICE-TO-HAVE], applies refactored diffs directly to the file tree, and outputs an audit report in docs/reviews/review-[date].md.

The 12-Dimension Quality Analysis Checklist

elevate-code audits code against 12 core engineering criteria:

  1. Single Responsibility Principle (SRP): Classes and functions must have only one reason to change.
  2. Open-Closed Principle (OCP): Open for extension, closed for modification via interfaces.
  3. Liskov Substitution Principle (LSP): Subtypes must be substitutable for base types without breaking behavior.
  4. Interface Segregation Principle (ISP): Clients must not be forced to depend on methods they do not use.
  5. Dependency Inversion Principle (DIP): Depend on abstractions, never on concrete implementations.
  6. Don’t Repeat Yourself (DRY): Eliminate logic duplication while avoiding premature abstraction.
  7. Naming Clarity & Intent: Self-documenting identifiers with zero ambiguous abbreviations.
  8. Cyclomatic Complexity: Flattens deeply nested conditionals and extracts guard clauses.
  9. Error Encapsulation: Replaces generic error throwing with typed domain exceptions (e.g., RFC 9457 Problem Details).
  10. Separation of Concerns: Strict isolation between persistence, business logic, and presentation.
  11. Security Anti-Patterns: Immediate flagging of SQL injection vectors, unsanitized inputs, and leaked tokens.
  12. Testability: Decoupled dependencies to allow friction-free unit test mocking.