| name | pr-review-automation |
| description | Automate PR review workflows: fetch and apply Copilot review suggestions, check/fix broken guard checks (commitlint, PR validation, branch policies), and apply test recommendations. |
PR Review & Guard Check Automation
Overview
This skill automates the common workflow of:
- Fetching AI code review — Pull Copilot review suggestions from active/open PRs
- Applying suggestions — Implement suggested changes with proper testing
- Fixing broken guards — Diagnose and fix commitlint, branch validation, PR title format, and other checks
- Validating changes — Re-run guards to ensure everything passes
Typical workflow:
gh pr view 161 --json comments [fetch Copilot review]
↓
[Analyze suggestions + implement changes]
↓
git commit + git push [push changes]
↓
gh pr view 161 --json statusCheckRollup [verify all checks pass]
Key Operations
1. Fetch Copilot Code Review Comments
Goal: Retrieve AI-generated review suggestions from open PR
Command:
gh pr view <NUMBER> --json comments --jq '.comments[] | select(.author.login | contains("copilot")) | {body, url, state}'
Also check: Review comments (line-level suggestions), not just PR-level comments
gh api repos/{owner}/{repo}/pulls/{number}/comments --jq '.[] | select(.user.login | contains("copilot"))'
Output to check:
- Comment author is
copilot-* bot
- Comment contains
// suggestion: or similar marker
- Line references specific code location
- Suggestion includes rationale
2. Detect & Fix Broken Guard Checks
Common guard checks that fail:
| Guard | Failure Message | Fix |
|---|
| Commitlint | "type must be one of..." | Update commit message type (feat/fix/docs/etc) |
| Validate PR Title | "PR title must match pattern" | Update PR title format (type(scope): subject) |
| Require Issue Reference | "No issue linked" | Link issue in PR description or commit |
| Branch Naming | "Branch must follow pattern" | Rename branch (feature/, fix/, docs/, etc) |
| Prevent Direct Push | "Branch is protected" | Use PR instead of direct push |
Detection strategy:
gh pr view <NUMBER> --json statusCheckRollup --jq '.statusCheckRollup[] | select(.conclusion != "SUCCESS" and .conclusion != "SKIPPED")'
gh run list --status failure --branch <branch> --limit 1 --json databaseId,conclusion
Fix strategies:
Commitlint Fix
git log --oneline HEAD~3..HEAD | head -1
git commit --amend --message "fix(scope): new message"
git push --force-with-lease
PR Title Format
gh pr edit <NUMBER> --title "feat(scope): description here"
Link Issue
gh pr edit <NUMBER> --add-assignee @me
3. Apply Copilot Suggestions
Workflow:
-
Parse suggestion from comment
- Extract code location (file, line range)
- Extract intended change
- Identify type (assert strengthening, mock improvement, documentation, etc)
-
Apply programmatically or manually
git checkout <BRANCH>
git add .
git commit -m "review(scope): apply Copilot suggestion — [brief description]"
git push
-
Test & validate
pytest tests/...
ruff check .
mypy .
-
Verify guard checks pass
gh pr view <NUMBER> --json statusCheckRollup --jq '.statusCheckRollup[] | select(.conclusion != "SUCCESS" and .conclusion != "SKIPPED")'
Execution Checklist
Before applying suggestions:
During implementation:
After pushing:
For guard check failures:
Example: Complete Workflow
Scenario: PR #161 with 3 Copilot suggestions + commitlint failure
Step 1: Fetch suggestions
gh pr view 161 --json comments,reviews \
--jq '.reviews[] | select(.author.login | contains("copilot"))'
Step 2: Identify guard failure
gh pr view 161 --json statusCheckRollup \
--jq '.statusCheckRollup[] | select(.conclusion != "SUCCESS" and .conclusion != "SKIPPED")'
Step 3: Fix commitlint
git log --oneline -1
git commit --amend --message "test(sagaz): apply Copilot suggestion — strengthen assertions"
git push --force-with-lease
Step 4: Apply suggestions (3 separate commits)
git add tests/...
git commit -m "review(tests): add Redis type validation to default URL test"
git add tests/...
git commit -m "review(tests): assert InMemorySagaStorage on empty URL fallback"
git add tests/...
git commit -m "review(tests): clarify _parse_storage_url behavior in test docstring"
git push
Step 5: Verify all checks pass
gh pr view 161 --json statusCheckRollup | grep -c "SUCCESS"
Anti-Patterns to Avoid
❌ Don't:
- Apply suggestions without reading them carefully (may be incorrect context)
- Mix multiple unrelated suggestions in one commit
- Ignore commitlint failures (signal of bigger PR mismatch)
- Force-push without
--force-with-lease (risky in team settings)
- Apply test suggestions without running full test suite
✅ Do:
- Review each Copilot suggestion in context before applying
- Use atomic, well-described commits for traceability
- Fix guard checks immediately when they fail
- Always test locally before pushing
- Use
--force-with-lease when amending committed work
Related PR Policies
This skill complements the development-policy skill:
- Commitlint types must be from approved list:
feat|fix|docs|refactor|test|perf|build|ci|chore|revert
- PR titles must match
type(scope): subject format
- Scope must be non-empty and match approved project scopes
- Subject must not use sentence case or end with period
- Issues must be referenced in PR description or commit message
See .github/skills/development-policy/SKILL.md for full policy.
Quick Reference Commands
gh pr view <NUMBER> --json comments --jq '.comments[] | select(.author.login | contains("copilot"))'
gh pr view <NUMBER> --json statusCheckRollup --jq '.statusCheckRollup[] | select(.conclusion != "SUCCESS" and .conclusion != "SKIPPED")'
git log --format="%h %s" | head -10
git commit --amend --message "fix(scope): corrected message"
git push --force-with-lease
pytest tests/ -x
ruff check .