|
| 1 | +# +brc - Branch Review & Cleanup |
| 2 | + |
| 3 | +Review differences between current branch and main branch, and perform branch cleanup. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This command performs comprehensive quality checks and cleanup before PR creation. It focuses on: |
| 8 | + |
| 9 | +- Ensuring code quality (lint, format) |
| 10 | +- Removing unnecessary files and code |
| 11 | +- **Complete cleanup of tmp/ directory** |
| 12 | +- Reviewing and resolving TODOs |
| 13 | +- Ensuring test success |
| 14 | + |
| 15 | +## Execution Steps |
| 16 | + |
| 17 | +### 1. Review Differences |
| 18 | +```bash |
| 19 | +git diff main...HEAD |
| 20 | +git diff --name-only main...HEAD |
| 21 | +``` |
| 22 | +Review files and content changed in the current branch. |
| 23 | + |
| 24 | +### 2. Remove Unnecessary Files and Code Fragments |
| 25 | +- Remove debug print statements, console.log, temporary commented-out code |
| 26 | +- Remove temporary test files (test_*.py, *.log, *.tmp, etc.) not used in actual tests |
| 27 | +- Remove unused import statements |
| 28 | +- Remove experimental code only used during implementation |
| 29 | +- **tmp/ directory cleanup**: |
| 30 | + ```bash |
| 31 | + # Check tmp/ directory contents |
| 32 | + if [ -d "tmp/" ]; then |
| 33 | + echo "=== tmp/ directory contents ===" |
| 34 | + ls -la tmp/ |
| 35 | + echo "Delete these files? (y/N)" |
| 36 | + # Wait for user confirmation |
| 37 | + read -r response |
| 38 | + if [[ "$response" =~ ^[Yy]$ ]]; then |
| 39 | + rm -rf tmp/* |
| 40 | + echo "Cleaned up tmp/ directory" |
| 41 | + fi |
| 42 | + else |
| 43 | + echo "tmp/ directory does not exist" |
| 44 | + fi |
| 45 | + ``` |
| 46 | + |
| 47 | +### 3. Review and Resolve TODOs |
| 48 | +```bash |
| 49 | +# Search for TODO comments |
| 50 | +rg "TODO|FIXME|XXX|HACK" --type-add 'code:*.{py,ts,js,tsx,jsx}' -t code |
| 51 | +``` |
| 52 | +- Review each TODO found |
| 53 | +- Immediately resolve items that should be addressed in current branch |
| 54 | +- For items to remain as future tasks, clearly document reasons in summary |
| 55 | + |
| 56 | +### 4. Fix Formatting |
| 57 | +```bash |
| 58 | +make format |
| 59 | +make lint |
| 60 | +``` |
| 61 | +- If lint errors exist, review error messages and fix |
| 62 | +- Manually fix errors that cannot be auto-fixed |
| 63 | + |
| 64 | +### 5. Fix Tests |
| 65 | +```bash |
| 66 | +make test |
| 67 | +``` |
| 68 | +- If tests fail: |
| 69 | + - First analyze error messages |
| 70 | + - Verify test expectations are correct |
| 71 | + - Determine whether to fix implementation or tests |
| 72 | + - If implementation should take priority over tests, document reasons in summary |
| 73 | + |
| 74 | +### 6. Final Review and Summary Display |
| 75 | +Display summary in the following format: |
| 76 | + |
| 77 | +``` |
| 78 | +## Branch Review Summary |
| 79 | +
|
| 80 | +### Changes |
| 81 | +- Changed files: X files |
| 82 | +- Added lines: +XXX |
| 83 | +- Deleted lines: -XXX |
| 84 | +
|
| 85 | +### Cleanup Performed |
| 86 | +- [ ] Removed unnecessary debug code |
| 87 | +- [ ] Removed unused imports |
| 88 | +- [ ] Removed temporary files |
| 89 | +- [ ] Cleaned up tmp/ directory |
| 90 | +
|
| 91 | +### TODO Status |
| 92 | +- Resolved: X items |
| 93 | +- Remaining: X items |
| 94 | + - [Reason] TODO content |
| 95 | +
|
| 96 | +### Test & Quality Check |
| 97 | +- [ ] make format: PASS/FAIL |
| 98 | +- [ ] make lint: PASS/FAIL |
| 99 | +- [ ] make test: PASS/FAIL |
| 100 | +
|
| 101 | +### Remaining Issues |
| 102 | +(Document if any) |
| 103 | +
|
| 104 | +### Next Steps |
| 105 | +(If all checks PASS) |
| 106 | +Ready to create PR. Create PR with the following command: |
| 107 | +gh pr create --title "Title" --body "Description" |
| 108 | +``` |
| 109 | + |
| 110 | +## Notes |
| 111 | +- Carefully judge unnecessary code to not compromise implementation intent |
| 112 | +- If tests fail, don't hastily fix tests; prioritize verifying implementation correctness |
| 113 | +- Don't automatically create PR; prompt for user's final confirmation |
| 114 | +- **About tmp/ directory**: |
| 115 | + - All intermediate files created by Claude Code (test files, planning documents, etc.) are placed in tmp/ |
| 116 | + - Always perform cleanup when executing +brc |
| 117 | + - Request user confirmation before deletion |
0 commit comments