一键导入
fix
Structured bug fix — reproduce (failing test), diagnose, fix (minimal change), verify, commit. Enforces test-first. Use when a bug needs a methodical fix.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Structured bug fix — reproduce (failing test), diagnose, fix (minimal change), verify, commit. Enforces test-first. Use when a bug needs a methodical fix.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
End a session — extract learnings, write handoff, store patterns, detect doc drift. Use when ending a work session or when the user says done/bye/closing.
Build anything — features, bug fixes, refactors, spikes, migrations. Auto-detects strategy, integrates with backlog, enforces TDD. The unified dev command.
Align a project to brana practices — assess gaps, plan, implement, verify. Auto-detects type. Use when setting up a new project or realigning an existing one.
Scan and diagnose a project, or scaffold a new client from scratch. Works for code and venture clients. Auto-detects project type.
Manage the backlog — plan, track, navigate phases and streams. Use when planning phases, viewing roadmaps, or restructuring work.
Unified maintenance — detect drift, run security checks, cascade spec propagation, knowledge hygiene. Scoped via --scope flag. Default: consistency.
| name | fix |
| description | Structured bug fix — reproduce (failing test), diagnose, fix (minimal change), verify, commit. Enforces test-first. Use when a bug needs a methodical fix. |
| effort | medium |
| model | sonnet |
| keywords | ["bug","fix","broken","error","crash","failing","regression","debug","diagnose","reproduce","root-cause"] |
| task_strategies | ["bug-fix"] |
| stream_affinity | ["bugs","tech-debt"] |
| argument-hint | [task-id or description of the bug] |
| group | execution |
| depends_on | ["backlog"] |
| allowed-tools | ["AskUserQuestion","Bash","Edit","Glob","Grep","Read","Write","Agent","mcp__ruflo__autopilot_learn","ToolSearch","TaskCreate","TaskList"] |
| status | stable |
| growth_stage | evergreen |
Structured bug fixing workflow. Five steps: REPRODUCE → DIAGNOSE → FIX → VERIFY → COMMIT → (HARDEN). Enforces test-first debugging — no source changes until a failing test exists. HARDEN is optional: fires when the same errata class has appeared 2+ times — offers to convert the pattern into a PreToolUse gate.
/brana:fix [task-id or bug description]
If a task ID is provided, load it via brana backlog get <id> and use the description as the bug statement.
On entry, create CC Tasks for each step (for compression resilience):
TaskCreate: "/brana:fix — REPRODUCE"
TaskCreate: "/brana:fix — DIAGNOSE" (blocked by REPRODUCE)
TaskCreate: "/brana:fix — FIX" (blocked by DIAGNOSE)
TaskCreate: "/brana:fix — VERIFY" (blocked by FIX)
TaskCreate: "/brana:fix — COMMIT" (blocked by VERIFY)
TaskCreate: "/brana:fix — HARDEN" (blocked by COMMIT, optional)
Mark each in_progress when starting, completed when done. Resume after compression by calling TaskList and finding the in_progress step.
After creating the step registry, call /goal and write active-goal.json unless --no-goal was passed.
If a task_id is known, first extract AC: lines from task context:
brana backlog get {task_id} | python3 -c "
import json, sys
t = json.load(sys.stdin)
lines = [l[3:].strip() for l in (t.get('context') or '').splitlines() if l.startswith('AC:')]
print('\n'.join(lines))
"
If AC: criteria found:
/goal "fix {task-id} — Done when: {criteria joined with ' AND '}"
Pin base_ref at goal start and initialize tests_required[] empty (hardened form —
ADR-061 §4, identical to build's LOAD step 0):
base_ref=$(git -C "{git_root}" rev-parse HEAD)
cat > ~/.claude/run-state/active-goal.json <<JSON
{"task_id": "{task_id}", "cwd": "{git_root}", "session_id": "$BRANA_SESSION_ID", "base_ref": "$base_ref", "criteria": ["{criterion1}", "{criterion2}"], "tests_required": []}
JSON
base_ref anchors the grader-immutability check; the REPRODUCE failing test is committed
red in its own commit (the REPRODUCE step, Step 1) so the red-verification pre-commit hook (t-2216) registers
it into tests_required[] — earning the exemption by observed redness. The Stop hook
(goal-completion.sh) auto-completes the task when all criteria pass, behind the presence +
immutability interlocks.
If no AC: criteria (or no task_id):
/goal "fix {task-id}: reproduce → diagnose → fix → verify → commit"
No active-goal.json write — the narrative goal is for session anchoring only.
/goalbinding declaration (ADR-061 §3, Stage 3 — t-2206). Span: REPRODUCE → DIAGNOSE → FIX → VERIFY (gate-free — no human approval inside it). Done-signal: the reproduce failing test now passes (encoded as anAC:line, graded bygoal-completion.sh). C1 ✓ machine-verifiable (test exit code); C2 ✓ gate-free span; C3 ✓ mutation-bounded to the failing path's files + the new test. Re-audit rule: if a human gate is ever added inside this span, the same commit must re-scope or retire this binding.
COMMIT is the natural terminator for single fixes. HARDEN fires only when recurrence is detected — skip it otherwise and self-terminate after COMMIT.
ToolSearch("select:mcp__ruflo__autopilot_learn")
Goal: prove the bug is real with a failing test before touching any source.
{test name} — {actual output}"If 3 or more previous fix attempts have already failed for this bug, pause and run
/brana:challengeon your diagnosis before continuing to Step 2.
Checkpoint:
printf '{"step":"REPRODUCE","completed":"%s","task":"%s"}\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "{task_id}" >> ~/.claude/run-state/{task_id}.jsonl
Goal: state a specific hypothesis about root cause — not a symptom.
"This bug fails because
{component}does{wrong thing}when{condition}, producing{bad result}instead of{expected result}."
parse_config()."Checkpoint:
printf '{"step":"DIAGNOSE","completed":"%s","hypothesis":"%s"}\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "{hypothesis}" >> ~/.claude/run-state/{task_id}.jsonl
Goal: make the minimal change that satisfies the hypothesis.
Goal: confirm the fix works and introduced no regressions.
{X}, now getting {X} — fixed."Commit message format:
fix({scope}): {what was wrong and what changed}
Examples:
fix(parse-config): nil check missing when optional key absentfix(session-end): cd /tmp invalidates git root for subsequent brana callsIf a task ID exists: add it to notes and set status:
brana backlog set {task_id} status completed
brana backlog set {task_id} notes --append "Fixed {date}: {one-line summary}"
Feed the autopilot — after committing, call:
mcp__ruflo__autopilot_learn()
Seeds pattern registry from completed fix outcome. Skip silently if ruflo unavailable.
Close the session if this was the only task: invoke /brana:close.
Goal: convert a recurring errata class into a structural PreToolUse gate so it cannot recur.
Trigger check (run immediately after COMMIT):
# Extract 2-3 keywords from the current fix subject/tags
KEYWORDS="{keyword1} {keyword2}"
# Count prior field notes matching the same class
grep -c "$KEYWORDS" ~/.claude/CLAUDE.md \
"$(git rev-parse --show-toplevel)/.claude/CLAUDE.md" 2>/dev/null | \
awk -F: '{s+=$2} END {print s}'
If count ≥ 2: proceed. Otherwise: skip HARDEN entirely — mark the CC Task completed and self-terminate.
Harden flow (only if triggered):
Identify the invariant. State in one sentence what structural condition would have prevented every instance:
"Every write to
{path}must have{field}absent /{condition}true."
Identify the interception point. Which CC tool event catches the violation before it lands?
Write / Edit to a specific file or path pattern → PreToolUse on Write/EditBash command matching a pattern (e.g., git commit, cargo build) → PreToolUse on BashPreToolUse on mcp__*Offer via AskUserQuestion — never proceed without explicit yes:
AskUserQuestion(
question: "This errata class ({class}) has appeared {N} times. Convert to a PreToolUse gate?\n\nProposed invariant: {invariant}\nInterception: PreToolUse on {tool} matching {pattern}",
options: ["Yes — draft the hook (Recommended)", "No — skip hardening"]
)
If yes — draft the hook script:
system/scripts/hooks/{errata-slug}-gate.shsystem/.claude-plugin/hooks.json under PreToolUse#!/usr/bin/env bash
# Gate: {invariant description}
# Errata: {errata-id} — fires when {condition}
INPUT=$(cat)
# ... extract relevant fields from $INPUT ...
if {violation_condition}; then
echo "{errata-id}: {what was wrong} — {how to fix}" >&2
exit 1
fi
exit 0
Write a test in system/scripts/tests/test-{errata-slug}-gate.sh:
Present the complete diff (hook script + hooks.json entry + test) to the user for review before writing any file.
After approval: write files, run chmod +x on the hook script, verify ./validate.sh passes.
/brana:challenge before continuing.TaskList — find the in_progress step~/.claude/run-state/{task_id}.jsonl for the last checkpoint state