forge-reflect-pr
npx skills add https://github.com/mgratzer/forge --skill forge-reflect-pr
Agent 安装分布
Skill 文档
Reflect on PR
Review the current PR branch for cleanup opportunities before finalizing.
When to Use
Run this after completing the main implementation work on a PR, before requesting review.
Process
Step 1: Identify Changed Files
# Detect the default branch, then get list of changed files
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
git diff --name-only $DEFAULT_BRANCH...HEAD
Step 2: Check for Refactoring Opportunities
For each changed file, assess:
- Code duplication: Are there repeated patterns that should be extracted?
- Function size: Are any functions too long and should be split?
- Naming: Are variable/function names clear and consistent?
- Abstractions: Is logic in the right layer (routes vs services vs repositories)?
- Dead code: Any unused imports, variables, or functions introduced?
- Pattern consistency: If a pattern was changed in this PR (error handling, component structure, API call convention), are ALL files using that pattern updated? Search for remaining instances:
grep -rn "<changed-pattern>" src/
Step 3: Check Environment and Configuration
Review changes for configuration correctness:
- New environment variables â Are they documented (e.g., in
.env.exampleor equivalent)? - Configuration placement â Are settings placed where they’re consumed? (runtime config vs build config vs compile-time constants)
- External service dependencies â Are new integrations noted? Are credentials properly handled (not hardcoded)?
- Deployment needs â Do changes require manual steps not yet captured in the PR description?
Step 4: Assess Test Coverage
- For each new/modified module, check if corresponding
.test.tsfile exists - Run coverage on changed files:
# Run the project's coverage command with a path filter (check package.json for the exact script) # e.g.: npm run test:coverage -- --testPathPattern="<pattern>" - Identify untested code paths, especially:
- Error handling branches
- Edge cases
- New public functions/methods
Step 5: Review Documentation
Check if any of these need updates based on changes made:
-
/docs/*.md– Architecture, API reference, development guides# Search for references to changed functionality grep -r "<feature-keyword>" docs/ -
CLAUDE.md– Project conventions, patterns, quick reference- New patterns or conventions established?
- New scripts or commands added?
- Architecture changes?
-
Code comments – Outdated comments in changed files?
- Search for dimension references, format mentions, etc.
grep -rn "<old-value>" src/ -
JSDoc/TSDoc – Public function documentation accurate?
Step 6: Cleanup Checklist
Verify:
- No
console.logdebugging statements left - No commented-out code that should be removed
- No TODO comments that should be addressed now
- Import statements are clean (no unused imports)
- No hardcoded values that should be constants
- Error messages are user-friendly and actionable
Step 7: Run Quality Gates
Run the project’s quality check commands. Discover available scripts from CLAUDE.md or package.json. Typical checks include lint/format, type checking, and tests.
Step 8: Report Findings
Provide a summary of:
- Refactoring done (if any)
- Tests added (if any)
- Documentation updated (if any)
- Items deferred – Valid improvements that should be separate PRs/issues
For each deferred item, create a GitHub issue â do not leave deferred items as untracked notes:
gh issue create --title "<title>" --body "<description>"
Output Format
## PR Reflection Summary
### Refactoring
- [x] Extracted `<function>` to reduce duplication
- [ ] No refactoring needed
### Tests
- [x] Added tests for `<module>`
- [ ] Coverage adequate for changes
### Documentation
- [x] Updated `docs/api-reference.md` with new endpoint
- [x] Fixed outdated comments in `<file>`
- [ ] No documentation updates needed
### Cleanup
- [x] Removed debug logging
- [x] Fixed lint warnings
- [ ] No cleanup needed
### Deferred Items
- Created issue #<num>: <title> (required for every deferred item)
- None identified
Related Skills
Before: Use forge-implement-issue to implement the feature/fix.
After review: Use forge-address-pr-feedback to address reviewer feedback.
Full workflow: forge-setup-project â forge-create-issue â forge-implement-issue â forge-reflect-pr â forge-address-pr-feedback â forge-update-changelog
Example Usage
/forge-reflect-pr