Worked example: fix-bug

These are the three files of the built-in fix-bug skill, from skills/fix-bug. Each file has its own reference page: SKILL.md, goals.yaml and kit.yaml.

SKILL.md:

---
name: fix-bug
description: Write a minimal, tested fix for a bug, ideally one that already has a failing reproduction test.
model_tier: strong
tools: [get_issue, read_file, list_files, search, write_file, edit_file, exec, git_diff, memory_search, set_output]
outputs: [TEST_CMD]
---

You receive a bug report and, when one exists, a failing reproduction test (`REPRO_TEST`, run with `REPRO_CMD`).

1. Find the root cause. Read the code path the reproduction exercises until you can state the cause in one sentence. Do not patch symptoms.
2. Make the smallest change that makes the reproduction pass.
3. Do not modify the reproduction test. If you believe the test itself is wrong, stop and say why instead of editing it.
4. Run the full test suite of the affected package or module, and the linter if the repository has one. Fix what you broke.
5. Record with `set_output` `TEST_CMD`: one shell command, run from the repository root, that runs the test suite of the affected package.
6. Finish with: the root cause in one or two sentences, what you changed and why that is the right place, and anything a reviewer should look at twice.

No unrelated refactors, renames or formatting changes. Follow the repository's conventions (AGENTS.md, surrounding code). If there is no reproduction test, add a regression test for the fix.

goals.yaml:

max_attempts: 3
checks:
  - name: reproduction passes
    run: ${REPRO_CMD}
    skip_if_unset: true
    timeout: 15m
  - name: package tests pass
    run: ${TEST_CMD}
    timeout: 30m
constraints:
  max_changed_lines: 300
  forbidden_paths: ["${REPRO_TEST}", ".github/**", ".gitlab-ci.yml", ".forgejo/**", "bitbucket-pipelines.yml", ".factory/**"]
judge:
  rubric: |
    - The fix addresses the root cause described in the analysis, not a symptom.
    - No unrelated refactors.
    - The reproduction test was not weakened, skipped or deleted.
    - The code follows the repository's conventions (see AGENTS.md).

kit.yaml:

resources: { cpu: "4", memory: 8Gi, disk: 40Gi }
needs_docker: true
egress:
  allow:
    - proxy.golang.org
    - sum.golang.org
    - registry.npmjs.org
    - pypi.org
    - files.pythonhosted.org
    - crates.io
    - static.crates.io
    - index.crates.io
    - repo.maven.apache.org
    - rubygems.org

How the pieces work together:

  • The subagent must record TEST_CMD. The check package tests pass then runs exactly that command, so the skill works in any repository without a hard-coded test command.
  • REPRO_CMD and REPRO_TEST come from an earlier reproduce-bug run in the same session. When there was none, the first check is skipped and the ${REPRO_TEST} constraint does not apply.
  • The constraints keep the fix small and keep it away from CI configuration and from .factory/ itself.
  • The judge runs last and grades what commands cannot: root cause, scope, conventions.
  • The kit names no image, so the deployment’s default toolchain image is used, and no credentials: the clone credential for the repository is added by kōjō.
Scroll to move. + - zoom, 0 fit, Esc close.100%