Fetches a bug ticket, reproduces it with a failing test, implements the fix, reviews, and publishes a PR. Runs end-to-end TDD with planner, implementer, and reviewer agents.
Ships in factory-fix. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
An optional playbook: a suggested order for taking a bug from ticket to a merge-ready draft PR without pausing for approval at each step. The task's objective, the repo's own instructions and the board's policy come first; use the steps that fit and skip the ones that do not. It stops for exactly two things: an infrastructure blocker it cannot fix, and a genuine contradiction (Step 7).
The order is a suggestion, not a graph. Go back whenever the evidence says so — a red gate, a review finding, a ticket comment you missed, a wrong module — and redo the steps that revision invalidates. Evidence from before a revision (a green gate, a clean review) does not carry over: rerun what the change touched before you publish or finish. What is required is policy, and the board enforces it whatever this playbook says: the declared gates over the final tree, the publication rules, the credentials you are given. This file only suggests how to meet them.
Everything here is stack-agnostic. Discover the project's conventions first (Step 0) and use them — the commands in this skill are placeholders, not literals.
command -v factory-gate succeeds → a Bellows task: follow this file alone. Otherwise → a
developer machine (LOCAL): also read ${CLAUDE_PLUGIN_ROOT}/factory-fix/local.md; it wins where
it and this file disagree.
On the claude executor the agents fix-planner, implementer and reviewer are listed: plan with
subagent_type: fix-planner before Step 5, telling it to write the plan to
$TMPDIR/factory-fix-plan.md, then follow that file; run the Local review gate with
subagent_type: reviewer. On opencode, skip this.
FILES is where this skill's files live: /usr/local/share/factory-skills/factory-fix in a Bellows
task, ${CLAUDE_PLUGIN_ROOT}/factory-fix on a developer machine (the image path below does not
exist there). The table names each file by its Bellows-task path; on a developer machine read the
same <path> under ${CLAUDE_PLUGIN_ROOT}/factory-fix. Every file is LOCAL: local.md uses them; a
Bellows task needs none unless its repo's overlay routes to one.
| File | Read where |
|---|---|
/usr/local/share/factory-skills/factory-fix/local.md | LOCAL |
/usr/local/share/factory-skills/factory-fix/review-codex.md | LOCAL |
/usr/local/share/factory-skills/factory-fix/agents/fix-planner.md | LOCAL |
/usr/local/share/factory-skills/factory-fix/agents/implementer.md | LOCAL |
/usr/local/share/factory-skills/factory-fix/agents/reviewer.md | LOCAL |
/usr/local/share/factory-skills/factory-fix/scripts/heavy.sh | LOCAL |
/usr/local/share/factory-skills/factory-fix/scripts/cleanup.sh | LOCAL |
/usr/local/share/factory-skills/factory-fix/sources/github.md | LOCAL |
/usr/local/share/factory-skills/factory-fix/sources/linear.md | LOCAL |
/usr/local/share/factory-skills/factory-fix/sources/fetch-linear-issue.sh | LOCAL |
/usr/local/share/factory-skills/factory-fix/sources/file-linear-followup.sh | LOCAL |
<repo root>/.claude/factory-fix.md, when it exists, names this repository's commands and rules;
it wins over discovered ones. An overlay may name sh HEAVY <command>; HEAVY is a LOCAL helper:
${CLAUDE_PLUGIN_ROOT}/factory-fix/scripts/heavy.sh/usr/local/share/factory-skills/factory-fix/scripts/heavy.shon_demand ones —
run each one your change touches once yourself, unfiltered). A failing test is fixed in
isolation — rerun only it until it passes alone, then widen again. Test runs go through the
declared gates whenever the repository has them (filtered when a gate accepts a filter — each
answer is a bounded, failure-first excerpt); your own shell only runs what no gate can, and then
its full output goes to a file you grep, never pasted into the session. A red-green loop you expect
to take more than two runs is delegated to a subagent that runs the loop under the same rule —
its test runs through the gates where the repository declares them — and returns only the
verdicts, the remaining failures with a one-line cause each, and the files it changed; the same
test failing the same way three times is a stop-and-diagnose (re-read the assertion and the
code, state the cause, one reasoned edit) — never a fourth blind scripted replacement.status === 200 and "an array came back". Seed both sides of any predicate
and assert inclusion and exclusion by id. Test boundaries (N, N-1, N+1). Assert exact
error codes, never "some error occurred". Cover every entry point that shares the logic.--no-verify, never
skip a check.Before touching anything, read the repo's own instructions — AGENTS.md, CLAUDE.md,
CONTRIBUTING.md, the README — and the test config. Establish:
| What | How to find it |
|---|---|
| Test runner and commands | package.json scripts, Makefile, justfile, CI workflow |
| Unit vs integration split | test directory layout; whether integration needs a live database |
| How integration tests get a database | docker-compose, testcontainers, a test:db-style script |
| Fixture / factory layer | existing test helpers; a faker or factory-bot equivalent |
| Seeded constants | the ids and users test setup provisions |
| Lint / format commands | scripts and config files; note if formatting is enforced in CI |
| Branch and commit conventions | git log --oneline -20, existing branch names, PR templates |
| Base branch | default branch, or a release/hotfix branch if the ticket targets a patch |
Write nothing down as a plan file. Carry it. (LOCAL: local.md's plan file replaces this.) (On the
claude executor: the planner's $TMPDIR/factory-fix-plan.md is the one plan file.) If the repo documents a rule that contradicts this
skill, the repo wins — say so and follow the repo.
Use the factory-jira skill, or the factory-linear skill for a Linear issue (a linear.app URL, or a bare
key when only Linear is bound). In short: find the in-progress ticket assigned to the current user, or take
the key the user gave. One match, use it; several, list them and ask; none, ask for a key.
Read the description and the comments — clarifications and reversals live in comments. If it is a subtask, read the parent too.
If the ticket is frontend-only, or targets a different service than the one checked out, stop and say so rather than fixing the wrong thing.
LOCAL: local.md's issue source fetches it.
Map the ticket's summary, description, components and labels onto code. Trace the whole path — the entry point (route/handler), the business logic (service/use case), and the data access (model/repository/query) — plus the tests that cover them.
git grep -ln "<distinctive term from the ticket>" -- <source dirs>
git log --oneline -15 -- <candidate path> # who touched this recently, and why
Ambiguous after grepping → ask the user to confirm the module before writing code. A module with no tests is not ambiguity; that is Step 4.
For the module, check: does a test directory exist with real specs; are there setup helpers that build state; is there a fixture/factory layer; for a unit-reproducible fault, is there a matching unit test file.
No coverage at all → Step 4. Some coverage → Step 5.
Commit on the task branch the checkout is on (Step 5.1), then:
<KEY> [test] add <module> baseline harness.Continue straight to Step 5 (the branch already exists). The baseline spec is where Step 5.9 later folds the bug's permanent test.
Stay on the task branch the checkout is on: commit and push there, never cut, check out or switch to another
branch, and never git worktree add — the driver checkpoints and publishes only this tree. The ticket's target
version only picks the pull request's base: a patch release means the corresponding hotfix branch, anything else
the project's development branch. Several candidate hotfix branches → ask.
LOCAL: local.md's Phase 1 picks the branch.
From the ticket and its comments, list the preconditions for the bug to manifest — "a record with tag X", "an order in status Y", "a role missing permission Z". For each: an existing helper covers it, or you add one in 5.3.
Add missing setup helpers before writing the spec, so the spec reads as intent rather than plumbing.
Apply the reproduction-layer practice above. If unit-reproducible, write the failing unit test now and confirm it fails for the right reason. Otherwise state explicitly why the fault is not unit-reproducible and go to 5.5b.
Check the test infrastructure is up first. A flaky or infra failure is never a valid red.
5.5a — unit repro path. The unit test pins the bug. Add a happy-path integration case for the behaviour a user expects end to end. It may already pass before the fix; it must pass after.
5.5b — integration repro path. Write a ticket-named spec that seeds both sides of the predicate, calls the affected entry point the way a client does, and asserts the buggy behaviour.
Watch the filter mechanism. If the project's test command filters by test name rather than
filename, a ticket-named file whose describe/it text omits the key matches zero tests — and
zero tests passing reports as success. Check which one your runner does before trusting a green.
Confirm it fails for the right reason.
Stage only the repro and the helpers it needed: <KEY> [test] reproduce <one-line bug summary>.
Minimal edit, under the surgical-changes practice.
Repro first, then the whole module suite for regressions. Both green before continuing.
excludes archived records from the list) — never for the ticket key.Run the project's lint (and formatter, if CI enforces it) and the affected suites. Any failure blocks the push. Fix errors; warnings are acceptable unless CI disagrees.
Stage the source fix, the permanent tests, and the deletion of the repro files:
<KEY> [fix] <one-line summary>.
Do not amend the first commit.
Run the Local review gate on the diff about to be pushed until it is clean,
then push. Gate fixes are new commits (<KEY> [fix] address local review: <summary>) — never amend
a commit already on the remote.
LOCAL: local.md's Phase 5 and Phase 6 replace this step.
Push the task branch and open (or update) the pull request yourself with git push and gh pr create, or ask the driver to do it (see the factory-github skill) —
either lands on the same pull request. Run the declared gates that cover your change first and fix a red one before you push;
report any that were unavailable. Finish with the work committed on the task
branch.
LOCAL: local.md's Phase 5 and Phase 6 replace this step.
On the run that fixed the ticket there is nothing to poll; finish at 5.13. On a follow-up run, after review feedback arrives, the PR exists and this loop applies. Per iteration:
Exit when the checks are green and nothing is unaddressed. Hand back early on the 5-iteration cap, a contradiction (Step 7), or a blocker outside the diff (infra, secrets, a base-branch conflict needing a product decision).
A contradiction is feedback that cannot be reconciled automatically:
When one appears: do not silently pick a side. Quote each position, name its source, lay out the options and their tradeoffs, ask, then resume Step 6 with the answer.
Minor ambiguity you can resolve sensibly is not a contradiction. Resolve it and keep going.
Do not declare done while CI is red. Confirm the final check status, then report: PR URL, CI status, what the fix was, whether Step 4 built a harness, how many review iterations it took, and anything left unresolved with the reason.
A headless review of the exact diff about to be pushed, run after lint and tests are green and before every push.
tries = 0
loop:
if tries >= 5:
Summarize what is still unresolved, ask the user how to proceed, and STOP.
Do not push a diff the gate has not cleared.
# The diff that will be pushed
git diff origin/<branch>...HEAD # branch already on the remote
git diff $(git merge-base origin/<base> HEAD)..HEAD # before the first push
Review it for correctness, error handling, security, and violations of the conventions in
the repo's own AGENTS.md / CLAUDE.md — plus this skill's practices. Ask for actionable
issues only, each with file:line and a concrete fix, and for an exact "NO ISSUES" when clean.
if clean: break
Fix every actionable issue. Behaviour change → test first, then fix. Re-run lint and the
affected suites. Commit as a new commit.
tries++
Use the merge-base form before the first push. A fixed HEAD~N offset silently drops the
earliest commits.
Run the review as a subagent (Claude Code: reviewer when listed, else general-purpose; OpenCode:
general) with the diff, or through a headless CLI if the environment has one. Skip pure style
nitpicks the linter already owns. If the review raises something that genuinely contradicts the
ticket or a practice above, treat it as Step 7 rather than degrading the fix to comply.
agents/fix-planner.md (opens in a new tab)agents/implementer.md (opens in a new tab)agents/reviewer.md (opens in a new tab)local.md (opens in a new tab)review-codex.md (opens in a new tab)scripts/cleanup.sh (opens in a new tab)scripts/heavy.sh (opens in a new tab)sources/fetch-linear-issue.sh (opens in a new tab)sources/file-linear-followup.sh (opens in a new tab)sources/github.md (opens in a new tab)sources/linear.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/factory-fix:factory-fixfrom factory-fix
npx claudepluginhub bellows-ai/bellows --plugin factory-fixOther plugins' skills for the same job