What problem does it solve?
This skill evaluates long-term code health: maintainability, readability, standards compliance, architectural alignment, and computational efficiency. It is distinct from code-review (which applies a holistic 8-dimension assessment for merge readiness) because this skill goes deep on quality metrics, tooling recommendations, architecture drift detection, and technical debt measurement. The objective is to ensure the codebase remains sustainable, performant, and structurally sound over time — not just correct today.
Clean Code in the AI Era
Code quality matters exponentially more when AI generates substantial portions of the codebase. AI models depend on the existing repository's abstractions, naming conventions, and architectural patterns to generate new code. If the codebase is messy, inconsistent, or poorly architected, AI systems absorb, mimic, and amplify that mess at massive scale. Software does not run on semantic meaning or intent — it runs on formal, precise, executable instructions. Code is the definitive formal anchor that ties business intent to deterministic behavior.
The Clean as You Code philosophy, pioneered by SonarQube, addresses this pragmatically: apply quality gates only to new and changed code, not the entire legacy codebase. This prevents technical debt accumulation in new work without requiring a massive retroactive cleanup. Quality gates on new code achieve false positive rates as low as 1% on mature codebases.
Clean, maintainable code enables AI agents to reason clearly, manage token limits effectively, and produce reliable outputs. Dirty code produces dirty AI outputs at scale — creating a compounding degradation loop.
Standards Enforcement Framework
Apply a three-layer automation stack to enforce quality systematically.
Layer 1 — Baseline Hygiene. Formatters, linters, and type checkers provide the foundation. Every PR must pass these before human review begins:
- Formatters: Prettier (JS/TS), Black (Python), rustfmt (Rust), gofmt (Go) — eliminate all style debates
- Linters: Ruff (Python, 10–100x faster than Flake8/Pylint, replaces multiple tools), ESLint v10 (JS/TS, now multi-threaded with CSS/HTML/JSON support), Oxlint (Rust-powered JS linter, 50–100x faster), golangci-lint (Go)
- Type Checkers: mypy (Python, 58% adoption), Pyright (3–5x faster, powers VS Code Pylance), ty (Astral, 80x faster than Pyright on incremental checks), TypeScript strict mode (gold standard for JS/TS)
Layer 2 — Semantic Analysis. Deep analysis engines that understand code meaning beyond syntax:
- SonarQube quality gates with pass/fail enforcement on new code
- Meta's Infer for inter-procedural bug detection using separation logic
- CodeQL for semantic pattern matching across 30+ languages
- Semgrep with reachability analysis reducing false positives by up to 98%
Layer 3 — AI-Assisted Review. Contextual analysis of design, intent, and cross-file dependencies:
- AI reviewers for change risk assessment and design evaluation
- Intent analysis comparing the change against its stated purpose
- Cross-file dependency tracing for impact assessment
Language-Specific Standards. Enforce the authoritative style guide for each language:
- JavaScript/TypeScript: Airbnb Style Guide (const over let, no var, strict ESLint enforcement)
- C#/.NET: editorconfig rules (IDE0017 object initializers, IDE0018 inline variables, IDE0016 throw expressions)
- Rust: Rust Style Guide with rustfmt + clippy (watch for non-idiomatic AI-generated Rust)
- Python: PEP 8 via Ruff, PEP 484 type hints enforced by type checker
Consult standards-enforcement documentation for detailed tool configurations and language-specific rule sets.
Architecture Review Protocol
Evaluate whether the code change respects the intended architecture using the C4 model as the documentation standard.
C4 Model Validation. The C4 model maps architecture across four levels of abstraction:
- System Context (Level 1): How the system fits into the broader environment — actors, users, external integrations
- Containers (Level 2): Separately deployable building blocks — web apps, APIs, databases, message brokers
- Components (Level 3): Internal logical groupings within a container — domain services, handlers, clients
- Code (Level 4): Implementation-level classes and interfaces — generally auto-generated from the codebase
Architecture Decision Records (ADRs). Verify that the change aligns with documented ADRs. If the change contradicts an existing ADR, it must either reference a new ADR that supersedes the old one or be flagged as architectural drift. ADRs capture context, alternatives considered, and consequences — not just the decision.
Drift Detection. Compare the live code against the documented architecture:
- Does the change respect defined module boundaries?
- Does it introduce new coupling between components that should be independent?
- Does it bypass established interfaces or create "shortcut" dependencies?
- Does it violate the layering defined in the C4 model (e.g., presentation layer directly accessing data layer)?
If architecture documentation exists, compute an informal drift score. Significant drift should block the merge or trigger an architecture review discussion.
Consult architecture-review information for procedures, ADR formats, and drift scoring methodology.
Efficiency Assessment
Evaluate computational efficiency and resource usage for production-impacting code.
Algorithmic Complexity. Flag unnecessary O(n^2) operations where O(n) or O(n log n) alternatives exist. Check for nested loops over large collections, repeated linear searches that should use hash maps, and sorting operations inside loops.
Resource Utilization. Examine memory allocation patterns (large allocations in hot paths, unnecessary copies), connection pooling, and caching strategy.
Database Query Optimization. Identify N+1 query patterns, missing indices on frequently queried columns, unnecessary joins, full table scans in production paths, and transaction scope issues.
Unnecessary Computation. Flag redundant API calls, repeated parsing of the same data, missed memoization opportunities, and work performed inside loops that could be hoisted outside.
Prioritization. Focus efficiency review effort based on the code's execution context. For hot paths, etc. Flag efficiency findings only when measurable or patterns clearly suboptimal.
Quality Metrics and Technical Debt
Measure and report on quality indicators that predict long-term maintainability, including DORA metrics mapping, AI productivity context, and debt indicators. Track code duplication, cyclomatic and cognitive complexity, dependency staleness, test coverage gaps, and TODO/FIXME/HACK density. Align findings with ISO/IEC/IEEE 5055 and IEEE 730-2026 references where applicable.
Quality Gate Configuration
SonarQube friendly gating for new code, plus manual checks for projects without SonarQube.
Review-Adjacent Metrics
Flow/throughput metrics to monitor quality and delivery interplay; outcome metrics for defect escape, change failure rate, and time-to-fix.
The content above outlines the standard approach for quality assurance in codebases and provides guidance for implementing robust quality practices across teams.
Consult references to align with the defined procedures, metrics, and governance models.
Cross-reference: references/architecture-review.md
Cross-reference: references/standards-enforcement.md
Cross-reference: references/metrics-and-debt.md
Cross-reference: references/standards-enforcement.md
Cross-reference: references/metrics-and-debt.md
Cross-reference: references/architecture-review.md
Cross-reference: references/standards-enforcement.md
Cross-reference: references/metrics-and-debt.md
Cross-reference: references/standards-enforcement.md
Cross-reference: references/architecture-review.md
Quick StartGuidance
Run a quality-review pass on the target codebase to generate a structured quality report.