|
| 1 | +# Automated Code Review System - Setup Complete |
| 2 | + |
| 3 | +## What Was Created |
| 4 | + |
| 5 | +### 1. Auto-Accept Permissions |
| 6 | +**File**: `.claude/settings.json` |
| 7 | + |
| 8 | +All permissions for the following are auto-accepted: |
| 9 | +- `Bash` tool (for git, Maven, scripts) |
| 10 | +- `Write`, `Edit`, `Read` tools |
| 11 | +- `TaskCreate`, `TaskUpdate`, `TaskList`, `TaskGet` |
| 12 | +- Patterns for common operations: git commands, Maven, gh CLI, script execution |
| 13 | + |
| 14 | +### 2. Code Review Scripts |
| 15 | +**Directory**: `.claude/scripts/` |
| 16 | + |
| 17 | +#### `code_review.sh` |
| 18 | +Runs 6 different code quality checks: |
| 19 | +1. **Checkstyle** - Code style violations |
| 20 | +2. **PMD** - Code quality issues |
| 21 | +3. **SpotBugs** - Potential bugs |
| 22 | +4. **OWASP Dependency Check** - Security vulnerabilities |
| 23 | +5. **TODO/FIXME Scanner** - Tracks technical debt |
| 24 | +6. **Security Pattern Scan** - Finds risky patterns (System.out, printStackTrace, etc.) |
| 25 | + |
| 26 | +#### `create_github_issues.py` |
| 27 | +- Parses review outputs |
| 28 | +- Creates GitHub issues automatically |
| 29 | +- Prevents duplicates |
| 30 | +- Labels with `automated-review` |
| 31 | +- Adds security labels for security findings |
| 32 | + |
| 33 | +#### `auto_fix_and_push.sh` |
| 34 | +- Stages all changes |
| 35 | +- Creates commit with descriptive message |
| 36 | +- Pushes to main branch |
| 37 | +- Includes Claude co-author attribution |
| 38 | + |
| 39 | +#### `review_loop.sh` (Main Script) |
| 40 | +- Runs review → create issues → wait 10 minutes → repeat |
| 41 | +- Stops after 2 consecutive clean iterations |
| 42 | +- Fully automated |
| 43 | + |
| 44 | +### 3. Documentation |
| 45 | +- `README.md` in scripts directory |
| 46 | +- This setup guide |
| 47 | + |
| 48 | +## How to Use |
| 49 | + |
| 50 | +### Start the Automated Review Loop |
| 51 | +```bash |
| 52 | +cd /home/sfloess/Development/github/FlossWare/platform-java |
| 53 | +./.claude/scripts/review_loop.sh |
| 54 | +``` |
| 55 | + |
| 56 | +This will: |
| 57 | +1. Run all 6 code quality checks |
| 58 | +2. Parse outputs and create GitHub issues |
| 59 | +3. Wait 10 minutes |
| 60 | +4. Repeat until clean for 2 iterations |
| 61 | + |
| 62 | +### Manual Operations |
| 63 | + |
| 64 | +Run just the review: |
| 65 | +```bash |
| 66 | +./.claude/scripts/code_review.sh |
| 67 | +``` |
| 68 | + |
| 69 | +Create issues from existing review: |
| 70 | +```bash |
| 71 | +python3 ./.claude/scripts/create_github_issues.py |
| 72 | +``` |
| 73 | + |
| 74 | +Commit and push current changes: |
| 75 | +```bash |
| 76 | +./.claude/scripts/auto_fix_and_push.sh |
| 77 | +``` |
| 78 | + |
| 79 | +## Integration Points |
| 80 | + |
| 81 | +### GitHub |
| 82 | +- Uses `gh` CLI for issue creation |
| 83 | +- Creates issues in `FlossWare/platform-java` |
| 84 | +- All issues labeled `automated-review` |
| 85 | +- Security issues also get `security` label |
| 86 | + |
| 87 | +### Maven |
| 88 | +Uses these plugins (already configured in `pom.xml`): |
| 89 | +- `maven-checkstyle-plugin` |
| 90 | +- `maven-pmd-plugin` |
| 91 | +- `spotbugs-maven-plugin` |
| 92 | +- `dependency-check-maven-plugin` |
| 93 | + |
| 94 | +### Git |
| 95 | +- Auto-commits with descriptive messages |
| 96 | +- Pushes to `main` branch |
| 97 | +- Co-authored by Claude Sonnet 4.5 |
| 98 | + |
| 99 | +## Review Output Location |
| 100 | + |
| 101 | +All review outputs saved to: `.claude/review-output/` |
| 102 | + |
| 103 | +Files created: |
| 104 | +- `checkstyle.txt` |
| 105 | +- `pmd.txt` |
| 106 | +- `spotbugs.txt` |
| 107 | +- `dependency-check.txt` |
| 108 | +- `todos.txt` |
| 109 | +- `security-patterns.txt` |
| 110 | + |
| 111 | +## Stop Conditions |
| 112 | + |
| 113 | +The loop stops when: |
| 114 | +1. **Success**: No issues found for 2 consecutive iterations |
| 115 | +2. **Manual**: User presses Ctrl+C |
| 116 | + |
| 117 | +## Next Steps |
| 118 | + |
| 119 | +### To Start the Review Process: |
| 120 | +```bash |
| 121 | +# Start the automated review loop |
| 122 | +./.claude/scripts/review_loop.sh |
| 123 | +``` |
| 124 | + |
| 125 | +### To Fix Issues Created: |
| 126 | +Claude will: |
| 127 | +1. Read the GitHub issues created by the script |
| 128 | +2. Fix the issues in the code |
| 129 | +3. Use `auto_fix_and_push.sh` to commit and push |
| 130 | +4. Loop continues until clean |
| 131 | + |
| 132 | +### To Monitor Progress: |
| 133 | +```bash |
| 134 | +# Check review outputs |
| 135 | +ls -lh .claude/review-output/ |
| 136 | + |
| 137 | +# Check GitHub issues |
| 138 | +gh issue list --label automated-review |
| 139 | + |
| 140 | +# Watch git log |
| 141 | +git log --oneline -10 |
| 142 | +``` |
| 143 | + |
| 144 | +## Configuration Notes |
| 145 | + |
| 146 | +- All scripts are executable |
| 147 | +- Python script requires Python 3.6+ |
| 148 | +- GitHub CLI must be authenticated (`gh auth login`) |
| 149 | +- Maven must be available on PATH |
| 150 | +- Git must be configured with user name/email |
| 151 | + |
| 152 | +## Workflow Summary |
| 153 | + |
| 154 | +``` |
| 155 | +┌─────────────────┐ |
| 156 | +│ Review Loop │ |
| 157 | +│ (Every 10m) │ |
| 158 | +└────────┬────────┘ |
| 159 | + │ |
| 160 | + ▼ |
| 161 | +┌─────────────────┐ |
| 162 | +│ code_review.sh │ ← Runs 6 checks |
| 163 | +└────────┬────────┘ |
| 164 | + │ |
| 165 | + ▼ |
| 166 | +┌─────────────────────┐ |
| 167 | +│ create_github_ │ ← Parses outputs |
| 168 | +│ issues.py │ Creates issues |
| 169 | +└────────┬────────────┘ |
| 170 | + │ |
| 171 | + ▼ |
| 172 | +┌─────────────────────┐ |
| 173 | +│ Claude reads issues │ |
| 174 | +│ and fixes code │ |
| 175 | +└────────┬────────────┘ |
| 176 | + │ |
| 177 | + ▼ |
| 178 | +┌─────────────────────┐ |
| 179 | +│ auto_fix_and_push.sh│ ← Commits & pushes |
| 180 | +└────────┬────────────┘ |
| 181 | + │ |
| 182 | + ▼ |
| 183 | +┌─────────────────────┐ |
| 184 | +│ Wait 10 minutes │ |
| 185 | +└────────┬────────────┘ |
| 186 | + │ |
| 187 | + └──────► (Repeat until clean) |
| 188 | +``` |
| 189 | + |
| 190 | +## Customization |
| 191 | + |
| 192 | +### Change Review Interval |
| 193 | +Edit `review_loop.sh`, line with `sleep 600` (600 seconds = 10 minutes) |
| 194 | + |
| 195 | +### Change Stop Condition |
| 196 | +Edit `review_loop.sh`, line with `if [ $NO_ISSUES_COUNT -ge 2 ]` (currently 2 clean iterations) |
| 197 | + |
| 198 | +### Add More Checks |
| 199 | +Edit `code_review.sh` to add more Maven goals or custom checks |
| 200 | + |
| 201 | +### Modify Issue Labels |
| 202 | +Edit `create_github_issues.py`, variables `ISSUE_LABEL` and `ISSUE_PREFIX` |
| 203 | + |
| 204 | +## Troubleshooting |
| 205 | + |
| 206 | +### GitHub CLI Not Authenticated |
| 207 | +```bash |
| 208 | +gh auth login |
| 209 | +``` |
| 210 | + |
| 211 | +### Maven Commands Failing |
| 212 | +```bash |
| 213 | +# Test Maven is working |
| 214 | +mvn --version |
| 215 | + |
| 216 | +# Run a clean build first |
| 217 | +mvn clean install |
| 218 | +``` |
| 219 | + |
| 220 | +### Permission Issues |
| 221 | +All permissions are auto-accepted in `.claude/settings.json` |
| 222 | + |
| 223 | +### Review Outputs Empty |
| 224 | +Check that Maven plugins are configured in `pom.xml` |
0 commit comments