|
| 1 | +# Add Comprehensive Code Review Feature to cc-track |
| 2 | + |
| 3 | +**Purpose:** Add an optional code review feature that runs after validation passes in the prepare-completion phase, launching a Claude Code SDK agent to perform comprehensive code review and write analysis to code-reviews directory. |
| 4 | + |
| 5 | +**Status:** completed |
| 6 | +**Started:** 2025-09-15 08:58 |
| 7 | +**Task ID:** 054 |
| 8 | + |
| 9 | +## Requirements |
| 10 | +- [ ] Add `code_review` section to track.config.json under `features` with `enabled` flag (default: false) |
| 11 | +- [ ] Create `performCodeReview()` function in `src/lib/claude-sdk.ts` |
| 12 | +- [ ] Configure function with taskId, taskTitle, taskRequirements, gitDiff, projectRoot parameters |
| 13 | +- [ ] Use Claude SDK with Sonnet model, 10-minute timeout, 30 turns max |
| 14 | +- [ ] Grant Read, Grep, Glob permissions plus Write/Edit to code-reviews/ directory only |
| 15 | +- [ ] Return structured review result with markdown content |
| 16 | +- [ ] Integrate into prepare-completion command after validation passes |
| 17 | +- [ ] Check if review file already exists for task (glob for `code-reviews/TASK_XXX_*.md`) |
| 18 | +- [ ] Skip review if file already exists and inform user |
| 19 | +- [ ] If no review exists, gather task requirements, git diff, task ID and title |
| 20 | +- [ ] Ensure code-reviews/ directory exists before writing |
| 21 | +- [ ] Write output to `code-reviews/TASK_XXX_[DATE].md` format |
| 22 | +- [ ] Show summary to user with path to review file |
| 23 | +- [ ] Include task summary, requirements alignment, security assessment, code quality analysis, performance considerations, architectural concerns, improvement suggestions, and overall verdict in review file |
| 24 | +- [ ] Add tests to prepare-completion.test.ts that mock the ClaudeSDK performCodeReview function |
| 25 | +- [ ] Test both enabled and disabled code review scenarios |
| 26 | +- [ ] Test skipping review when file already exists |
| 27 | +- [ ] Test file creation and error handling |
| 28 | + |
| 29 | +## Success Criteria |
| 30 | +- Code review feature can be enabled/disabled via configuration |
| 31 | +- When enabled and no existing review exists, comprehensive code review is generated after validation passes |
| 32 | +- Review files are written to code-reviews/ directory with proper naming convention |
| 33 | +- Existing reviews are detected and skip duplicate generation |
| 34 | +- Feature is fully tested with appropriate mocks |
| 35 | +- User receives clear feedback about review generation or skipping |
| 36 | + |
| 37 | +## Technical Approach |
| 38 | +- Extend existing ClaudeSDK patterns with new performCodeReview function |
| 39 | +- Use dependency injection pattern consistent with other commands |
| 40 | +- Configure agent with restricted permissions for security |
| 41 | +- Implement idempotent behavior by checking for existing review files |
| 42 | +- Follow existing test patterns with mock creation functions |
| 43 | + |
| 44 | +## Recent Progress |
| 45 | +- Researched existing codebase structure and patterns for implementing code review feature |
| 46 | +- Analyzed validation library (src/lib/validation.ts) to understand current validation flow |
| 47 | +- Examined existing code-reviews directory and file naming conventions (TASK_XXX_[DATE].md format) |
| 48 | +- Investigated track.config.json structure and configuration patterns |
| 49 | +- Reviewed Claude SDK usage patterns in claude-sdk.ts for consistent implementation |
| 50 | +- Analyzed prepare-completion command structure and integration points |
| 51 | +- Clarified requirements: hardcode 10-minute timeout and 30 turns max (not configurable) |
| 52 | +- Implemented performCodeReview() function in claude-sdk.ts with all required parameters |
| 53 | +- Added code_review configuration to track.config.json with enabled flag (default: false) |
| 54 | +- Integrated code review into prepare-completion command after validation passes |
| 55 | +- Implemented idempotent behavior - skips if review file already exists |
| 56 | +- Added comprehensive test suite covering all scenarios (enabled/disabled, existing reviews, errors) |
| 57 | +- Fixed test to expect full task content instead of just requirements section |
| 58 | +- Successfully ran automated code review on own implementation - all requirements met |
| 59 | +- Updated Biome configuration to treat all warnings as errors for stricter validation |
| 60 | + |
| 61 | +## Current Focus |
| 62 | + |
| 63 | +Task completed on 2025-09-15 |
| 64 | + |
| 65 | +## Open Questions & Blockers |
| 66 | +None - task successfully completed with comprehensive code review feature fully operational |
| 67 | + |
| 68 | +## Next Steps |
| 69 | +1. Examine current track.config.json structure and config types |
| 70 | +2. Add code_review configuration section with proper TypeScript types |
| 71 | +3. Create performCodeReview function in claude-sdk.ts |
| 72 | +4. Integrate review logic into prepare-completion command |
| 73 | + |
| 74 | +<!-- github_issue: 52 --> |
| 75 | +<!-- github_url: https://github.com/cahaseler/cc-track/issues/52 --> |
| 76 | +<!-- issue_branch: 52-add-comprehensive-code-review-feature-to-cc-track --> |
0 commit comments