No. 096 Review the diff

Pre-Review Checklist

Use when a diff needs a second pass that stops at findings

  • Claude Code
  • Codex
  • Cursor
  • Review the diff

Prompt

# Pre-Review Checklist

Please help me ensure my code is ready for review.

PR/Branch: ${PR_BRANCH:-current branch}
Focus areas: ${FOCUS_AREAS:-all changes}

## Quality Checks

1. **Find and fix debug code**:
   ```bash
   # Find TODOs that need addressing
   ch cq todos --with-context
   
   # Remove debug logs
   ch cq console-logs
   
   # Check for commented code
   chs find-code "^\\s*//.*\\b(console|debug|test)" 
   ```

2. **Check code quality metrics**:
   ```bash
   # Find overly large files
   ch cq large-files ${MAX_LINES:-500}
   
   # Check complexity
   ch cq complexity ${MAX_COMPLEXITY:-10}
   
   # Look for duplicated code patterns
   chs find-code "$PATTERN" --count
   ```

3. **Security scan**:
   ```bash
   # Scan for hardcoded secrets
   ch cq secrets-scan
   
   # Check for sensitive data in logs
   chs find-code "password|token|secret|key" --exclude .env
   ```

4. **Verify test coverage**:
   ```bash
   # Find untested files
   if ! git diff --name-only origin/main...HEAD 2>/dev/null | while IFS= read -r f; do
     echo "Checking tests for: $f"
     chs find-file "*.test.*" | xargs grep -l "$(basename "$f" .js)" 2>/dev/null || echo "  No tests found for $f"
   done; then
     echo "Note: Could not compare with origin/main"
   fi
   
   # Run tests
   ch ts test
   ```

5. **Check dependencies**:
   ```bash
   # Audit for vulnerabilities
   ch ts audit
   
   # Check for unused dependencies
   ch ts deps --check-unused
   ```

6. **Documentation check**:
   - Are new functions documented?
   - Is the README updated if needed?
   - Are breaking changes noted?

## PR Preparation

1. **Generate context for reviewers**:
   ```bash
   # Create summary
   ch ctx summarize > PR_CONTEXT.md
   
   # Show what changed
   git diff --stat origin/main...HEAD
   ```

2. **Check commit history**:
   ```bash
   # Review commits
   git log --oneline origin/main..HEAD
   
   # Consider squashing if needed
   ```

3. **Update PR if exists**:
   ```bash
   # Check if PR exists
   PR_NUMBER=$(gh pr list --head "$(git branch --show-current)" --json number -q ".[0].number")
   
   if [ -n "$PR_NUMBER" ]; then
     # Update PR description with context
     gh pr edit "$PR_NUMBER" --body "$(gh pr view "$PR_NUMBER" --json body -q .body)\n\n## Review Context\n\n$(cat PR_CONTEXT.md)"
     
     # Mark as ready if it's a draft
     gh pr ready "$PR_NUMBER" 2>/dev/null || echo "PR already ready for review"
     
     # Add review request if needed
     gh pr edit "$PR_NUMBER" --add-reviewer "${REVIEWER:-@me}"
   else
     echo "No PR found. Create one with: gh pr create"
   fi
   ```

## Final Checklist

- [ ] All debug code removed
- [ ] No hardcoded secrets
- [ ] Tests pass locally
- [ ] New code has tests
- [ ] Documentation updated
- [ ] No generated files committed
- [ ] Commit messages are clear
- [ ] PR description is complete

Please review my changes and confirm they meet quality standards.

When to use

“Pre-Review Checklist” fits when a diff needs a second pass that stops at findings, because it says “Pre-Review Checklist”, and its first written step is “Find and fix debug code:”.

For “Pre-Review Checklist”, the extra line you type is the requirement those steps ask for, for example “make src/cart.js return 0 on an empty cart and skip a line with no price”, and the file then starts at “Find and fix debug code:”.

When not to use

Leave “Pre-Review Checklist” unused when you wanted the fix applied in the same turn, because “Pre-Review Checklist” points the other way

How to run it

Claude Code

Claude Code stores “Pre-Review Checklist” as a Claude command and runs it with that command, putting the requirement in the argument, and CLAUDE.md should not also carry “Pre-Review Checklist”.

Codex

Codex takes “Pre-Review Checklist” as a paste above the task. Leave AGENTS.md unchanged so the next thread does not inherit “Pre-Review Checklist”.

Cursor

Cursor should see “Pre-Review Checklist” only as a chat paste of “Pre-Review Checklist” for this turn. A file at .cursor/rules would keep applying after the turn ends.

Comparison

Without “Pre-Review Checklist”, the run printed only the corrected function and defaulted a missing qty to 0. With “Pre-Review Checklist”, it filled the checklist, marked tests as not run, and said the ch and git steps could not be executed in this session.

Related

来源:Darin Cassler · https://github.com/cassler/awesome-claude-code-setup/blob/main/commands/pre-review-check.md · MIT · Copyright (c) 2025 Darin Cassler · 2026-12-01