Skip to content

@tank/bdd-issue-fixer

1.1.0

Resolve GitHub issues using BDD. Triage issues, write Gherkin tests, run RED-GREEN fix cycle (up to 5 iterations), verify with regression checks, submit PR with evidence. Covers triage, issue-to-Gherkin, fix verification, related issue detection, batch fixing. Triggers: fix issue, resolve issue, BDD fix, issue to test, red green fix, triage issue, duplicate issue, related issues, issue fixer, auto-fix, resolve bug report.


name: "@tank/bdd-issue-fixer" description: | Resolve GitHub issues using BDD — read the issue, write a behavioral test, confirm it fails (RED), fix the code, confirm it passes (GREEN), open a PR with test + fix as proof. Covers issue triage (bug vs feature vs invalid vs duplicate), issue-to-Gherkin translation, the relentless RED-GREEN fix cycle, fix verification, PR submission with evidence, and related issue detection. Synthesizes Smart/Molak (BDD in Action), Beck (TDD By Example), Nicieja (Writing Great Specifications), SWE-bench (Princeton NLP), and Sweep.dev patterns.

Trigger phrases: "fix this issue", "resolve issue", "fix GitHub issue", "BDD fix", "issue to test", "write test for issue", "red green fix", "triage issue", "duplicate issue", "related issues", "fix and PR", "issue fixer", "auto-fix issue", "resolve bug report"

BDD Issue Fixer

Hard Rules

These are non-negotiable. Violating any of these means the work is wrong.

  1. Never weaken a test. When a test fails, the CODE is wrong. Fix the code, not the test. Never skip, mock, or reduce assertion precision.

  2. Test behavior, not implementation. The Gherkin scenario captures what the user expects. Write declarative scenarios from the user's perspective, never imperative UI scripts.

  3. Iterate until fixed. Try up to 5 different fix strategies. If approach 1 fails, analyze why and try approach 2. Never give up after one attempt. Escalate only after 5 genuine attempts.

  4. Not every issue deserves a fix. Triage first. Duplicates, questions, invalid reports, and vague wishlists are not fixable issues. Classify before coding.

  5. Document everything. Every fix produces findings, resolutions, and a PR with evidence. The BDD scenario in the PR IS the proof.

Core Workflow

This is the mandatory sequence. Execute in order. Do not skip steps.

1. TRIAGE  →  Read issue, classify, check for duplicates/related
     ↓
2. GHERKIN →  Translate fixable issue into behavioral test
     ↓
3. RED     →  Run test, confirm it fails (bug exists)
     ↓
4. FIX     →  Implement minimal code change
     ↓
5. GREEN?  →  Run test again
     ↓ YES         ↓ NO
6. VERIFY      Back to step 4 (max 5 iterations)
     ↓
7. PR      →  Create PR with test + fix + evidence

Quick-Start

"I have a GitHub issue to fix"

StepAction
1. Read issuegh issue view {N} --json title,body,labels,comments
2. TriageClassify: bug / feature / question / invalid / duplicate. See references/issue-triage.md
3. Check relatedSearch for duplicates and same-root-cause issues. See references/related-issues.md
4. Write GherkinTranslate issue into .bdd/features/{domain}/{slug}.feature. See references/issue-to-gherkin.md
5. RED-GREEN cycleRun test → fix code → run test → repeat until GREEN. See references/red-green-fix-cycle.md
6. VerifyFull suite, no regressions, document findings. See references/fix-verification.md
7. PRBranch, commit (test, fix, docs), push, create PR. See references/pr-and-git-workflow.md

"The issue seems invalid or incomplete"

SignalActionReference
Can't reproduceAsk for clarification with templatereferences/issue-triage.md
User confusion, not a bugAnswer the question, closereferences/issue-triage.md
Same as existing issueLink to original, close as duplicatereferences/related-issues.md
Vague wishlist, no criteriaLabel "needs-discussion", don't fixreferences/issue-triage.md
Requires breaking changesEscalate to maintainerreferences/issue-triage.md

"My fix broke other tests"

SymptomFixReference
Target test passes but other tests failAdjust fix to satisfy both behaviorsreferences/fix-verification.md
Flaky test fails intermittentlyRun 3x — if pre-existing flake, note and move onreferences/fix-verification.md
Type/lint errors in changed filesFix them — never suppress with ts-ignore or rule disablingreferences/fix-verification.md

"Multiple issues seem related"

RelationshipActionReference
Duplicate (same bug)Close duplicate, fix canonicalreferences/related-issues.md
Same root causeWrite Gherkin for ALL, fix root cause oncereferences/related-issues.md
Blocked by another issueFix blocker firstreferences/related-issues.md
Parent-childFix parent, check if child resolvesreferences/related-issues.md

Decision Trees

Should I fix this issue?

SignalDecision
Clear bug with repro stepsFix it
Feature request with acceptance criteriaFix it
Vague report, can infer expected behaviorFix it, note assumptions
No expected behavior, can't inferAsk for clarification
User error or confusionAnswer and close
Duplicate of existing issueClose, link to original
Requires architectural changesEscalate, label "needs-design"
Security vulnerabilityPrivate disclosure, do not fix in public PR

Which fix iteration strategy?

IterationStrategy
1Direct fix — most obvious change
2Root cause analysis — trace the stack trace deeper
3Broader context — read surrounding code, understand data flow
4Alternative approach — different algorithm or code path
5Minimal viable — simplest possible code that makes it work
After 5Escalate — document all attempts, label "needs-human-review"

Commit and PR Structure

Three atomic commits per fix:

CommitContentMessage format
1Gherkin scenario (the failing test)test: add BDD scenario for #{N}
2Code fixfix: {description} (#{N})
3QA documentation (findings + resolution)docs: add QA findings for #{N}

PR body must include: the Gherkin scenario, verification results, iteration count, and Fixes #{N} for auto-close. See references/pr-and-git-workflow.md.

Reference Files

FileContents
references/issue-triage.mdIssue classification, extraction protocol, gh CLI commands, when NOT to fix, clarification templates, priority signals
references/issue-to-gherkin.mdTranslating issues into Gherkin scenarios, bug-to-Gherkin, feature-to-Gherkin, handling vague issues, file placement, quality rules
references/red-green-fix-cycle.mdThe relentless fix loop: RED confirmation, fix strategies per iteration, failure analysis, never-weaken rule, escalation protocol
references/fix-verification.mdPost-fix verification suite, regression handling, findings/resolution documentation format, verification checklist
references/pr-and-git-workflow.mdBranch strategy, 3-commit structure, PR title/body template, gh CLI commands, auto-close keywords, non-fix outcomes
references/related-issues.mdDuplicate detection, same-root-cause clustering, blocked-by chains, batch fixing, gh CLI search patterns

Command Palette

Search skills, docs, and navigate Tank