/review
Perform comprehensive AI-powered code review on pull request changes. Review analyzes code for quality, security, performance, best practices, and provides actionable feedback with specific code examples.
Quick Start
# Review current branch against main
/agileflow:review
# Review specific branch
/agileflow:review BRANCH=feature/auth
# Review with focus on security
/agileflow:review FOCUS=securityThe command will:
- Get code changes (git diff)
- Analyze across 6 categories (Quality, Security, Performance, Best Practices, Testing, Documentation)
- Generate detailed report with issues prioritized by severity
- Calculate code quality score
- Suggest auto-fixes and follow-up work
Key Features
Comprehensive Analysis
Review examines your code changes across 6 important categories:
| Category | Checks |
|---|---|
| Code Quality | Complexity, duplication, naming, function/file length |
| Security | SQL injection, XSS, hardcoded secrets, unsafe deserialization |
| Performance | N+1 queries, inefficient algorithms, memory leaks |
| Best Practices | Error handling, logging, type safety, async/await |
| Testing | Missing tests, test quality, coverage gaps |
| Documentation | Missing JSDoc, outdated comments, README updates |
Severity-Based Prioritization
Issues are categorized by impact:
š“ CRITICAL - Must fix before merge
š HIGH - Fix before merge (blocks release)
š” MEDIUM - Address soon (technical debt)
āŖ LOW - Nice to have (style/consistency)Code Quality Score
Your PR gets a score (0-100) with breakdown by category:
Code Quality Score: 72/100
Breakdown:
- Security: 40/100 (critical issues found)
- Performance: 75/100 (one N+1 query)
- Maintainability: 80/100 (some complexity)
- Testing: 65/100 (coverage gaps)
- Style: 90/100 (mostly consistent)Constructive Feedback
Every issue includes:
- Where it is (file, line number)
- Why it matters (risk/impact)
- How to fix it (specific code examples)
- Example of ā BAD code
- Example of ā GOOD code
Usage
Basic - review current branch
/agileflow:reviewReviews changes on current branch against main/master.
Review specific branch
/agileflow:review BRANCH=feature/user-authReviews the named branch against main.
Review against different base
/agileflow:review BRANCH=feature/auth BASE=developCompares against a different base branch.
Review with focus area
# Security-only review
/agileflow:review FOCUS=security
# Performance-only review
/agileflow:review FOCUS=performance
# Testing coverage review
/agileflow:review FOCUS=testsFilter by severity
# Show only critical/high issues
/agileflow:review SEVERITY=high
# Show all issues
/agileflow:review SEVERITY=allParameters
| Parameter | Required | Default | Options |
|---|---|---|---|
BRANCH | No | Current | Branch name to review |
BASE | No | main/master | Base branch for comparison |
FOCUS | No | all | all, security, performance, style, tests |
SEVERITY | No | all | critical, high, medium, low, all |
Examples
Typical PR review
/agileflow:review
# Output:
# AI Code Review Report
# Branch: feature/user-auth
# Files Changed: 5
# Critical: 1 | High: 3 | Medium: 5 | Low: 2
# Code Quality Score: 72/100
#
# š“ CRITICAL ISSUES
# - Hardcoded API key in stripe.ts:15
#
# š HIGH ISSUES
# - N+1 query in posts API
# - Missing error handling in login
# ...Security-focused review
/agileflow:review FOCUS=security
# Analyzes only for:
# - Hardcoded secrets
# - SQL injection risks
# - XSS vulnerabilities
# - Authentication issues
# - CORS misconfigurationPerformance review
/agileflow:review FOCUS=performance
# Checks for:
# - N+1 database queries
# - Inefficient algorithms
# - Missing indexes
# - Memory leaks
# - Bundle size issuesReview Report Structure
Header
# AI Code Review Report
**Branch**: feature/user-auth
**Base**: main
**Files Changed**: 8
**Lines Added**: 245
**Lines Removed**: 32
**Generated**: 2025-10-16T10:30:00ZSummary
## Summary
**Critical**: 2 | **High**: 5 | **Medium**: 12 | **Low**: 8
**Must Fix Before Merge**: 7 issuesIssues by Severity
For each issue:
### 1. Hardcoded API Key (SECURITY)
**File**: src/api/payments/stripe.ts:15
**Severity**: CRITICAL
// ā BAD
const stripeKey = "sk_live_abc123...";
// ā
GOOD
const stripeKey = process.env.STRIPE_SECRET_KEY;
if (!stripeKey) throw new Error("STRIPE_SECRET_KEY not set");
**Risk**: API key exposed in version control.
**Fix**: Move to environment variable. Rotate immediately.
**Priority**: Block mergePositive Observations
## Positive Observations ā
- ā
Good use of TypeScript strict mode
- ā
Consistent error handling pattern
- ā
Well-structured component separation
- ā
Clear commit messagesCode Quality Breakdown
## Code Quality Score: 72/100
**Breakdown**:
- Security: 40/100 (2 critical issues)
- Performance: 75/100 (1 N+1 query)
- Maintainability: 80/100 (some complexity)
- Testing: 65/100 (coverage gaps)
- Style: 90/100 (mostly consistent)Customization
Project-specific rules
Create custom review rules in:
.agileflow/review-rules.mddocs/02-practices/code-standards.md
Example:
# Code Review Rules
## Critical
- No console.log in production code
- All API endpoints must have rate limiting
- All database queries must use ORM
## High
- Functions >30 lines should be refactored
- Test coverage must be >85%Actions After Review
Auto-fix issues
Review asks: "Fix auto-fixable issues? (YES/NO)"
If YES:
- Runs npm run lint -- --fix
- Fixes 8 style issues automatically
- Shows which issues were fixedCreate follow-up stories
Review asks: "Create stories for follow-up work?"
If YES:
- Creates story for each medium/low issue
- Adds to your backlog
- Links to code review reportBlock merge for critical issues
Review asks: "Block merge for critical/high issues?"
If YES:
- Marks merge as blocked
- Provides failure reason
- Suggests resolution stepsSave report
Report automatically saved to:
docs/08-project/code-reviews/<YYYYMMDD>-<BRANCH>.mdExample:
docs/08-project/code-reviews/20251016-feature-user-auth.mdSecurity Checks
Review automatically checks for:
Secrets & Credentials
- Hardcoded API keys
- Database passwords
- OAuth tokens
- JWT secrets
- AWS credentials
Common Vulnerabilities
- SQL injection (unparameterized queries)
- XSS attacks (unescaped output)
- Unsafe deserialization
- CSRF vulnerabilities
- Missing CORS validation
Insecure Patterns
- eval() or Function()
- Unsafe string concatenation
- Missing input validation
- Weak encryption
- Insecure dependencies
Performance Checks
Review looks for:
Database
- N+1 query problems
- Missing indexes
- Inefficient joins
- Unnecessary queries
Algorithms
- O(n²) when O(n) possible
- Nested loops that could be flat
- Repeated calculations
- Unoptimized recursion
Memory
- Memory leaks
- Large objects not freed
- Circular references
- Memory hogging data structures
Testing Coverage
Review checks:
New Code
- Is there a test for new functionality?
- Are edge cases covered?
- Is test quality good?
Coverage Gaps
- Lines added without tests
- Functions with no test coverage
- Error paths not tested
Test Quality
- Are assertions meaningful?
- Do tests verify behavior?
- Are tests maintainable?
Output & Recommendations
Immediate Actions (Block Merge)
1. Remove hardcoded API key (critical)
2. Fix SQL injection (critical)
3. Add error handling to login (high)Before Merge
4. Add tests for auth endpoints (high)
5. Fix N+1 query in posts API (high)
6. Reduce complexity in validator.ts (medium)Follow-up (Create Stories)
7. Standardize naming conventions (medium)
8. Add ESLint rule for secrets (medium)
9. Set up automated security scanning (low)Integration with CI
Suggest adding to .github/workflows/pr.yml:
- name: AI Code Review
run: npx claude-code /agileflow:review BRANCH=${{ github.head_ref }}
- name: Check for critical issues
run: |
if grep -q "CRITICAL" code-review-report.md; then
echo "::error::Critical issues found."
exit 1
fiTips
Before submitting PR
/agileflow:review
# Fix any CRITICAL or HIGH issues
# Address MEDIUM issues if possible
# Then submit PR with confidenceIterative improvement
# After feedback, run review again
/agileflow:review
# See if score improved
# Ensure critical issues fixed
# Check test coverageSecurity-first approach
# Always check security first
/agileflow:review FOCUS=security
# Fix any CRITICAL security issues
# Then review other categoriesPrinciples
- Be constructive - Provide actionable feedback, not just criticism
- Show examples - Include ā BAD and ā GOOD code
- Prioritize - Critical issues first, style last
- Celebrate - Include positive observations
- Suggest fixes - Don't just identify problems
- No force commits - Always ask before auto-fixing
Related Commands
On This Page
/reviewQuick StartKey FeaturesComprehensive AnalysisSeverity-Based PrioritizationCode Quality ScoreConstructive FeedbackUsageBasic - review current branchReview specific branchReview against different baseReview with focus areaFilter by severityParametersExamplesTypical PR reviewSecurity-focused reviewPerformance reviewReview Report StructureHeaderSummaryIssues by SeverityPositive ObservationsCode Quality BreakdownCustomizationProject-specific rulesActions After ReviewAuto-fix issuesCreate follow-up storiesBlock merge for critical issuesSave reportSecurity ChecksSecrets & CredentialsCommon VulnerabilitiesInsecure PatternsPerformance ChecksDatabaseAlgorithmsMemoryTesting CoverageNew CodeCoverage GapsTest QualityOutput & RecommendationsImmediate Actions (Block Merge)Before MergeFollow-up (Create Stories)Integration with CITipsBefore submitting PRIterative improvementSecurity-first approachPrinciplesRelated Commands