Create and implement a bug fix linked to an original feature
Creates a bug fix linked to an original feature and implements it using an agentic loop.
/plugin marketplace add panayiotism/claude-harness/plugin install claude-harness@claude-harnessCreate a bug fix linked to an original feature and implement it using the agentic loop:
Arguments: $ARGUMENTS
Bug fixes are linked to their original features for context. They share memory,
verification commands, and contribute learnings back to the feature's knowledge base.
Commits use fix: prefix for proper PATCH versioning.
Parse arguments:
Validate feature exists:
.claude-harness/features/active.json features array.claude-harness/features/archive.json archived arrayGenerate fix ID:
.claude-harness/features/active.json fixes arrayfix-{feature-id}-{sequential-number} (3 digits, zero-padded)fix-feature-001-001, fix-feature-001-002Generate branch name:
fix/{feature-id}-{slug}fix/feature-001-token-expiryInherit verification commands:
inherited: true in verificationCreate GitHub issue:
fix: {bug description}## Bug Report: {bug description}
### Related Feature
- Feature: #{original-issue-number} - {feature-name}
- Original Branch: `{original-feature-branch}`
### Bug Description
{user-provided description}
### Affected Files
{list of relatedFiles from original feature}
### Verification Checklist
- [ ] Build passes
- [ ] Tests pass
- [ ] Lint passes
- [ ] Typecheck passes
- [ ] Bug is resolved
- [ ] Regression tests added (if applicable)
---
_This fix is linked to #{original-issue-number}_
["bugfix", "claude-harness", "linked-to:{feature-id}"]Add comment to original feature issue:
Bug fix created: #{new-issue-number} - {bug description}Create and checkout branch:
fix/{feature-id}-{slug}.claude-harness/features/active.json fixes array:
{
"id": "fix-{feature-id}-{NNN}",
"name": "{bug description}",
"description": "{full description}",
"linkedTo": {
"featureId": "{original-feature-id}",
"featureName": "{original-feature-name}",
"issueNumber": {original-issue-number}
},
"type": "bugfix",
"status": "pending",
"phase": "implementation",
"verification": {
"build": "{inherited or override}",
"tests": "{inherited or override}",
"lint": "{inherited or override}",
"typecheck": "{inherited or override}",
"custom": [],
"inherited": true
},
"attempts": 0,
"maxAttempts": 10,
"relatedFiles": ["{inherited from original}"],
"github": {
"issueNumber": {new-issue-number},
"prNumber": null,
"branch": "fix/{feature-id}-{slug}"
},
"createdAt": "{ISO timestamp}",
"updatedAt": "{ISO timestamp}"
}
Query procedural memory for original feature:
.claude-harness/memory/procedural/failures.json
feature matches original feature IDlinkedTo matches original feature ID.claude-harness/memory/procedural/successes.json
Compile fix context:
Display context summary:
┌─────────────────────────────────────────────────────────────────┐
│ FIX CONTEXT: {fix-id} │
│ Linked to: {feature-name} (#{original-issue}) │
├─────────────────────────────────────────────────────────────────┤
│ Previous learnings for this feature: │
│ ✓ {N} successful approaches │
│ ✗ {N} failed approaches to avoid │
│ Files commonly affected: {file list} │
└─────────────────────────────────────────────────────────────────┘
.claude-harness/loops/state.json:
{
"version": 3,
"feature": "{fix-id}",
"featureName": "{bug description}",
"type": "fix",
"linkedTo": {
"featureId": "{original-feature-id}",
"featureName": "{original-feature-name}"
},
"status": "in_progress",
"attempt": 1,
"maxAttempts": 10,
"startedAt": "{ISO timestamp}",
"lastAttemptAt": null,
"verification": {
"build": "{command}",
"tests": "{command}",
"lint": "{command}",
"typecheck": "{command}",
"custom": []
},
"history": [],
"lastCheckpoint": null,
"escalationRequested": false
}
Celebration and update:
┌─────────────────────────────────────────────────────────────────┐
│ ✅ FIX VERIFIED │
├─────────────────────────────────────────────────────────────────┤
│ Build: ✅ PASSED │
│ Tests: ✅ PASSED │
│ Lint: ✅ PASSED │
│ Typecheck: ✅ PASSED │
├─────────────────────────────────────────────────────────────────┤
│ Fix complete in {n} attempts! │
│ Linked to: {feature-name} │
└─────────────────────────────────────────────────────────────────┘
Update fix status:
Record to procedural memory:
.claude-harness/memory/procedural/successes.json:
{
"id": "{uuid}",
"timestamp": "{ISO timestamp}",
"feature": "{fix-id}",
"type": "fix",
"linkedTo": "{original-feature-id}",
"approach": "{what worked}",
"files": ["{modified files}"],
"verificationResults": {
"build": "passed",
"tests": "passed",
"lint": "passed",
"typecheck": "passed"
},
"patterns": ["{reusable patterns discovered}"]
}
Create git commit:
git add -Afix({original-feature-id}): {bug description}
{Brief description of the fix}
Verification passed:
- Build: ✅
- Tests: ✅
- Lint: ✅
- Typecheck: ✅
Fixes #{fix-issue-number}
Related to #{original-issue-number}
Update loop state:
Report success and next steps:
/claude-harness:checkpoint to push and create PRRecord failure:
.claude-harness/memory/procedural/failures.json:
{
"id": "{uuid}",
"timestamp": "{ISO timestamp}",
"feature": "{fix-id}",
"type": "fix",
"linkedTo": "{original-feature-id}",
"attempt": {n},
"approach": "{what was tried}",
"files": ["{affected files}"],
"errors": ["{error messages}"],
"rootCause": "{analysis of why it failed}",
"tags": ["{error-type}", "{category}"],
"prevention": "{how to avoid in future}"
}
Increment attempt and retry or escalate:
Update fix status to "escalated"
Generate escalation report:
┌─────────────────────────────────────────────────────────────────┐
│ ⚠️ FIX ESCALATION REQUIRED │
├─────────────────────────────────────────────────────────────────┤
│ Fix: {fix-id} │
│ Linked to: {feature-name} │
│ Max attempts ({maxAttempts}) reached without success │
│ │
│ Attempts Summary: │
│ 1. {approach} → {error summary} │
│ 2. {approach} → {error summary} │
│ ... │
│ │
│ Recurring Issues: │
│ - {pattern of failures} │
│ │
│ Recommendation: │
│ {suggested manual intervention or alternative approach} │
└─────────────────────────────────────────────────────────────────┘
Fix loop state persists in .claude-harness/loops/state.json across sessions.
SessionStart hook will display:
┌─────────────────────────────────────────────────────────────────┐
│ 🔧 ACTIVE FIX: {fix-id} (attempt {n}/{max}) │
│ Linked to: {feature-name} │
│ Last: "{approach summary}" → {result} │
│ Resume: /claude-harness:implement {fix-id} │
└─────────────────────────────────────────────────────────────────┘
Running /claude-harness:implement {fix-id} resumes the fix loop.
/claude-harness:fix feature-001 "Bug description"/claude-harness:implement fix-feature-001-001/claude-harness:fix feature-001 "Bug" --test-pattern="auth"/claude-harness:fix feature-001 "Bug" --verify="npm run test:auth"/claude-harness:fix feature-001 "Bug" --max-attempts=20