|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Ready to Review is a macOS/Linux/Windows menubar application that helps developers track GitHub pull requests. It shows a count of incoming/outgoing PRs and highlights when you're blocking someone's review. The app integrates with the Turn API to provide intelligent PR metadata about who's actually blocking progress. |
| 8 | + |
| 9 | +## Key Commands |
| 10 | + |
| 11 | +### Building and Running |
| 12 | +```bash |
| 13 | +make run # Build and run (on macOS: installs to /Applications and launches) |
| 14 | +make build # Build for current platform |
| 15 | +make app-bundle # Create macOS .app bundle |
| 16 | +make install # Install to system (macOS: /Applications, Linux: /usr/local/bin, Windows: %LOCALAPPDATA%) |
| 17 | +``` |
| 18 | + |
| 19 | +### Development |
| 20 | +```bash |
| 21 | +make lint # Run all linters (golangci-lint with strict config + yamllint) |
| 22 | +make fix # Auto-fix linting issues where possible |
| 23 | +make deps # Download and tidy Go dependencies |
| 24 | +make clean # Remove build artifacts |
| 25 | +``` |
| 26 | + |
| 27 | +## Architecture Overview |
| 28 | + |
| 29 | +### Core Components |
| 30 | + |
| 31 | +1. **Main Application Flow** (`main.go`) |
| 32 | + - Single `context.Background()` created in main, passed through all functions |
| 33 | + - App struct holds GitHub/Turn clients, PR data, and UI state |
| 34 | + - Update loop runs every 2 minutes to refresh PR data |
| 35 | + - Menu updates only rebuild when PR data actually changes (hash-based optimization) |
| 36 | + |
| 37 | +2. **GitHub Integration** (`github.go`) |
| 38 | + - Uses GitHub CLI token (`gh auth token`) for authentication |
| 39 | + - Fetches PRs with a single optimized query: `is:open is:pr involves:USER archived:false` |
| 40 | + - No pagination needed (uses 100 per page limit) |
| 41 | + |
| 42 | +3. **Turn API Integration** (`cache.go`) |
| 43 | + - Provides intelligent PR metadata (who's blocking, PR size, tags) |
| 44 | + - Implements 2-hour TTL cache with SHA256-based cache keys |
| 45 | + - Cache cleanup runs daily, removes files older than 5 days |
| 46 | + - Turn API calls are made for each PR to determine blocking status |
| 47 | + |
| 48 | +4. **UI Management** (`ui.go`) |
| 49 | + - System tray integration via energye/systray |
| 50 | + - Menu structure: Incoming PRs → Outgoing PRs → Settings → About |
| 51 | + - Click handlers open PRs in browser with URL validation |
| 52 | + - "Hide stale PRs" option filters PRs older than 90 days |
| 53 | + |
| 54 | +5. **Platform-Specific Features** |
| 55 | + - `loginitem_darwin.go`: macOS "Start at Login" functionality via AppleScript |
| 56 | + - `loginitem_other.go`: Stub for non-macOS platforms |
| 57 | + |
| 58 | +### Key Design Decisions |
| 59 | + |
| 60 | +- **No Context in Structs**: Context is always passed as a parameter, never stored |
| 61 | +- **Graceful Degradation**: Turn API failures don't break the app, PRs still display |
| 62 | +- **Security**: Only HTTPS URLs allowed, whitelist of github.com and dash.ready-to-review.dev |
| 63 | +- **Minimal Dependencies**: Uses standard library where possible |
| 64 | +- **Proper Cancellation**: All goroutines respect context cancellation |
| 65 | + |
| 66 | +### Linting Configuration |
| 67 | + |
| 68 | +The project uses an extremely strict golangci-lint configuration (`.golangci.yml`) that enforces: |
| 69 | +- All available linters except those that conflict with Go best practices |
| 70 | +- No nolint directives without explanations |
| 71 | +- Cognitive complexity limit of 55 |
| 72 | +- No magic numbers (must use constants) |
| 73 | +- Proper error handling (no unchecked errors) |
| 74 | +- No naked returns except in very short functions |
| 75 | +- Field alignment optimization for structs |
| 76 | + |
| 77 | +### Special Considerations |
| 78 | + |
| 79 | +1. **Authentication**: Uses GitHub CLI token, never stores it persistently |
| 80 | +2. **Caching**: Turn API responses cached to reduce API calls |
| 81 | +3. **Menu Updates**: Hash-based change detection prevents unnecessary UI updates |
| 82 | +4. **Context Handling**: Single context from main, proper cancellation in all goroutines |
| 83 | +5. **Error Handling**: All errors wrapped with context using `fmt.Errorf` with `%w` |
| 84 | + |
| 85 | +When making changes: |
| 86 | +- Run `make lint` and fix all issues without adding nolint directives |
| 87 | +- Follow the strict Go style guidelines in ~/.claude/CLAUDE.md |
| 88 | +- Keep functions simple and focused |
| 89 | +- Test macOS-specific features carefully (login items, app bundle) |
0 commit comments