code-reviewer
Code Reviewer
⚠️ MANDATORY COMPLIANCE ⚠️
CRITICAL: The 5-step workflow outlined in this document MUST be followed in exact order for EVERY code review. Skipping steps or deviating from the procedure will result in incomplete and unreliable reviews. This is non-negotiable.
File Structure
- SKILL.md (this file): Main instructions and MANDATORY workflow
- examples.md: Review scenarios demonstrating cross-language reviews, architecture assessments, and legacy code audits
- Context: Language and domain context loaded dynamically via
contextProvider.getDomainIndex("{detected-language}")andcontextProvider.getDomainIndex("security"). See ContextProvider Interface. - Memory: Project-specific memory accessed via
memoryStore.getSkillMemory("code-reviewer", "{project-name}"). See MemoryStore Interface.
Review Focus Areas
This skill evaluates 8 critical dimensions in the changed code, independent of language or framework:
- Correctness & Logic: Algorithm correctness, boundary conditions, off-by-one errors, null/nil handling, type mismatches, logic flow
- Error Handling: Exception strategies, graceful degradation, error propagation, resource cleanup, failure recovery
- Maintainability & Readability: Code clarity, function length, cognitive complexity, comments quality, consistent style
- SOLID Principles: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
- DRY / KISS: Code duplication, unnecessary abstractions, over-engineering, premature optimization
- Naming Conventions: Variable, function, class, and module naming clarity and consistency with language idioms
- Test Coverage Assessment: Missing tests for changed code, edge case coverage, test quality and isolation
- Documentation Completeness: API docs, inline comments for complex logic, README updates, changelog entries
Note: Focus on substantive issues requiring human judgment, not style/formatting details. Reviews are performed on changed code only, using the get-git-diff skill to identify modifications.
MANDATORY WORKFLOW (MUST FOLLOW EXACTLY)
⚠️ STEP 1: Identify Review Scope (REQUIRED)
YOU MUST:
- Invoke the
get-git-diffskill to identify changed files, OR analyze user-specified files directly - Determine comparison scope:
- Which commits/branches to compare? (e.g.,
HEAD^ vs HEAD,main vs feature-branch) - If not specified, default to comparing current changes against the default branch
- Which commits/branches to compare? (e.g.,
- Classify changed files by language and framework:
- Detect languages from file extensions (
.py,.js,.ts,.go,.java,.cs,.rb, etc.) - Identify frameworks from imports, config files, and project structure
- Detect languages from file extensions (
- If no reviewable files were changed, inform the user and exit gracefully
- Focus subsequent review ONLY on the files identified in the diff
DO NOT PROCEED WITHOUT IDENTIFYING REVIEW SCOPE
⚠️ STEP 2: Load Memory & Context (REQUIRED)
YOU MUST:
- CHECK PROJECT MEMORY FIRST:
- Identify the project name from the repository root or ask the user
- Use
memoryStore.getSkillMemory("code-reviewer", "{project-name}")to load project-specific patterns - Cross-skill discovery: Use
memoryStore.getByProject("{project-name}")to check for related skill results (e.g.,python-code-review,dotnet-code-review,database-schema-analysis) - If memory exists: Review previously learned patterns, conventions, and project-specific context
- If no memory exists (empty result): Note this is first review, you will create memory later
- USE CONTEXT INDEXES FOR EFFICIENT LOADING:
- For each detected language, use
contextProvider.getDomainIndex("{language}")to understand available context - Use
contextProvider.getDomainIndex("security")for security-related context - Use
contextProvider.getCrossDomainContext("{language}", triggers)for cross-cutting concerns
- For each detected language, use
See ContextProvider and MemoryStore interfaces.
DO NOT PROCEED WITHOUT COMPLETING THIS STEP
⚠️ STEP 3: Load Relevant Context (REQUIRED)
YOU MUST use the indexes to load only relevant files:
Based on languages and frameworks detected in Step 1:
- ALWAYS: Use
contextProvider.getAlwaysLoadFiles("{language}")for each detected language to load universal patterns and common issues - Based on framework detected: Use
contextProvider.getConditionalContext("{language}", detection)to load framework-specific patterns - For security-sensitive code: Use
contextProvider.getCrossDomainContext("{language}", triggers)where triggers include:- Authentication/authorization code
- User input handling and validation
- Database queries and data access
- File system operations
- Network/API calls
- Cryptographic operations
- For multi-language PRs: Load context for EACH language present in the changeset, respecting the file token budget
Progressive loading: Only load files relevant to the detected languages, frameworks, and code type. The ContextProvider respects the 4-6 file token budget automatically.
DO NOT SKIP LOADING RELEVANT CONTEXT FILES
⚠️ STEP 4: Deep Review (REQUIRED)
YOU MUST examine ONLY the changed code for ALL categories below:
Important: While reviewing changed lines, consider the surrounding context to understand:
- How changes interact with existing code
- Whether changes introduce regressions
- Impact on callers and dependent code
- Whether the change addresses the root cause or masks symptoms
Review Categories (language-agnostic):
Correctness & Logic: Algorithm correctness, boundary conditions, null safety, type correctness, edge cases, off-by-one errors, integer overflow, state corruption Error Handling: Missing error handling, swallowed exceptions, improper error propagation, resource leaks, missing cleanup/finally blocks, inconsistent error strategies Maintainability: Function/method length, cognitive complexity, deep nesting, code duplication, magic numbers/strings, dead code, unclear control flow SOLID Principles: God classes, mixed responsibilities, rigid hierarchies, interface bloat, concrete dependencies, violation of contracts DRY / KISS: Repeated logic, unnecessary abstractions, over-engineering, premature optimization, complex solutions for simple problems Naming & Conventions: Unclear names, inconsistent naming style, misleading identifiers, language-idiomatic naming violations Test Coverage: Missing tests for new/changed code, untested edge cases, brittle tests, missing integration tests, poor test isolation Documentation: Missing/outdated API docs, undocumented public interfaces, missing changelog entries, misleading comments
DO NOT SKIP ANY CATEGORY
⚠️ STEP 5: Generate Report & Update Memory (REQUIRED)
YOU MUST ask user for preferred output format:
- Option A: Structured report → executive summary, categorized findings, action items → output to
claudedocs/ - Option B: Inline comments → file:line feedback, PR-style
- Option C (Default): Both formats
DO NOT CHOOSE FORMAT WITHOUT USER INPUT
For EVERY issue in the output, YOU MUST provide:
- Severity: Critical / Important / Minor
- Category: Correctness / Error Handling / Maintainability / SOLID / DRY-KISS / Naming / Testing / Documentation
- Description: What is wrong and why it matters
- Fix: Concrete code example with improvement
- File:line: Exact location (e.g.,
handler.go:142)
Format guidelines:
- Explain WHY (not just what)
- Show HOW to fix with examples
- Be specific with file:line references
- Be balanced (acknowledge good patterns)
- Educate, don't criticize
- Note language-specific idioms and conventions
DO NOT PROVIDE INCOMPLETE RECOMMENDATIONS
After completing the review, UPDATE PROJECT MEMORY:
Use memoryStore.update("code-reviewer", "{project-name}", ...) to create or update memory files:
- project_overview: Languages, frameworks, architecture patterns, deployment info
- common_patterns: Project-specific coding patterns and conventions discovered
- known_issues: Recurring issues or anti-patterns found in this project
- review_history: Summary of reviews performed with dates and key findings
Timestamps and staleness tracking are managed automatically by MemoryStore. See MemoryStore Interface for update() and append() method details.
Interface References
| Interface | Usage in This Skill |
|---|---|
| ContextProvider | Load language/framework context dynamically based on detected stack |
| MemoryStore | Persist project review patterns, conventions, and history |
| SkillInvoker | Delegate to get-git-diff for change identification |
| ExecutionContext | Receive context from chained commands |
Compliance Checklist
Before completing ANY review, verify:
- Step 1: Review scope identified using
get-git-diffskill or user-specified files; languages and frameworks detected - Step 2: Project memory loaded via
memoryStore.getSkillMemory()and context detected viacontextProvider - Step 3: All relevant context files loaded via
contextProvider.getAlwaysLoadFiles(),getConditionalContext(), andgetCrossDomainContext()for each detected language - Step 4: Deep review completed for ALL categories on changed code only
- Step 5: Output generated with all required fields AND project memory updated via
memoryStore.update()
FAILURE TO COMPLETE ALL STEPS INVALIDATES THE REVIEW
Further Reading
- Quality Principles:
- SOLID Principles: https://en.wikipedia.org/wiki/SOLID
- Clean Code (Robert C. Martin)
- Refactoring (Martin Fowler)
- Security:
- OWASP Top 10: https://owasp.org/www-project-top-ten/
- CWE Top 25: https://cwe.mitre.org/top25/
- Testing:
- Test Pyramid: https://martinfowler.com/bliki/TestPyramid.html
Version History
- v1.0.0 (2026-02-12): Initial release — language-agnostic code review framework
- Covers 8 review dimensions: correctness, error handling, maintainability, SOLID, DRY/KISS, naming, testing, documentation
- Dynamic language/framework detection with contextProvider integration
- Cross-skill discovery via memoryStore for related review insights