fix ยท git:20260630.8299393 ยท 2026-06-30 ยท sha256 ffff137baad589e8
fix git:20260630.8299393A
Immutable. This exact content never changes and is served at /api/v1/blob/ffff137baad589e8.
---
name: fix
description: Plan-aware auto-fix loop after coding. Runs tests, lint, format, and graph checks. Updates plan task status. Use after execute/tdd.
mcp: code-review-graph
---
# /supergraph:fix
Plan-aware auto-fix loop. Ensure tests pass, lint clean, format applied, graph risks handled.
## Usage
`/supergraph:fix` | `/supergraph:fix plan auth-login` | `/supergraph:fix plan auth-login task 2`
## Steps
### 0. Announce
"๐ง /supergraph:fix โ starting auto-fix loop..."
### 1. Select Plan Context
0 plans โ skip | 1 โ use | >1 โ ask | `plan <slug>` โ match.
Read `## Environment Context`, fix scoped task or all in-progress/stuck tasks.
### 2. Get Commands
Read from plan `## Environment Context` or `.supergraph-env` (set by `/supergraph:scan`). Missing โ STOP, run scan first.
Missing command โ skip phase, report as `SKIP`.
### 3. Get Changed Files
```bash
git diff --name-only && git diff --cached --name-only
```
Reindex changed files before graph analysis (graph may be stale after edits):
```
mcp__code-review-graph__index_incremental(files=[changed])
```
Graph: `get_minimal_context_tool()`, `get_impact_radius_tool(files=[changed], depth=3)`, `query_graph(query_type="tests", target=each_file)`.
No changed files and no in-progress/stuck tasks โ STOP: nothing to fix.
### 3b. Serena pre-loop diagnostics (optional)
If `/supergraph:scan` was not run this session, call `mcp__serena__initial_instructions()` first. Skip entire step if `SERENA_ACTIVE=false` in `.supergraph-env`.
Before starting the fix loop, triage IDE-level errors with Serena:
```
for each changed_file:
mcp__serena__get_diagnostics_for_file(file=changed_file)
```
Fix any type errors found before entering the loop โ reduces iterations by catching obvious errors early.
Skip if Serena unavailable.
### 4. Auto-Fix Loop (max 3 iterations)
At iteration start: "๐ง Fix iteration N/3 โ running tests..."
| Phase | Action |
|---|---|
| **Reproduce** | Smallest failing command + expected vs actual. Classify: assertion / crash / timeout / env / data pollution / race. |
| **Tests** | Run targeted tests (from graph) else `$TEST_CMD`. FAIL โ trace to root cause, fix source. Don't modify tests unless demonstrably wrong. |
| **Serena fix** | After source fix: `mcp__serena__get_diagnostics_for_file(file=<fixed_file>)` โ confirm fix didn't introduce new type errors before re-running suite. For body fixes: prefer `mcp__serena__replace_symbol_body(symbol=<fn>)`. For renames: `mcp__serena__rename_symbol(old, new)`. Skip if Serena unavailable. |
| **Format+Lint** | `$FORMAT_CMD` then `$LINT_CMD`. If format changed files โ re-run lint. |
| **Graph** | `index_incremental(files=[changed])` first, then `detect_changes_tool()`, `get_surprising_connections_tool()`, `get_knowledge_gaps_tool()`, `refactor_tool(action="dead_code")`. CRITICAL โ fix. WARNING โ fix or record. |
| **Decide** | All clean โ break. Tests/lint fail โ continue loop. |
### 5. Update Plan Status (if plan exists)
- Succeeded โ `Status: completed`
- Failed after 3 โ `stuck` + append STUCK log
- Never mark completed if tests or lint fail
### 6. Report
```
## Auto-Fix Report
- Iterations: N/3 | Tests: PASS|FAIL|SKIP | Lint: PASS|FAIL|SKIP | Format: PASS|SKIP
- Graph: PASS|WARNING|CRITICAL | Plan status: updated|none
- Issues: [list or "none"]
Next: /supergraph:verify โ /supergraph:review
```
## Rules
- Max 3 fix iterations
- Never commit broken code
- Never use `git add -A`
- Never hide failures by weakening tests
- Prefer source fixes over test edits
- CRITICAL graph findings: fix or escalate
- Warnings: fix or report
- Prefer `mcp__serena__replace_symbol_body` for body fixes and `mcp__serena__rename_symbol` for renames when Serena is available