ワンクリックで
fix-bug
Fix a bug using test-driven development.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Fix a bug using test-driven development.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Build or modify a Sculptor extension — a runtime ESM module loaded into the Sculptor UI. Use when asked to write an extension (or "plugin") for Sculptor, add a panel, overlay, workspace widget, home view, or settings UI to Sculptor, or to iterate on an extension with `sculpt extension`. Works from any repo; this file is a self-contained reference (the Sculptor source code is optional).
Interact with Sculptor programmatically using the sculpt CLI. Use this skill when using `sculpt`, or when designing or planning a workflow that would benefit from understanding the structural capabilities of `sculpt` (workspaces, agents, isolation, and how code flows between them).
Live, hot-reloading preview of the Sculptor WEB frontend from a phone or any browser, served through the OpenHost nginx /proxy front. ONLY relevant when running INSIDE the openhost-deployed Sculptor (the container fronted by nginx on :5050, reachable at https://sculptor.<zone>/) — NOT for local or Electron dev. Frontend-only: it reuses the single shared backend, so it previews UI/frontend changes, not a per-workspace backend. Invoke when iterating on the web UI and wanting to see it live in a browser through the OpenHost SSO front.
How this OpenHost-hosted Sculptor environment works — storage and what survives restarts, where/how to add repositories and authorize gh, and the /proxy/<port>/ capability for previewing loopback web apps from a browser. ONLY relevant when running inside an OpenHost deployment (detect via the OPENHOST_* env vars, e.g. OPENHOST_APP_NAME). Ships with the deploy image and is refreshed every release.
Test a pull request by creating a shallow clone at the PR's commit and launching Sculptor. Use when you need to test changes from a specific PR in isolation.
QA the Sculptor mobile web UI on a real iOS Simulator, driven headlessly from a Mac. A single CLI boots a notched iPhone, launches the local frontend server (parsing its port — no hardcoding), opens the app in MobileSafari, taps/swipes via idb, and screenshots each step. Includes the Add-to-Home-Screen standalone flow — the only way to verify notch / status-bar / home-indicator safe-area rendering (env(safe-area-inset-*) is 0 everywhere except real iOS). Use when visually verifying mobile/responsive changes on an iPhone.
| name | fix-bug |
| description | Fix a bug using test-driven development. |
| when_to_use | Invoke when the user describes a bug, pastes an error, or references a bug ticket ID. Input: a description of the bug to fix, or a bug ticket ID. Prefix the input with `--autonomous` to run end-to-end with no user questions, hypothesis exploration, and (if the repo's config allows it) automatic publishing. The workflow enforces TDD — write a failing test first, then fix the code, then verify. Prefer this skill over ad-hoc bug fixes whenever the bug can be expressed as a reproducible test. |
Fix a bug using a strict TDD workflow: understand the bug, prove it with a failing test, fix the code, verify.
This skill has two modes:
.sculptor/code.md Publishing Changes
section permits it) push and open an MR/PR. For the other outcomes:
report the outcome with evidence (via the testing config's ticket
entry points if configured) and do NOT push. Triggered when the input
begins with --autonomous (or autonomous as the first token).Steps 1–3 below are shared by both modes. After Step 3, autonomous mode jumps to the "Autonomous Workflow" section near the end of this file. Interactive mode continues into Phase 1.
You MUST have all three config files before doing anything else. Do not proceed to any later step until all three files exist and you have read them.
Check for .sculptor/code.md, .sculptor/testing.md, and .sculptor/docs.md
in the repo root.
/sculptor-workflow:setup-repo skill via the Skill tool. Do NOT ask the
user whether to run it first — just run it. Do NOT attempt to fix the bug
without these files. Do NOT try to infer the information yourself — the
setup skill exists specifically to gather this information correctly
through conversation with the user..sculptor/code.md: codebase structure, branch naming, build/run
commands, pre-commit verification, publishing changes, proof-of-work
standards.sculptor/testing.md: test framework, test strategy, bug tracking
(fetch / file / comment / state-change entry points), manual testing,
visual verification.sculptor/docs.md: in particular the ## Code Review section,
which names the skill that the post-fix review pass invokes (see Phase 4
and Phase A4.5 below). If the section is empty or absent, the review
pass is skipped — see "Code review fallback" notes inline.Check the current branch with git branch --show-current.
auto/bugs/SCU-123-login-crash or auto/bugs/login-crash.git checkout -b <branch-name>
If the testing config has a Bug Tracking section, follow its instructions. The config specifies:
SCU-123, PROJ-42)If the input matches the ticket ID format, fetch the ticket's title, description, and comments, and use that context as the bug description for the rest of the workflow.
If the config says a ticket is always required but no ticket ID was provided:
If the testing config has no Bug Tracking section, skip this step.
If running in autonomous mode, jump now to the Autonomous Workflow section. The interactive Phase 1–4 below does not apply.
Before writing any code, get full clarity on what is broken.
Ask the user questions with your question tool if the description is vague or incomplete. Don't guess — ask about:
Read the relevant source code to understand how the feature currently works. Trace the code path to build a mental model of where the bug likely lives.
Reproduce the bug (if the testing config has a Manual Testing section). Follow the config's instructions to launch the app and visually confirm the bug. Take screenshots at each step — you will show them to the user in the confirmation step. If there are no manual testing instructions, skip visual reproduction.
Follow the testing config's Test Strategy section. The test strategy is mandatory policy, not a suggestion — you MUST follow its rules about what kind of test to write.
Write out your understanding as a summary:
The summary MUST appear as a plain chat message before you call the question tool. Your internal reasoning is invisible to the user, and the question panel only shows short question text — so a diagnosis that lives only in your thinking or inside the question tool's input was never shown to the user, and asking "does the diagnosis match?" leaves them with nothing to confirm. Skipping the written summary and jumping straight to the question tool is a known failure mode for this phase — do not do it.
If you reproduced the bug visually: include the screenshots inline with
<img> tags. Walk the user through each screenshot, explaining what you did
and what you observed.
You MUST ask with your question tool here — mcp__sculptor__ask_user_question if it's available, otherwise the built-in AskUserQuestion — do NOT ask via a plain
text message. (The written summary above is still a plain text message; only
the ask itself goes through the tool, which triggers a UI notification that
grabs the user's attention.) Ask:
"Does this match your understanding? Is the test location correct? Please confirm so I can proceed."
Then STOP. Do not proceed to Phase 2. Do not write any code. Wait for the user's explicit response.
Write a test that asserts the desired (correct) behavior. Since the bug hasn't been fixed yet, this test should fail.
Before writing anything, restate the commitment from Phase 1 verbatim:
"In Phase 1 I confirmed I would write a <test kind> test at <test file path>. I will write that exact test now."
The test kind and file path are locked. You MUST NOT re-read the testing config's Test Strategy and re-derive the decision. The user already confirmed it. Re-opening the decision here is the most common failure mode for this skill — do not do it.
If, while writing the test, you believe you need to change the test kind (e.g. fall back from an end-to-end test to a unit test), you MUST stop and ask with your question tool before writing anything different. In the question:
Do NOT decide to deviate on your own. Do NOT silently write a different kind of test than what was confirmed.
Follow the testing config's instructions for:
If the config references a skill for writing tests of the locked-in kind, invoke that skill. If not, read an existing test file in the repo as a reference and follow its patterns.
Test design:
Run the test using the testing config's test runner command (or skill). Verify it fails because of the bug.
Once the test fails as expected, commit the test file with a message like:
Add failing test for <bug description>.
Now implement the code change to make the test pass.
It is NOT ALLOWED to change the test file created in Phase 2. The test is the specification — the code must be changed to make the test pass, not the other way around.
Run the code config's pre-commit verification commands. Fix any issues introduced. Commit the implementation.
If the testing config has a Manual Testing section:
The testing config (.sculptor/testing.md) may specify rules about how
to verify particular classes of bugs — for example, which test harness
mode to use, whether real external services are required, or which kind
of evidence is mandatory. Re-read the testing config's Test Strategy
and Manual Testing sections now and apply any verification rules
that match this bug's class. Verification policy lives in the repo's
config, not in this skill.
Run the code-review skill named in .sculptor/docs.md's ## Code Review
section against the diff produced by this fix.
If the section is missing or empty: skip the review pass entirely
(same fallback as /sculptor-workflow:review). Continue to "Final
checks" below.
If the section names a skill (e.g. Skill: /code-review-checklist):
invoke that skill with:
<base branch>...HEAD, where <base branch> is the
up-to-date remote-tracking base ref (e.g. origin/main) — NOT local
main, which may be stale and silently widen the diff to include
commits already merged upstream. The three-dot syntax scopes the
review to this branch's own commits (it diffs against the merge base
automatically).Read every finding. Use your judgement to decide which findings to act on (there's no severity rule — trust yourself). For each finding you decide to act on, fix it in a follow-up commit. Single pass — do not re-run the review after fixing. Print the remaining findings (those you declined to act on) at the end of Phase 4 so the user can see them.
The implementation is not considered complete until this review pass has run.
.sculptor/code.md, .sculptor/testing.md,
.sculptor/docs.md) loaded (or created via setup).sculptor/docs.md has no ## Code Review section); findings the
agent declined to act on were printed to the userEnter this workflow only when the input began with --autonomous (or
autonomous as the first token). Steps 1–3 above have already run.
.sculptor/testing.md rules
for when a non-end-to-end test is allowed still apply. In autonomous mode
you make that decision yourself (no user gate), but the criteria are
unchanged. Document the test-kind choice for each bug in the final MR/PR
body so a reviewer can sanity-check it.The success bar for autonomous mode is a reviewer can approve the MR/PR without re-running the repro themselves. That requires:
.sculptor/code.md's ## Proof of Work section — typically before/after screenshots for UI-visible bugs,
failing-then-passing test output for the rest. Capture this evidence as
you go in Phases A2 and A4 (instructions inline below). Do not try to
reconstruct screenshots at the end.Treat A1–A4 as actively building the MR/PR body. Keep an "evidence log" in your working notes — for each hypothesis: the repro attempt, screenshots taken (with file paths), the test file path, what the test output looked like before the fix and after.
Autonomous mode MUST recognize that not every ticket is a "fix this code" ticket. After Phase A1 + A2 (investigate, form hypotheses, attempt repro), the agent classifies the ticket into exactly one of four outcomes:
main. The bug appears to have resolved itself (perhaps via an
unrelated commit). Skip the fix flow. Take the "STALE" branch under
Phase A5.main that already addresses the bug. Skip the fix flow. Take the
"ALREADY-FIXED" branch under Phase A5.Crucial rule: if the outcome is anything other than REPRODUCED, the agent MUST NOT push a branch, open an MR, or commit a speculative fix. Do not invent a bug to fix. Trying to fix the bug at all costs — when the right answer is to say "this is stale" or "I can't reproduce this" — is the failure mode this section exists to prevent.
Trust the outcome decision. A clean STALE / ALREADY-FIXED / UNREPRODUCIBLE outcome is a successful run, not a failed one.
Re-read the bug input (plus ticket context, if any was fetched in Step 3).
Check whether the bug is already fixed. Search git log --oneline -200
and grep the codebase for recent changes that could plausibly address the
bug (commits mentioning the same files, symptoms, or ticket ID). If you
find one, plan to verify in A2 — if the symptom no longer reproduces on
main, the outcome is ALREADY-FIXED.
Explore the codebase to find the code path(s) the description could plausibly refer to. Use Grep, Glob, and Read. If the testing config has a Manual Testing section, follow its instructions to poke at the live UI to narrow down where the bug surfaces.
List concrete hypotheses. Each hypothesis must name:
Cap the list. Carry at most 3 hypotheses forward. If you have more, keep the 3 best-supported by code evidence and drop the rest.
If the description is so vague that you can't form even one grounded hypothesis: the outcome is UNREPRODUCIBLE. Stop here, skip A2–A4, and take the UNREPRODUCIBLE branch under Phase A5.
Save your hypothesis list (titles + one-line summaries) — you'll quote it in the final MR/PR body, or in the ticket comment if the outcome is not REPRODUCED.
For each hypothesis, in order:
attachments/screenshots/bug-<slug>-before.png). This screenshot is a
required artifact in the final MR/PR body — capturing it now is not
optional, and the failing-test output you save in step 3 does not
substitute for it. Record the exact repro steps you used — every click,
input, and navigation — in your evidence log; they go into the MR/PR
body verbatim. If the bug does not reproduce, discard the hypothesis
and note in the evidence log what you tried and what you observed
instead. Move on.At the end of Phase A2 you have a set (possibly empty, possibly one, possibly several) of proven bugs, each with a failing test, a before-screenshot (if UI-visible), and saved failing-test output.
Outcome decision after A2:
main that an existing
commit/MR addresses the bug → outcome is ALREADY-FIXED. Skip A3–A4.5;
take the ALREADY-FIXED branch under Phase A5.main (no existing fix found either) → outcome is STALE. Skip
A3–A4.5; take the STALE branch under Phase A5.Do not push, commit fixes, or open an MR in any non-REPRODUCED outcome. Do not invent a bug to fix.
For each proven bug, commit its failing test on its own:
git add <test file>
git commit -m "Add failing test for <one-line bug description>"
One test per commit keeps the history easy to review and lets a human bisect later.
For each proven bug, in order:
Implement the minimal code change to make the test pass.
Run the test. Iterate the implementation (not the test) until it passes. Save the passing test output to the evidence log alongside the failing output from Phase A2 — the before-and-after pair is what proves the fix.
Run any sibling tests in the same area to catch regressions.
Re-run the manual repro from Phase A2 against the fixed code via the
testing config's Manual Testing section, and take an
after-screenshot (e.g. attachments/screenshots/bug-<slug>-after.png).
If A2 captured a before-screenshot for this hypothesis, you MUST
capture a matching after-screenshot. There is no exception, including
"the test already passes," "this would take too long," or "the fix is
obvious." If the difference is subtle, annotate the after-screenshot
using the testing config's Visual Verification section. Only skip
this step if A2 did not use the UI to reproduce (i.e. the bug genuinely
has no UI surface).
Exercise the full user flow, not just the narrow symptom. If the ticket describes a multi-step flow, drive the entire flow end-to-end and confirm the whole thing works — don't just confirm the literal symptom is gone. Reviewers will reject "this one moment is fixed but the broader flow is still broken."
Verification mode: re-read the testing config's Test Strategy and Manual Testing sections and apply any rules they specify about how to verify this class of bug (e.g. which harness mode, whether real external services are required, what evidence is mandatory). Verification policy lives in the repo's config — defer to it rather than guessing.
Commit the fix on its own:
git add <fix files>
git commit -m "Fix <one-line bug description>"
The test files from Phase A3 are locked. Do not modify them during A4.
After all proven bugs have been fixed in A4, run the code-review skill
named in .sculptor/docs.md's ## Code Review section against the diff
this run has produced.
If the section is missing or empty: skip the review pass entirely
(same fallback as /sculptor-workflow:review). Proceed to A5.
If the section names a skill (e.g. Skill: /code-review-checklist):
invoke that skill with:
<base branch>...HEAD, where <base branch> is the
up-to-date remote-tracking base ref (e.g. origin/main) — NOT local
main, which may be stale and silently widen the diff to include
commits already merged upstream. The three-dot syntax scopes the
review to this branch's own commits (it diffs against the merge base
automatically).Read every finding. Use your judgement to decide which findings to act on — there's no severity-based rule, trust yourself. For each finding you decide to act on, fix it in a follow-up commit. Single pass — do not re-run the review after fixing.
Any findings you declined to act on MUST be appended to the MR body in
a ## Review notes section so the human reviewer can see them and
decide whether to push back.
This phase only runs when the outcome from A2 is REPRODUCED. The STALE, ALREADY-FIXED, and UNREPRODUCIBLE branches are below.
Run the code config's Pre-commit Verification commands. Fix anything they flag and amend or add a follow-up commit.
Enumerate deferred-work follow-ups. If during A1–A4.5 you
consciously deferred any adjacent work (related bugs, refactors,
follow-up improvements), enumerate them in a ## Deferred follow-ups
section of the MR body draft. If you deferred nothing, omit the
section entirely.
Read the ## Publishing Changes section of .sculptor/code.md.
Auto-publish allowed is no or
ambiguous: stop here. Print a summary of the commits made and tell the
user to publish manually (and to re-run /setup-repo if they want this
automated next time). Do not push.Auto-publish allowed is yes: run the Push command
verbatim, then run the Create MR/PR (base command) with the title
(step 4) and body (step 5) appended as runtime flags.MR/PR title: write one imperative line summarizing the primary fix,
≤ 70 characters (e.g. "Fix login crash when token contains a colon").
If multiple bugs were fixed, summarize the most impactful one and rely
on the body to enumerate the rest. Do NOT prefix with Draft: /
[WIP] — draft state is controlled by the --draft flag in the base
command, not the title.
MR/PR body: write a detailed, reviewer-ready description.
First, re-read .sculptor/code.md's ## Proof of Work section to
confirm the team's evidence standard, then assemble the body using the
template below. The body is the reviewer's only context — vague,
one-line, or "fixed the bug" bodies are not acceptable.
Pass the title and body to the base command at runtime via flags. For
glab mr create: append --title "<title>" --description "<body>"
(for a large body, write it to a file first and pass it as
--description "$(cat <path>)" — glab does not have a --description-file
flag). For gh pr create: append --title "<title>" --body "<body>"
(or --body-file <path>). Never use --fill — it would discard the body.
Required template (use these exact section headings):
## Original bug
<verbatim quote of the user's bug description, plus ticket link if any>
## Hypotheses considered
<numbered list of every hypothesis from Phase A1, each annotated
"REPRODUCED" or "DISCARDED — <one-line reason>">
## For each reproduced bug
### <one-line bug title>
**Repro steps**
<numbered, exact steps from the evidence log — every click, input,
navigation, command, or fixture used to trigger the bug>
**Expected vs actual**
- Expected: <what should happen>
- Actual: <what happens today>
**Before**
<If A2 captured a before-screenshot for this bug, embed it here. **Do
not substitute test output** — the failing-test output is documented
in the Test block above. If the bug has no UI surface and A2 did not
take a screenshot, paste the saved failing-test output here in a
fenced code block instead.>
**Root cause**
<several sentences explaining the code path responsible and why it
produces the buggy behavior; reference specific files and functions>
**Fix**
<several sentences explaining what changed and why it addresses the
cause; if there were obvious alternatives, briefly say why this one>
**Test**
- Path: `<test file>`
- Kind: <e2e | unit> (if unit, cite the "impossible" criterion)
- Failing-test commit: `<hash>`
- Fix commit: `<hash>`
**After**
<If A4 captured an after-screenshot for this bug, embed it here. **Do
not substitute test output.** If the bug has no UI surface and A4 did
not take a screenshot, paste the saved passing-test output here in a
fenced code block instead.>
For multiple reproduced bugs, repeat the ### <bug title> block.
Reject your own draft if it contains any of:
Rewrite before posting. If you catch yourself thinking "the screenshot isn't worth the time" or "the test output is enough proof," that is exactly the rationalization the autonomous mode is designed to reject — go back and capture the screenshot.
Review notes: if Phase A4.5 left any findings you declined to act
on, append them as a final ## Review notes section. One bullet per
finding, with the file/line reference. This is required even if the
list is empty — write _(no outstanding review notes)_ so a reviewer
knows the review pass ran.
Print the resulting MR/PR URL.
Take this branch when Phase A2 concluded the outcome is anything other than REPRODUCED. Do not push a branch, open an MR, or commit any speculative fix. The agent must NOT invent a bug.
For all three outcomes, follow these steps:
Comment templates:
For STALE:
**Outcome: stale** — autonomous fix-bug run on <commit-sha>
I attempted to reproduce this bug on `main` (<commit-sha>) and could not.
The symptom no longer appears to manifest. The bug may have been resolved
incidentally by an unrelated change.
What I tried:
- <bullet list of repro attempts and what was observed>
If you can still reproduce this, please add updated repro steps so I can
investigate further.
For ALREADY-FIXED:
**Outcome: already fixed** — autonomous fix-bug run on <commit-sha>
I found an existing fix on `main` that appears to address this:
- Commit: <hash-or-MR-link>
- Behaviour change: <one-line summary>
Walking the original repro against the current code shows the described
behaviour no longer occurs. Recommend closing this ticket.
What I tried:
- <bullet list of repro attempts and what was observed>
For UNREPRODUCIBLE:
**Outcome: unreproducible** — autonomous fix-bug run on <commit-sha>
I attempted to reproduce this bug but could not narrow it down from the
description. <Only include the next sentence if the state change in step 3
actually ran:> Moving the ticket to the configured "needs info" state so
the reporter can clarify.
What I tried:
- <bullet list of hypotheses considered, repro attempts, and observations>
To make this fixable, please add:
- Exact steps to reproduce (every click, input, navigation)
- Environment details (OS, app version, anything else relevant to the repro)
- Screenshots or logs showing the buggy state
- Whether it reproduces consistently or intermittently
These outcomes are successful runs, not failures. They preserve trust in autonomous mode by guaranteeing the agent never fabricates a bug to fix.
--autonomous / autonomous; no user questions were asked.sculptor/code.md, .sculptor/testing.md,
.sculptor/docs.md) were loaded before any other action.sculptor/docs.md has no ## Code Review section)## Review notes section## Deferred follow-ups section; if the testing config has a
"How to file new tickets" entry point, each item also has a
tracker URL.sculptor/code.md's Publishing Changes section
— pushed and opened MR/PR only if Auto-publish allowed: yes--description / --body
(or equivalent), not --fill