Chapter 14

Troubleshooting

"Something's wrong." Find the answer fast.

Every tool breaks eventually. The question is whether you have a diagnostic path or just a prayer. Start with pforge smith — it catches 80% of issues in 5 seconds.

Key terms: Glossary defines every Plan Forge term. If you see "scope contract," "validation gate," "slice," or "applyTo" and aren't sure what they mean, check there first.

Diagnostic Tools

Troubleshooting decision tree: start with pforge smith, branch to execution, guardrails, dashboard, or setup issues
ToolWhat It ChecksWhen to Use
pforge smithEnvironment, VS Code config, setup health, versionFirst thing when anything seems off
pforge checkSetup file existence and validityAfter setup or update
pforge diagnose <file>Multi-model bug investigation on a specific fileWhen a slice fails and you can't see why

Agent Isn't Following Guardrails

SymptomCauseFix
AI ignores coding standardsInstruction files not loadingCheck applyTo pattern matches the file you're editing. Run pforge smith to verify file counts.
Wrong instructions loadingapplyTo glob too broadNarrow the pattern — use **/auth/** instead of **
Guardrails load but AI ignores themContext budget exceededReduce copilot-instructions.md to <80 lines. Remove applyTo: '**' from non-essential files.
Project Principles not enforcedPROJECT-PRINCIPLES.md missingRun the project-principles prompt. The instruction file activates only when this file exists.

Plan Execution Fails

SymptomCauseFix
Gate fails with build errorsCode doesn't compileFix the build error, then pforge run-plan --resume-from N
Gate fails — tests regressNew code broke existing testsFix the regression. Check if scope contract is too broad.
Slice times outContext window exhausted or model overloadedSplit the slice into smaller chunks. Try a different --model.
Model returns errorAPI key invalid or rate limitedCheck XAI_API_KEY / OPENAI_API_KEY env vars. Wait for rate limit reset.
Scope violation detectedAI touched forbidden filesThe PreToolUse hook should catch this. If not, tighten the Scope Contract.
Escalation exhaustedAll models in chain failedReview the slice — it may be too complex. Break into sub-slices or simplify gates.

Dashboard Won't Load

SymptomCauseFix
Connection refused on :3100Server not runningnode pforge-mcp/server.mjs
Port already in useAnother process on 3100node pforge-mcp/server.mjs --port 4100 or kill the conflicting process
Blank page loadsMissing node_modulescd pforge-mcp && npm install
WebSocket disconnectsFirewall or proxy blocking :3101Allow port 3101, or set WS_PORT env var
No data in Runs/Cost tabsNo execution history yetRun a plan first: pforge run-plan

Setup Failed

SymptomCauseFix
"Preset not found"Typo in preset nameValid presets: dotnet, typescript, python, java, go, swift, rust, php, azure-iac
Permission deniedRead-only directory or no git accessCheck file permissions. Run from a writable directory.
Existing files conflictPrevious setup existsUse -Force flag to overwrite, or pforge update for selective updates
Wrong files installedIncorrect preset for your stackRe-run: .\setup.ps1 -Preset <correct-preset> -Force

Costs Are Too High

StrategySavingsHow
Use cheaper execution model50–70%Set modelRouting.execute to a smaller model
Reserve expensive model for review30–50%modelRouting.review: "claude-opus-4.6"
Raise quorum threshold20–40%--quorum-threshold 8 (fewer slices trigger consensus)
Reduce context per slice10–20%Use targeted Context: lists (see Chapter 5)
Preview before runningN/Apforge run-plan --estimate

Grok Image Generation Crashes Session

xAI Grok Aurora returns JPEG bytes regardless of requested format. If raw bytes with wrong MIME type enter the conversation history, the session becomes unrecoverable.

Current mitigations: The MCP tool returns text-only responses (file path + metadata, never raw base64). The generateImage() function detects actual format via magic bytes and converts using sharp. Sessions should be safe — but if you encounter the MIME mismatch error, start a fresh session.

Safe workflow: Use .jpg extensions (matches Grok's native output), generate art in dedicated sessions, or use the REST API: POST /api/image/generate.

Common Error Messages

ErrorCauseFix
No .forge.json foundNot in a Plan Forge projectRun pforge init or setup.ps1
templateVersion mismatchFramework files outdatedpforge update
No API key configuredMissing env var for image/analysisSet XAI_API_KEY or OPENAI_API_KEY
Plan parsing failedMalformed plan fileCheck for missing ## Execution Slices section or broken markdown
Gate command failed (exit 1)Build or test failureFix the code, then --resume-from N
DRIFT DETECTEDForbidden file modifiedRevert the forbidden change, re-run the slice

Getting Help

📄 Full reference: FAQ, COPILOT-VSCODE-GUIDE.md