بنقرة واحدة
code-review
Conduct thorough code reviews for pull requests and pre-commit changes
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Conduct thorough code reviews for pull requests and pre-commit changes
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Run comprehensive project health checks including code quality, documentation, git status, and project structure
Check CI/CD workflow status and troubleshoot failing checks in GitHub Actions
Initialize .docent/ directory structure and configuration for a new project
Comprehensive guide for AI agents on proactive documentation capture using /docent:tell
Migrate a docent v0.9 project to v1.0 skills-based architecture
Review journal entries and extract valuable knowledge into formal documentation
| name | code-review |
| description | Conduct thorough code reviews for pull requests and pre-commit changes |
| group | development |
| keywords | ["code-review","pull-request","quality","pr","review code","code quality"] |
| version | 1.0.0 |
| author | docent |
This runbook provides procedures for reviewing code in two scenarios:
The review process ensures code quality, maintainability, adherence to project standards, and alignment with architectural decisions (ADRs).
Expected duration:
gh CLI (GitHub CLI) - version 2.0 or highergit command line toolBefore starting, ensure:
Use this procedure when reviewing PRs from contributors or reviewing your own PRs before merge.
Purpose: Identify pull requests that need review
Commands:
# List all open PRs
gh pr list --state open
# List PRs assigned to you for review
gh pr list --search "review-requested:@me"
# List PRs by specific author
gh pr list --author <username>
# List PRs with specific label
gh pr list --label "ready-for-review"
Validation:
If step fails:
gh auth statusPurpose: Understand what the PR does and why
Commands:
# View PR in terminal
gh pr view <PR_NUMBER>
# View PR in browser for full experience
gh pr view <PR_NUMBER> --web
# Check PR metadata (labels, reviewers, CI status)
gh pr view <PR_NUMBER> --json title,body,labels,reviews,statusCheckRollup
Review Checklist:
Validation:
If context is missing:
gh pr comment <PR_NUMBER> --body "Thanks for this PR! Could you provide additional context:
- What problem does this solve?
- How did you test this?
- Are there any breaking changes?
This will help with the review process."
Purpose: Ensure automated checks pass before manual review
Commands:
# Check CI status
gh pr checks <PR_NUMBER>
# Watch CI in real-time
gh pr checks <PR_NUMBER> --watch
# View specific check details
gh run view <RUN_ID>
Requirements:
If CI fails:
# Request fixes before continuing review
gh pr comment <PR_NUMBER> --body "The CI checks are failing. Please fix these issues before review:
- [List specific failures]
Once fixed, I'll complete the review."
Do not proceed with detailed review until CI passes - this saves time and ensures baseline quality.
Purpose: Test the changes in your local environment
Commands:
# Check out the PR branch
gh pr checkout <PR_NUMBER>
# Verify you're on the PR branch
git branch --show-current
# Pull latest changes if needed
git pull
Validation:
If step fails:
git stashPurpose: Verify the code works in your environment
Commands:
# Install dependencies (if package.json changed)
npm install
# Run TypeScript build
npm run build
# Run tests
npm test
# Run linting
npm run lint
# Run markdown linting
npm run lint:md
Validation:
If tests fail locally but pass in CI:
node --versionPurpose: Examine the code for quality, style, and maintainability
Commands:
# View all files changed
gh pr diff <PR_NUMBER>
# View diff for specific file
gh pr diff <PR_NUMBER> --name-only
git diff main -- path/to/file.ts
# See full file content
cat path/to/file.ts
Code Quality Checklist:
Red Flags:
Purpose: Ensure changes align with project architecture and decisions
Commands:
# Check relevant ADRs
ls -1 docs/adr/
# Search ADRs for related decisions
grep -r "<topic>" docs/adr/
# View specific ADR
cat docs/adr/adr-NNNN-<topic>.md
Architecture Checklist:
If PR conflicts with ADR:
gh pr comment <PR_NUMBER> --body "This change conflicts with [ADR-NNNN](../adr/adr-NNNN.md) where we decided [decision].
Could you either:
1. Refactor to align with the ADR, OR
2. Make a case for why we should revisit that decision (would require new RFC/ADR)
Happy to discuss approaches!"
Purpose: Ensure changes are properly tested
Commands:
# List test files changed
gh pr diff <PR_NUMBER> --name-only | grep -E 'test|spec'
# View test coverage (if available)
npm test -- --coverage
# Run specific test file
npm test -- path/to/test.ts
Test Quality Checklist:
Test Coverage Requirements:
If tests are inadequate:
gh pr comment <PR_NUMBER> --body "The implementation looks good, but I'd like to see tests for:
- [Specific functionality that needs tests]
- [Edge cases that should be covered]
Tests help ensure this works correctly and prevents regressions."
Purpose: Ensure changes are documented appropriately
Commands:
# Check if docs were updated
gh pr diff <PR_NUMBER> --name-only | grep -E '\.md$|docs/'
# Search for related documentation
grep -r "<feature name>" docs/
Documentation Checklist:
Documentation Requirements:
docs/specs/mcp-tools/If docs are missing:
gh pr comment <PR_NUMBER> --body "This change needs documentation updates:
- [ ] Update README with new feature usage
- [ ] Add JSDoc comments to exported functions
- [ ] Update CHANGELOG.md with breaking changes
Let me know if you need help with any of these!"
Purpose: Give constructive, actionable feedback
Feedback Guidelines:
Commands:
# Add general comment
gh pr comment <PR_NUMBER> --body "Great work on this! I have a few suggestions..."
# For inline comments, use the web interface
gh pr view <PR_NUMBER> --web
# Request changes (blocks merging)
gh pr review <PR_NUMBER> --request-changes --body "Thanks for this PR! Before merging, please address:
## Required Changes
- [ ] Fix error handling in foo.ts:45
- [ ] Add tests for edge case X
- [ ] Update documentation for API change
## Nice-to-have
- Consider extracting duplicate logic to helper function
- Variable naming could be more descriptive
Happy to re-review once these are addressed!"
# Approve with minor comments
gh pr review <PR_NUMBER> --approve --body "Looks great! Just a couple of minor suggestions (non-blocking):
- Consider adding a comment explaining the algorithm in line 45
- Nice refactoring of the error handling!
Approved to merge once CI passes."
# Comment without approving/requesting changes
gh pr review <PR_NUMBER> --comment --body "I have some questions about the approach before I can give a full review:
- Why did you choose approach X over Y?
- How does this handle case Z?
Once clarified, I'll complete the review."
Review Categories:
--approve)--request-changes)--comment)Purpose: Ensure requested changes are addressed
Commands:
# Check if PR was updated
gh pr view <PR_NUMBER>
# See new commits since your review
git log --oneline main..<PR_BRANCH> --since="2 days ago"
# View changes to specific file since review
git diff <OLD_COMMIT> <NEW_COMMIT> -- path/to/file.ts
# Re-run tests with changes
npm test
Follow-up Actions:
If changes look good:
gh pr review <PR_NUMBER> --approve --body "Thanks for addressing the feedback! The changes look good. ✅"
Purpose: Complete the review process
Merge Requirements:
Commands:
# Merge PR (squash commits for clean history)
gh pr merge <PR_NUMBER> --squash --delete-branch
# Merge with merge commit (preserves commit history)
gh pr merge <PR_NUMBER> --merge --delete-branch
# Merge with rebase (linear history)
gh pr merge <PR_NUMBER> --rebase --delete-branch
# Close without merging (if rejecting)
gh pr close <PR_NUMBER> --comment "Thanks for the contribution! Unfortunately, this doesn't align with [reason]. See [alternative approach/issue]."
Merge Strategy for Docent:
Post-Merge:
# Return to main branch
git checkout main
# Pull merged changes
git pull origin main
# Clean up local PR branch
git branch -d <PR_BRANCH>
Use this procedure when reviewing your own changes before committing directly to main.
Purpose: Self-review before committing to main (no PR)
When to use: For small fixes, documentation updates, or when you have direct commit access
Commands:
# 1. Check what's changed
git status
git diff
# 2. Review your own changes
git diff --staged # If already staged
git diff HEAD # All uncommitted changes
# 3. Run automated checks
npm run build # TypeScript compilation
npm test # Run test suite
npm run lint # Linting
npm run lint:md # Markdown linting
# 4. Check for debug code
git diff | grep -E 'console\.log|debugger|TODO|FIXME'
# 5. Verify no secrets
git diff | grep -iE 'password|secret|token|api[_-]?key'
# 6. Check against ADRs (if architectural change)
grep -r "<related topic>" docs/adr/
# 7. Update docs if needed
# - Update README if user-facing
# - Update CHANGELOG.md if notable
# - Add ADR if architectural decision
# 8. Commit with clear message
git add .
git commit -m "feat: add concise doctor output
- Add verbose parameter to doctor tool (default: false)
- Create concise formatter that groups findings
- Show only failures/warnings by default
- Maintain backward compatibility
Closes #2"
Self-Review Questions:
If unsure:
Consider creating a PR even for your own work - gives community visibility and opportunity for feedback.
After completing a review:
For PR Review:
For Pre-Commit Review:
If you need to undo review actions:
# Dismiss your own review (if you change your mind)
# Note: Can only be done via web UI or API
gh pr view <PR_NUMBER> --web
# Navigate to your review and select "Dismiss review"
# If PR was merged incorrectly
gh pr view <PR_NUMBER> --json mergeCommit --jq '.mergeCommit.oid'
# Create revert PR
git revert <MERGE_COMMIT_SHA>
git push origin main
# Or revert via GitHub
gh pr view <PR_NUMBER> --web
# Click "Revert" button
Symptoms:
Resolution:
gh pr comment <PR_NUMBER> --body "I'm having trouble reproducing the bug this fixes. Could you provide:
- Steps to reproduce the original bug
- How to verify the fix works
- Test case that covers this scenario
This will help validate the fix and prevent regressions."
Symptoms:
Resolution:
gh pr comment <PR_NUMBER> --body "This PR is quite large and touches many areas. To make review more effective, could you:
1. Split into smaller PRs (if possible), OR
2. Provide a detailed summary of each major change, OR
3. Schedule a synchronous review session to walk through changes
Large PRs are harder to review thoroughly and more likely to introduce issues."
Symptoms:
Resolution:
# Coordinate with other reviewers
gh pr comment <PR_NUMBER> --body "@reviewer1 @reviewer2 - We have different suggestions on approach. Let's align on one direction:
**Option A (my suggestion):** [Describe]
**Option B (@reviewer1's suggestion):** [Describe]
@author - We'll resolve this and get back to you with aligned feedback."
Escalate to project lead (@tnez) if:
Escalation Method:
gh pr comment <PR_NUMBER> --body "@tnez - Could you weigh in on [specific issue]? Need maintainer input to proceed."
After reviewing a batch of PRs:
Important Notes:
Gotchas:
Related Procedures:
Review Philosophy:
docent values:
| Date | Author | Changes |
|---|---|---|
| 2025-10-20 | @tnez | Initial creation for PR and pre-commit review workflows |
This runbook ensures consistent, thorough code review that maintains quality while being respectful and constructive to contributors.