From rawgentic
Fix a bug using the WF3 14-step workflow with reproduce-first TDD, root cause analysis, lightweight reflect, and conventional commit PR. Invoke with /fix-bug followed by an issue number. DO NOT use this skill if the user is working within a BMAD workflow or has BMAD story files — use bmad-dev-story instead. Only trigger when the user explicitly invokes /fix-bug or /rawgentic:fix-bug, or is working in a rawgentic-only project without BMAD.
How this skill is triggered — by the user, by Claude, or both
Slash command
/rawgentic:fix-bug GitHub issue number (e.g., "42") or issue URLGitHub issue number (e.g., "42") or issue URLThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
<role>
| Step | Name | Why mandatory |
|---|---|---|
| 1 | Receive Bug Report | Foundation — wrong bug = wrong fix |
| 2 | Analyze Bug Context | Complexity classification + reproduction context |
| 3 | Root Cause Analysis | Fixing symptoms without RCA causes regressions |
| 4 | Quality Gate (Reflect) | Validates the RCA before implementation |
| 5 | Create Fix Plan | Task decomposition for TDD |
| 6 | Create Branch | Git isolation is non-negotiable |
| 7 | TDD Bug Fix | Reproduce-first is the core WF3 principle |
| 8 | Verification | Confirms fix works and no regressions |
| 9 | Code Review | NON-NEGOTIABLE. Catches security issues, logic errors, and regression risks in the fix. |
| 10 | Create PR | Deliverable — no PR means no review trail |
Conditional steps (skip ONLY when their condition is not met):
ENFORCEMENT: You MUST NOT rationalize skipping a mandatory step. Common invalid justifications:
If you catch yourself about to skip a mandatory step, STOP and acknowledge: "I was about to skip Step N which is mandatory. Proceeding with the full step."
Before executing any workflow steps, load the project configuration:Determine the active project using this fallback chain:
Level 1 -- Conversation context: If a previous /rawgentic:switch in this session set the active project, use that.
Level 2 -- Session registry: Read claude_docs/session_registry.jsonl. Grep for your session_id. If found, use the project from the most recent matching line.
Level 3 -- Workspace default: Read .rawgentic_workspace.json from the Claude root directory. If exactly one project has active == true, use it. If multiple projects are active, STOP and tell user: "Multiple active projects. Run /rawgentic:switch <name> to bind this session."
At any level:
.rawgentic_workspace.json missing -> STOP. Tell user: "No rawgentic workspace found. Run /rawgentic:new-project.".rawgentic_workspace.json malformed -> STOP. Tell user: "Workspace file is corrupted. Run /rawgentic:new-project to regenerate, or fix manually."activeProject.path may be relative (e.g., ./projects/my-app). Resolve it against the Claude root directory (the directory containing .rawgentic_workspace.json) to get the absolute path for file operations.1b. Disabled skill check: After resolving the active project, read .rawgentic_workspace.json (if not already read in step 1) and find the active project's entry.
disabledSkills array and this skill's bare name appears in it:
[Headless cleanup]: Before stopping, check if claude_docs/headless_suspend.json exists. If it does, delete it, remove rawgentic:ai-waiting label from the issue (read issue number from suspend file), and add rawgentic:ai-error with a comment: "This skill was disabled after a headless session was suspended. The pending question can no longer be processed." Then STOP.
/rawgentic:setup or edit disabledSkills in .rawgentic_workspace.json."
Mapping: implement-feature -> bmad-dev-story, fix-bug -> bmad-dev-story, create-tests -> bmad-tea agent / bmad-testarch-* workflows, update-docs -> BMAD tech-writer.disabledSkills in .rawgentic_workspace.json to re-enable."bmadDetected is true but the project entry has no disabledSkills field: STOP. Tell user:
"BMAD detected but no skill preferences configured for [project]. Run /rawgentic:switch or /rawgentic:setup to configure."capabilities object, so all 11
workflow skills and the docs table cannot drift apart):
python3 hooks/capabilities_lib.py derive \
--config <activeProject.path>/.rawgentic.json
/rawgentic:setup). A config.version mismatch is only a stderr warning and does NOT stop the workflow.{"config": {...}, "capabilities": {...}}. Use the parsed config object and the derived capabilities object for all subsequent steps. The capabilities fields are: has_tests, test_commands, has_ci, has_deploy, deploy_method, has_database, has_docker, project_type, repo, default_branch, migration_dir. Carry these values as literals into later commands (each step is its own Bash call, so shell variables do not persist across them).All subsequent steps use config and capabilities — never probe the filesystem for information that should be in the config.
All other project-specific values (repo, hosts, database, docker compose files, test commands) come from config and capabilities loaded via the <config-loading> block. Do not read CLAUDE.md for infrastructure or database details.
If config loading fails, STOP and tell the user which config step failed.
WF3 terminates after deployment verification and completion summary. No auto-transition to other workflows. WF3 terminates ONLY after the completion-gate (after Step 14) passes. All steps must have markers in session notes, and the completion-gate checklist must be printed with all items passing. Per rawgentic workflow principle (context preservation): before context compaction, document in `claude_docs/session_notes.md`: current step number, branch name, last commit SHA, bug classification, RCA findings, and loop-back budget state. Bug fixes enforce a strict "reproduce first" TDD pattern: 1. Write a failing test that reproduces the exact bug behavior described in the issue 2. Run the test — confirm it fails in a way that demonstrates the bug exists. In mocked or test environments, the specific status code or error message may differ from production — the key proof is that the broken behavior (missing validation, unguarded code path, incorrect logic) is demonstrated, not that the exact production symptom is reproduced. 3. Fix the code — make the test pass 4. Run full test suite — confirm no regressions 5. Add edge case tests — cover related scenarios the original bug report hints atThis is stricter than WF2's general TDD flow because bugs have a concrete "before" state that MUST be captured in a test before fixing. A test written after the fix cannot prove the fix actually addressed the bug.
WF3 accepts bug reports of any complexity. However: - If Step 2 classifies the bug as `complex_bug` (fix touches 10+ files, cross-service, unclear root cause), the workflow UPGRADES to WF2 automatically. - Before escalating, document all Step 2 findings in `claude_docs/session_notes.md`: affected files list, blast radius, suspected root cause, test inventory, related issues. This ensures WF2 Step 2 can build on existing analysis. - Inform the user: "This bug fix is complex enough to warrant the full feature implementation workflow. Switching to `/implement-feature`." - If the user disagrees, they can override and stay in WF3. The low-end mirror of ``. Some bug fixes are **trivial** — a typo, a one-line off-by-one, a comment, a config/constant tweak — where even WF3's 14 steps are more ceremony than the fix warrants. This surfaces that BEFORE the workflow invests in root-cause analysis and review.Trigger (evaluated in Step 2, after complexity classification): set
trivial_work = true only when the fix is ~1 file (occasionally 2), roughly ≤ 10 changed
lines, mechanical, with no new logic and low reversal cost. (Reproduce-first still applies
in spirit — a one-line regression test is cheap and worth it — but the full step
machinery is not.)
This is a suggestion, never a hard gate — the orchestrator must NOT bail on its own, and continuing the full workflow is always a valid choice.
When trivial_work == true (interactive): STOP and present, concisely:
Step 2 → TRIVIAL bug detected (<N files, ~M lines, <one-line why>).
The full WF3 (14 steps) is likely overkill. Proceed how?
(a) Do it directly — reproduce test + minimal fix + branch + PR [recommended]
(b) Continue the full WF3 workflow
Wait for the choice.
complexity: "trivial".[Headless: AUTO-RESOLVE — continue the full workflow; log ### WF3 Step 2 — trivial-work suggestion (auto-continued in headless).]
If the project's CLAUDE.md or development rules require explicit approval for merge, deploy, or similar operations, ask the user before proceeding. The steps must still be executed — they just require user confirmation first.
At the end of each step, log a marker in `claude_docs/session_notes.md`: `### WF3 Step X: — DONE ()` This enables workflow resumption if context is lost.<config-loading> to load the project configuration and build the capabilities object. Then execute <environment-setup>** to populate PROJECT_ROOT. Log resolved config values in session notes. If config loading fails, STOP and tell the user which step failed.gh issue view <number> --repo capabilities.reposecurity. If the security label is present, the issue likely uses STRIDE format (from WF9) instead of the standard bug report template. Adapt field mapping:
security label but no recognizable STRIDE fields, fall back to standard parsing and ask the user to clarify.mcp__mempalace__* tools loaded), call mempalace_search with the symptom and any error messages from the issue. Past similar bugs often have documented root causes and fixes. Surface any matches explicitly before moving to Step 2. If no mempalace MCP server is configured, skip silently.Present to user:
Bug Report: #<number>
Title: <title>
Status: <open/closed>
Format: [standard bug report | security finding (STRIDE)]
Steps to Reproduce / Vulnerability Path:
<from issue>
Expected: <from issue or "blocked/mitigated">
Actual: <from issue or "exploitable">
Environment: <from issue>
Confirm this is the bug to fix, or provide corrections.
Wait for user confirmation before proceeding to Step 2. [Headless: AUTO-RESOLVE for WF1-created issues. QUESTION for manual issues — post summary, suspend.]
/implement-feature) insteadfind_symbol, find_referencing_symbols) for complex call chains involving multiple services or deep symbol resolution where grep alone would miss indirect references.simple_bug: 1-3 files, clear root cause, no migration neededmoderate_bug: 4-10 files, root cause requires investigation, may need migrationcomplex_bug: 10+ files, cross-service, unclear root cause → prompt upgrade to WF2gh issue list --repo capabilities.repo --search "<keywords>" --limit 10<trivial-work-check>. If the fix
is trivial_work == true, present the "do it directly vs. continue the full workflow"
suggestion and WAIT for the user's choice before proceeding to Step 3 (headless:
auto-continue).Bug analysis (internal working artifact):
complex_bug → prompt upgrade to WF2 (user can override)trivial_work → suggest doing it directly (user can continue WF3); see <trivial-work-check>RCA document (internal working artifact):
Invoke /reflexion:reflect with focus on root cause correctness. Single-pass reflection checking:
Critique level: Lightweight reflect ONLY. RATIONALE: Bug fixes have lower reversal cost than new features. A full 3-judge critique adds 2-3 minutes of latency for diminishing returns on small-scope changes.
Adversarial review sub-step (opt-in, DEFAULT-OFF, cross-model). WF3 is deliberately lightweight; an external cross-model review is therefore off by default and must be explicitly opted in per project. After the lightweight reflect above, check:
python3 hooks/adversarial_review_lib.py is-enabled \
--workspace .rawgentic_workspace.json --project <name> --skill fix-bug
0 when enabled (fix-bug listed in the project's adversarialReview.workflows) and non-zero otherwise. If disabled (the default), skip silently. The fast path is preserved exactly; this adds zero overhead to a normal bug fix./rawgentic:adversarial-review <rca-path> plan. It is report-only; merge its findings (tagged source: adversarial) with the reflect findings and apply the circuit breaker over the merged list. If a Critical/High indicates the root cause itself is wrong, loop back to Step 3 once (max 1 per loop-back budget, same as the reflect loop-back — it does NOT add a second budget). Codex failure is non-blocking (additive review): on ANY non-success — including headless unmet-prerequisite — skip the adversarial layer, log loudly (headless: STATUS comment), and continue with the reflect result. Do NOT trigger the ERROR protocol and do NOT block WF3 (only the standalone /rawgentic:adversarial-review skill ERRORs on an unmet prerequisite). Log: ### WF3 Step 4 — Adversarial Review (invoked|skipped): <report path or skip reason>.Note: the is-enabled check reads .rawgentic_workspace.json; if that file is missing or corrupt the engine returns disabled (fail-safe), so WF3 continues unchanged.
Amended RCA (findings applied) OR blocked state (circuit breaker triggered).
fix/<issue-number>-<short-desc>Fix plan with ordered tasks, file paths, and test expectations.
git fetch origin capabilities.default_branch
git checkout -b fix/<issue-number>-<short-desc> origin/capabilities.default_branch
config.techStack includes npm/yarn/pnpm-based technologies (node, react, vue, angular, etc.) or a package.json exists in the project root, verify node_modules exists. If missing, run the appropriate install command (npm install, yarn install, or pnpm install) before proceeding to Step 7. Similarly, for Python projects with a requirements.txt or pyproject.toml, verify the virtual environment is active or dependencies are installed. This prevents test failures due to missing dependencies rather than actual bugs.Active fix branch with dependencies installed.
git stash), create branch, then ask user if stash should be applied. [Headless: AUTO-RESOLVE — always stash, post brief issue comment with stash ref.]Execute the plan from Step 5 using strict reproduce-first TDD:
capabilities.test_commands to confirm no regressions. Iterate over all configured test frameworks.fix(scope): brief descriptionTest commands are derived from capabilities.test_commands (loaded from config.testing.frameworks[].command). If capabilities.has_docker, run tests via the compose files from config.infrastructure.docker.composeFiles[]. If tests are configured to run on remote hosts, use config.infrastructure.hosts[] to determine connection details.
Do not hardcode test runners or compose file names — always derive from config.
Fixed code with passing tests on fix branch.
Quick self-check (no sub-agent needed):
git diff --stat should show only planned files.Verification pass/fail.
git checkout -- <file> to revert straysPart A: Code Review
Launch a focused 2-agent code review in parallel using Agent tool calls (subagent_type per the PR review toolkit):
pr-review-toolkit:silent-failure-hunter — silent failure detection (critical for bug fixes — ensure the fix doesn't suppress errors)pr-review-toolkit:code-reviewer — project standards compliance + general reviewFor bug fixes, focus reviewers on: (a) is the fix correct and complete, (b) are there any new silent failures, (c) is the code simple and focused. Type design and code simplification are deferred — bug fixes should be minimal and targeted.
Apply findings automatically. Circuit breaker on ambiguity.
Part B: Conditional Memorize
If the bug fix reveals a pattern worth remembering (new pitfall, gotcha, or recurring issue), invoke /reflexion:memorize to curate insights into project knowledge. Skip if the fix is routine.
Memorize triggers:
Review-clean code + optional project knowledge updates.
Stage all changes: git add <specific files> (never git add -A)
Create final commit with conventional format:
git commit -m "fix(scope): description (closes #<issue>)"
Push branch:
git push -u origin fix/<issue-number>-<short-desc>
Create PR:
gh pr create --repo capabilities.repo \
--title "fix(scope): description" \
--body "$(cat <<'EOF'
## Summary
- Fixes #<issue-number>
- Root cause: [brief RCA]
- Fix: [brief description of fix]
## Test plan
- [ ] Reproduction test passes (was failing before fix)
- [ ] Regression tests added
- [ ] Full test suite passes
- [ ] CI passes
Generated with [Claude Code](https://claude.com/claude-code) using WF3
EOF
)" \
--label "bug"
PR URL.
gh auth statusgit pull --rebase origin capabilities.default_branch), resolve conflicts, re-pushgh run list --repo capabilities.repo --branch fix/<branch-name> --limit 3
gh run view <id> --log-failed, fix, push, and re-check (max 2 retries).Note: gh pr checks does NOT work with fine-grained PATs. Use gh run list / gh run view instead.
CI pass/fail status.
Pre-merge check: If the project's CLAUDE.md or development rules require explicit user approval for merge or deploy operations, ask the user before proceeding. Do not auto-merge in projects with approval gates.
gh pr merge <number> --squash --delete-branch --repo capabilities.repo
capabilities.has_deploy, use the deploy method and commands from config.deploy. Otherwise, ask the user for deployment instructions.capabilities.has_database, run it using the database CLI from config.database.cli against the database specified in config.database. If the database runs in a container, derive the container name and credentials from config.database and config.infrastructure.docker.Merged PR + deployed dev environment.
git revert on the default branchcapabilities.has_tests and config includes E2E test commands, run the relevant E2E specs using the test command from config.testing.frameworks[] (filtered for E2E type). If tests run on a remote host, use the appropriate host from config.infrastructure.hosts[].Deployment verified OR rollback needed.
git revert on the default branchThe completion summary is no longer hand-typed. Assemble a structured
run-record and drive the summary through hooks/work_summary.py — the same
Tier-2 telemetry substrate WF2 Step 16 uses (see docs/run-records.md), so WF3's
completion output is consistent and every run is measurable, not just a sentence
read once.
Update claude_docs/session_notes.md with fix summary.
Close GitHub issue with closing comment:
gh issue close <number> --repo capabilities.repo \
--comment "Fixed in PR #<pr-number>. Root cause: <brief>. Fix: <brief>."
Assemble the run-record and write it to /tmp/wf3-run-record.json (use the
Write tool, or a cat > … <<'JSON' heredoc). Every key below must be
present; "nullable" means null is an allowed value, NOT that the key may
be omitted (a dropped field is a telemetry gap). Counts are non-negative
integers and resolved may not exceed findings:
{
"workflow": "fix-bug",
"workflow_version": "<.claude-plugin/plugin.json version>",
"issue": {"number": <bug issue #>, "type": "bug",
"complexity": "trivial|standard|complex|null"},
"changes": {"files_changed": N, "insertions": N|null, "deletions": N|null,
"commits": N},
"tests": {"added": N, "passing": N|null, "total": N|null},
"gates": [
{"step": "4", "name": "Lightweight Reflect", "findings": N, "resolved": N, "status": "pass|fail|skipped|fast_path"},
{"step": "9", "name": "Code Review", "findings": N, "resolved": N, "status": "..."}
],
"security_scan": {"ran": false, "blocking_resolved": 0, "advisory": 0, "skipped": []},
"loop_backs": {"used": N, "budget": 2},
"outcome": {"pr_number": N|null, "pr_url": "<url>"|null, "merged": true|false|null,
"ci": "passed|failed|not_configured|skipped",
"deploy": "success|manual|failed|not_applicable"},
"extra": [
{"label": "Root Cause", "value": "<one-line root cause>"},
{"label": "Fix", "value": "<one-line fix>"}
],
"follow_ups": ["<any item requiring future attention>", ...]
}
WF3 has no tool-based security scan (that is WF2 Step 11.5), so
security_scan.ran is false (with zero counts and empty skipped) and the
render shows "Security Scan: not run". extra carries the Root Cause / Fix
lines WF3 has always shown. WF3's loop-back budget is 2. Each gate's
step must be distinct; conditional memorization happens within Step 9
(Code Review), so record any memorized insights in follow_ups rather than as
a second step-9 gate.
Render + persist (carry activeProject.path in as a literal — shell vars
do not persist across Bash tool calls):
python3 hooks/work_summary.py summarize \
--record-file /tmp/wf3-run-record.json \
--project-root <activeProject.path>
rc=$?
The tool's stdout is the "WF3 COMPLETE" summary — present it to the user
as-is (do not re-type it). It also appends the record to
<activeProject.path>/docs/measurements/run_records.jsonl (override with
--store or $RAWGENTIC_RUN_RECORD_STORE).
Handle the exit code:
rc == 0: record valid and persisted. Done.rc == 1: the summary still rendered (the user keeps it) but the record
FAILED validation and was not persisted — a telemetry gap. The stderr
lists the bad fields; fix /tmp/wf3-run-record.json and re-run. If it
genuinely can't be fixed, record the gap in session notes.rc == 2: usage error / unreadable record file — fix the invocation.Log a marker in claude_docs/session_notes.md:
### WF3 Step 14: Completion summary + run-record — DONE (persisted: yes/no)
work_summary.py (Step 14) and the run-record persisted (rc 0) — or, if validation failed (rc 1), the telemetry gap is recorded in session notesIf ANY item fails, go back and complete it before declaring "WF3 complete." You may NOT output "WF3 complete" until all items pass.
If this skill is invoked mid-conversation, detect the current state:
Announce the detected state before resuming: "Detected prior progress. Resuming at Step N."
After completing the bug fix, check if the fix revealed patterns worth memorizing:
If insights are found, they are curated via /reflexion:memorize in Step 9. This is conditional — skip for routine, one-off fixes.
npx claudepluginhub 3d-stories/rawgentic --plugin rawgenticCreates bite-sized, testable implementation plans from specs or requirements, with file structure and task decomposition. Activates before coding multi-step tasks.