|
| 1 | +# Continuous Code Review Guide |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Automated code reviews run on a schedule to continuously monitor code quality, security vulnerabilities, and technical debt. |
| 6 | + |
| 7 | +## Setup |
| 8 | + |
| 9 | +### Option 1: Daily Reviews (Recommended) |
| 10 | + |
| 11 | +Run comprehensive code review every day at 9am: |
| 12 | + |
| 13 | +\`\`\`bash |
| 14 | +# Create cron job for daily reviews |
| 15 | +/loop "0 9 * * *" "/auto-review --severity=high" |
| 16 | +\`\`\` |
| 17 | + |
| 18 | +### Option 2: Weekly Reviews |
| 19 | + |
| 20 | +Run exhaustive review every Monday at 9am: |
| 21 | + |
| 22 | +\`\`\`bash |
| 23 | +# Create cron job for weekly reviews |
| 24 | +/loop "0 9 * * 1" "/auto-review --severity=all --deep-scan" |
| 25 | +\`\`\` |
| 26 | + |
| 27 | +### Option 3: On-Commit Reviews |
| 28 | + |
| 29 | +Trigger review on every commit via Git hook: |
| 30 | + |
| 31 | +\`\`\`bash |
| 32 | +# .git/hooks/post-commit |
| 33 | +#!/bin/bash |
| 34 | +claude-code --session=auto-review "/auto-review --quick" |
| 35 | +\`\`\` |
| 36 | + |
| 37 | +## Review Dimensions |
| 38 | + |
| 39 | +Each review scans across multiple dimensions: |
| 40 | + |
| 41 | +### 1. Security Vulnerabilities |
| 42 | +- OWASP Top 10 checks |
| 43 | +- Path traversal attempts |
| 44 | +- SQL injection risks |
| 45 | +- XSS vulnerabilities |
| 46 | +- Insecure deserialization |
| 47 | +- Known CVEs in dependencies |
| 48 | + |
| 49 | +### 2. Code Quality |
| 50 | +- Cyclomatic complexity |
| 51 | +- Code duplication |
| 52 | +- Long methods (>150 lines) |
| 53 | +- God classes (>500 lines) |
| 54 | +- Lack of cohesion |
| 55 | +- Code smells |
| 56 | + |
| 57 | +### 3. Test Coverage |
| 58 | +- Uncovered code paths |
| 59 | +- Missing edge case tests |
| 60 | +- Untested error handling |
| 61 | +- Integration test gaps |
| 62 | +- Missing security tests |
| 63 | + |
| 64 | +### 4. Documentation |
| 65 | +- Missing JavaDoc on public APIs |
| 66 | +- Outdated documentation |
| 67 | +- TODO/FIXME audit |
| 68 | +- Missing README sections |
| 69 | + |
| 70 | +### 5. Dependencies |
| 71 | +- Outdated versions |
| 72 | +- Known vulnerabilities (CVE database) |
| 73 | +- Unused dependencies |
| 74 | +- License compatibility |
| 75 | + |
| 76 | +## Severity Levels |
| 77 | + |
| 78 | +Reviews create GitHub issues based on severity: |
| 79 | + |
| 80 | +| Severity | Description | Action | |
| 81 | +|----------|-------------|--------| |
| 82 | +| **P0 (Critical)** | Security vulnerability, data loss risk | Auto-fix immediately + create issue | |
| 83 | +| **P1 (High)** | Production blocker, major bug | Create issue, assign to team | |
| 84 | +| **P2 (Medium)** | Technical debt, code smell | Create issue, backlog | |
| 85 | +| **P3 (Low)** | Nice-to-have, optimization | Log only, no issue | |
| 86 | + |
| 87 | +## Configuration |
| 88 | + |
| 89 | +### Custom Review Rules |
| 90 | + |
| 91 | +Create `.claude/review-config.yaml`: |
| 92 | + |
| 93 | +\`\`\`yaml |
| 94 | +review: |
| 95 | + schedule: "0 9 * * *" # Daily at 9am |
| 96 | + severity_threshold: high # Only P0/P1 issues |
| 97 | + auto_fix: true # Auto-fix P0 issues |
| 98 | + |
| 99 | + dimensions: |
| 100 | + security: |
| 101 | + enabled: true |
| 102 | + checks: |
| 103 | + - owasp-top-10 |
| 104 | + - dependency-vulnerabilities |
| 105 | + - path-traversal |
| 106 | + |
| 107 | + quality: |
| 108 | + enabled: true |
| 109 | + thresholds: |
| 110 | + max_method_length: 150 |
| 111 | + max_class_length: 500 |
| 112 | + max_cyclomatic_complexity: 15 |
| 113 | + |
| 114 | + coverage: |
| 115 | + enabled: true |
| 116 | + minimum: 60 # Fail if below 60% |
| 117 | + |
| 118 | + documentation: |
| 119 | + enabled: true |
| 120 | + require_javadoc: public # public methods only |
| 121 | + |
| 122 | + exclusions: |
| 123 | + paths: |
| 124 | + - "*/test/*" |
| 125 | + - "*/generated/*" |
| 126 | + files: |
| 127 | + - "*.generated.java" |
| 128 | +\`\`\` |
| 129 | + |
| 130 | +### GitHub Integration |
| 131 | + |
| 132 | +Auto-create issues for findings: |
| 133 | + |
| 134 | +\`\`\`yaml |
| 135 | +github: |
| 136 | + create_issues: true |
| 137 | + labels: |
| 138 | + - code-review |
| 139 | + - automated |
| 140 | + assign_to: "@team-lead" |
| 141 | + milestone: "Tech Debt Sprint" |
| 142 | +\`\`\` |
| 143 | + |
| 144 | +## Review Reports |
| 145 | + |
| 146 | +Reviews generate: |
| 147 | + |
| 148 | +1. **Summary Report** - `.claude/review-output/summary-YYYY-MM-DD.md` |
| 149 | +2. **Detailed Findings** - `.claude/review-output/findings-YYYY-MM-DD.json` |
| 150 | +3. **Trend Analysis** - `.claude/review-output/trends.csv` |
| 151 | + |
| 152 | +### Example Summary Report |
| 153 | + |
| 154 | +\`\`\`markdown |
| 155 | +# Code Review Summary - 2026-05-29 |
| 156 | + |
| 157 | +## Overview |
| 158 | +- **Files Scanned**: 153 |
| 159 | +- **Issues Found**: 12 |
| 160 | +- **Auto-Fixed**: 3 |
| 161 | + |
| 162 | +## By Severity |
| 163 | +- **P0 (Critical)**: 1 - Path traversal (auto-fixed) |
| 164 | +- **P1 (High)**: 4 - Missing input validation |
| 165 | +- **P2 (Medium)**: 5 - Code duplication |
| 166 | +- **P3 (Low)**: 2 - Missing JavaDoc |
| 167 | + |
| 168 | +## By Dimension |
| 169 | +- **Security**: 5 issues |
| 170 | +- **Quality**: 4 issues |
| 171 | +- **Coverage**: 2 issues |
| 172 | +- **Documentation**: 1 issue |
| 173 | + |
| 174 | +## Top Issues |
| 175 | + |
| 176 | +### #1 [P0] Path Traversal in NativeProcessLauncher |
| 177 | +**Status**: Auto-fixed |
| 178 | +**File**: platform-core/src/main/java/.../NativeProcessLauncher.java:131 |
| 179 | +**Fix**: Added path validation |
| 180 | + |
| 181 | +### #2 [P1] Missing Input Validation in ApiAuthFilter |
| 182 | +**Status**: Issue created (#340) |
| 183 | +**File**: platform-rest-api/src/main/java/.../ApiAuthFilter.java:87 |
| 184 | +**Recommendation**: Add null check before authentication |
| 185 | + |
| 186 | +... |
| 187 | +\`\`\` |
| 188 | + |
| 189 | +## Best Practices |
| 190 | + |
| 191 | +### 1. **Review Scheduling** |
| 192 | +- **Daily**: Quick scans (5-10 min) for recent changes |
| 193 | +- **Weekly**: Deep scans (30-60 min) for comprehensive coverage |
| 194 | +- **On-Commit**: Lightweight checks (1-2 min) for immediate feedback |
| 195 | + |
| 196 | +### 2. **Issue Triage** |
| 197 | +- Review auto-created issues daily |
| 198 | +- Close false positives immediately |
| 199 | +- Assign P0/P1 issues to sprint |
| 200 | +- Backlog P2/P3 for tech debt sprints |
| 201 | + |
| 202 | +### 3. **Auto-Fix Guidelines** |
| 203 | +- Only auto-fix P0 issues with high confidence |
| 204 | +- Always create backup branch before auto-fix |
| 205 | +- Review auto-fixes in next PR |
| 206 | +- Disable auto-fix for critical systems |
| 207 | + |
| 208 | +### 4. **Metrics Tracking** |
| 209 | +- Track issues found/fixed over time |
| 210 | +- Monitor coverage trends |
| 211 | +- Measure mean-time-to-fix by severity |
| 212 | +- Report on security posture monthly |
| 213 | + |
| 214 | +## Troubleshooting |
| 215 | + |
| 216 | +### Review Taking Too Long |
| 217 | + |
| 218 | +Reduce scope: |
| 219 | +\`\`\`yaml |
| 220 | +review: |
| 221 | + scope: changed # Only review changed files |
| 222 | + max_files: 50 # Limit to 50 files per run |
| 223 | +\`\`\` |
| 224 | + |
| 225 | +### Too Many False Positives |
| 226 | + |
| 227 | +Tune sensitivity: |
| 228 | +\`\`\`yaml |
| 229 | +review: |
| 230 | + sensitivity: low # Reduce false positives |
| 231 | + confidence_threshold: 0.8 # Higher confidence required |
| 232 | +\`\`\` |
| 233 | + |
| 234 | +### Missing Issues |
| 235 | + |
| 236 | +Increase depth: |
| 237 | +\`\`\`yaml |
| 238 | +review: |
| 239 | + deep_scan: true |
| 240 | + check_transitive_deps: true |
| 241 | + analyze_dead_code: true |
| 242 | +\`\`\` |
| 243 | + |
| 244 | +## Integration with CI/CD |
| 245 | + |
| 246 | +### GitHub Actions |
| 247 | + |
| 248 | +\`\`\`yaml |
| 249 | +# .github/workflows/code-review.yml |
| 250 | +name: Automated Code Review |
| 251 | + |
| 252 | +on: |
| 253 | + schedule: |
| 254 | + - cron: '0 9 * * *' # Daily at 9am |
| 255 | + push: |
| 256 | + branches: [main, develop] |
| 257 | + |
| 258 | +jobs: |
| 259 | + review: |
| 260 | + runs-on: ubuntu-latest |
| 261 | + steps: |
| 262 | + - uses: actions/checkout@v4 |
| 263 | + |
| 264 | + - name: Run Claude Code Review |
| 265 | + run: | |
| 266 | + claude-code "/auto-review --ci-mode" |
| 267 | + |
| 268 | + - name: Upload Report |
| 269 | + uses: actions/upload-artifact@v4 |
| 270 | + with: |
| 271 | + name: code-review-report |
| 272 | + path: .claude/review-output/ |
| 273 | +\`\`\` |
| 274 | + |
| 275 | +## Metrics Dashboard |
| 276 | + |
| 277 | +Track review metrics over time: |
| 278 | + |
| 279 | +\`\`\`bash |
| 280 | +# Generate metrics dashboard |
| 281 | +claude-code "/auto-review --metrics-dashboard" |
| 282 | +\`\`\` |
| 283 | + |
| 284 | +Creates HTML dashboard at `.claude/review-output/dashboard.html`: |
| 285 | +- Issues found/fixed trend |
| 286 | +- Coverage trend |
| 287 | +- Security posture score |
| 288 | +- Top file hotspots |
| 289 | +- Technical debt accumulation |
| 290 | + |
| 291 | +## Next Steps |
| 292 | + |
| 293 | +1. **Choose schedule** - Daily, weekly, or on-commit |
| 294 | +2. **Configure rules** - Create `.claude/review-config.yaml` |
| 295 | +3. **Test run** - Run `/auto-review --dry-run` |
| 296 | +4. **Enable automation** - Set up cron job or CI/CD integration |
| 297 | +5. **Monitor results** - Review reports daily |
| 298 | +6. **Iterate** - Tune configuration based on findings |
| 299 | + |
| 300 | +--- |
| 301 | + |
| 302 | +**Last Updated**: May 29, 2026 |
| 303 | +**Related Skills**: `/auto-review`, `/auto-review-loop` |
| 304 | +**Issue**: #338 |
0 commit comments