Prompt
I'm building a code review workflow and want to catch issues earlier
Latest observation
A good way to catch issues earlier in a code review workflow is to shift checks left and make them automatic before a human reviewer ever sees the code.
Here’s a practical setup:
1. Add fast pre-review checks
Run these on every pull request:
- Formatting/linting: Prettier, ESLint, Black, gofmt, etc.
- Type checks: TypeScript, mypy, Rust compiler, etc.
- Unit tests: especially fast, deterministic ones
- Build verification: make sure the app/package compiles
2. Use pre-commit hooks locally
This catches simple problems before code is pushed:
- formatting
- import/order rules
- trailing whitespace / syntax issues
- secret scanning if possible
Tools like pre-commit, Husky, Lefthook, or just simple Git hooks work well.
3. Automate static analysis
Add tools for deeper detection:
- Security scanning: CodeQL, Semgrep, Snyk, Dependabot
- Bug-prone patterns: linters with custom rules
- Complexity checks: cyclomatic complexity, duplication, dead code
- Dependency checks: outdated/vulnerable packages
4. Make CI block merges
Configure your CI so a PR cannot merge unless:
- tests pass
- lint/type checks pass
- security scan passes for defined severity thresholds
- required review approvals are present
5. Standardize PR templates and review checklists
A template can prevent common misses:
- What changed?
- Why?
- How was it tested?
- Any migrations or edge cases?
- Screenshots/logs if relevant
6. Keep PRs small
Smaller changes are easier to review and fail earlier:
- split refactors from behavior changes
- avoid bundling unrelated changes
- aim for focused PRs with one purpose
7. Add “review gates” by risk
For higher-risk changes, require extra checks:
- auth/payment/data migration changes → security review
- critical paths → more tests
- API changes → contract tests
- performance-sensitive code → benchmarks
8. Use code ownership and required reviewers
Auto-request reviewers based on paths using CODEOWNERS, so the right people see changes early.
9. Surface feedback earlier than PR creation
Options:
- draft PRs with CI running early
- run checks in feature branches
- use local dev containers or dev environments that mirror CI
10. Measure what’s being missed
Track:
- defects found in review vs. after merge
- recurring review comments
- CI failures by category
- time-to-detect issues
That helps you tune the workflow and add the highest-value checks.
If you want, I can also help you design a specific end-to-end workflow for GitHub/GitLab/Bitbucket, including the exact checks and merge gates.