Implement a fix from investigation artifact - code changes, PR, and self-review
Implements fixes from investigation artifacts, creates PRs, and performs self-reviews.
/plugin marketplace add Wirasm/PRPs-agentic-eng/plugin install prp-core@prp-marketplace<issue-number|artifact-path>Input: $ARGUMENTS
Execute the implementation plan from /prp-issue-investigate:
Golden Rule: Follow the artifact. If something seems wrong, validate it first - don't silently deviate.
If input looks like a number (123, #123):
# Look for artifact
ls .claude/PRPs/issues/issue-{number}.md
If input is a path:
cat {artifact-path}
Extract from artifact:
If artifact not found:
❌ Artifact not found at .claude/PRPs/issues/issue-{number}.md
Run `/prp-issue-investigate {number}` first to create the implementation plan.
PHASE_1_CHECKPOINT:
For each file mentioned in the artifact:
If significant drift detected:
⚠️ Code has changed since investigation:
File: src/x.ts:45
- Artifact expected: {snippet}
- Actual code: {different snippet}
Options:
1. Re-run /prp-issue-investigate to get fresh analysis
2. Proceed carefully with manual adjustments
Ask yourself:
If plan seems wrong:
PHASE_2_CHECKPOINT:
# What branch are we on?
git branch --show-current
# Are we in a worktree?
git rev-parse --show-toplevel
git worktree list
# Is working directory clean?
git status --porcelain
# Are we up to date with remote?
git fetch origin
git status
┌─ IN WORKTREE?
│ └─ YES → Use it (assume it's for this work)
│ Log: "Using worktree at {path}"
│
├─ ON MAIN/MASTER?
│ └─ Q: Working directory clean?
│ ├─ YES → Create branch: fix/issue-{number}-{slug}
│ │ git checkout -b fix/issue-{number}-{slug}
│ └─ NO → Warn user:
│ "Working directory has uncommitted changes.
│ Please commit or stash before proceeding."
│ STOP
│
├─ ON FEATURE/FIX BRANCH?
│ └─ Use it (assume it's for this work)
│ If branch name doesn't contain issue number:
│ Warn: "Branch '{name}' may not be for issue #{number}"
│
└─ DIRTY STATE?
└─ Warn and suggest: git stash or git commit
STOP
# If branch tracks remote
git pull --rebase origin main 2>/dev/null || git pull origin main
PHASE_3_CHECKPOINT:
For each step in the artifact's Implementation Plan:
bun run type-checkDO:
DON'T:
For UPDATE files:
For CREATE files:
For test files:
If you must deviate from the artifact:
PHASE_4_CHECKPOINT:
Execute each command from the artifact's Validation section:
bun run type-check
bun test {pattern-from-artifact}
bun run lint
All must pass before proceeding.
If failures:
Execute any manual verification steps from the artifact.
PHASE_5_CHECKPOINT:
git add -A
git status # Review what's being committed
Format:
Fix: {brief description} (#{issue-number})
{Problem statement from artifact - 1-2 sentences}
Changes:
- {Change 1 from artifact}
- {Change 2 from artifact}
- Added test for {case}
Fixes #{issue-number}
Commit:
git commit -m "$(cat <<'EOF'
Fix: {title} (#{number})
{problem statement}
Changes:
- {change 1}
- {change 2}
Fixes #{number}
EOF
)"
PHASE_6_CHECKPOINT:
git push -u origin HEAD
If branch was rebased:
git push -u origin HEAD --force-with-lease
gh pr create --title "Fix: {title} (#{number})" --body "$(cat <<'EOF'
## Summary
{Problem statement from artifact}
## Root Cause
{Root cause summary from artifact}
## Changes
| File | Change |
|------|--------|
| `src/x.ts` | {description} |
| `src/x.test.ts` | Added test for {case} |
## Testing
- [x] Type check passes
- [x] Unit tests pass
- [x] Lint passes
- [x] {Manual verification from artifact}
## Validation
```bash
bun run type-check && bun test {pattern} && bun run lint
Fixes #{number}
.claude/PRPs/issues/issue-{number}.md
{None | List any deviations}
</details>Automated implementation from investigation artifact EOF )"
### 7.3 Get PR Number
```bash
PR_URL=$(gh pr view --json url -q '.url')
PR_NUMBER=$(gh pr view --json number -q '.number')
PHASE_7_CHECKPOINT:
Use Task tool with subagent_type="code-reviewer":
Review the changes in this PR for issue #{number}.
Focus on:
1. Does the fix address the root cause from the investigation?
2. Code quality - matches codebase patterns?
3. Test coverage - are the new tests sufficient?
4. Edge cases - are they handled?
5. Security - any concerns?
6. Potential bugs - anything that could break?
Review only the diff, not the entire codebase.
gh pr comment --body "$(cat <<'EOF'
## 🔍 Automated Code Review
### Summary
{1-2 sentence assessment}
### Findings
#### ✅ Strengths
- {Good thing 1}
- {Good thing 2}
#### ⚠️ Suggestions (non-blocking)
- `{file}:{line}` - {suggestion}
- {other suggestions}
#### 🔒 Security
- {Any concerns or "No security concerns identified"}
### Checklist
- [x] Fix addresses root cause from investigation
- [x] Code follows codebase patterns
- [x] Tests cover the change
- [x] No obvious bugs introduced
---
*Self-reviewed by Claude • Ready for human review*
EOF
)"
PHASE_8_CHECKPOINT:
mkdir -p .claude/PRPs/issues/completed
mv .claude/PRPs/issues/issue-{number}.md .claude/PRPs/issues/completed/
git add .claude/PRPs/issues/
git commit -m "Archive investigation for issue #{number}"
git push
PHASE_9_CHECKPOINT:
## Implementation Complete
**Issue**: #{number} - {title}
**Branch**: `{branch-name}`
**PR**: #{pr-number} - {pr-url}
### Changes Made
| File | Change |
| --------------- | ------------- |
| `src/x.ts` | {description} |
| `src/x.test.ts` | Added test |
### Validation
| Check | Result |
| ---------- | ------- |
| Type check | ✅ Pass |
| Tests | ✅ Pass |
| Lint | ✅ Pass |
### Self-Review
{Summary of review findings}
### Artifact
📄 Archived to `.claude/PRPs/issues/completed/issue-{number}.md`
### Next Steps
- Human review of PR #{pr-number}
- Merge when approved
/prp-issue-investigate