Debugs a failing LLM prompt systematically instead of tweaking it by feel: freeze every variable, reproduce the failure and measure its rate, shrink it to a minimal case, bisect the prompt by removing one section at a time, make one surgical fix, and lock the fix in with an output contract used as a regression test. Triggers when a specific prompt produces a specific wrong, malformed, or inconsistent output, when a prompt that used to work regressed after an edit or a model change, or when someone asks why a prompt misbehaves on some inputs. For designing a new prompt from scratch use prompt-patterns instead; for version history and rollback use prompt-versioning.
./install.sh prompt-debuggername: "prompt_debugger" description: "Debugs a failing LLM prompt systematically instead of tweaking it by feel: freeze every variable, reproduce the failure and measure its rate, shrink it to a minimal case, bisect the prompt by removing one section at a time, make one surgical fix, and lock the fix in with an output contract used as a regression test. Triggers when a specific prompt produces a specific wrong, malformed, or inconsistent output, when a prompt that used to work regressed after an edit or a model change, or when someone asks why a prompt misbehaves on some inputs. For designing a new prompt from scratch use prompt-patterns instead; for version history and rollback use prompt-versioning."
A prompt fails the way code fails: for a findable reason, in a findable place. This skill treats a bad output as a bug report and works it like one. No rewriting the whole prompt and hoping. No stacking new instructions on top of old ones until nobody knows which line does what.
The method in one line: reproduce it, shrink it, bisect it, fix one thing, prove the fix, lock it so it stays fixed.
Ships with a helper CLI at bin/prompt_debug.py (standard library only) that generates section-ablation variants and checks outputs against deterministic contracts.
Record the exact setup before changing anything:
Run the frozen setup on the failing input at least 5 times at production settings.
Name the failure before fixing it. The taxonomy in references/failure-taxonomy.md covers the ten common classes: instruction conflict, buried instruction, ambiguous spec, examples teaching the wrong pattern, format drift, context dilution, data read as instructions, missing edge case, overconstraint, and plain sampling variance. Each class has a signature and the fix it usually takes. A fix aimed at the wrong class makes the prompt longer and the bug older.
Cut the input down while the failure still happens: shorter document, fewer fields, one conversation turn. Stop when removing anything else makes the failure disappear. The minimal case is the test you will rerun all day, and it is what goes into the regression set at the end. If the failure only happens on the long version, that itself is the clue: suspect context dilution or a buried instruction.
Run python3 bin/prompt_debug.py variants prompt.md --out variants/ to get the full prompt plus one variant per section with that section removed (sections are markdown headings or XML-style tags). Run every variant on the minimal case, same settings, at least 3 runs each for flaky failures.
references/teardowns.md.Write the hypothesis in one sentence before editing: "The refund example teaches the model to promise refunds, so it promises one on the escalation case." Then make the smallest edit that tests it: fix the example, move the instruction, delete the contradicting line. Resist bundling a cleanup pass into a bug fix. Bundled edits that work leave you not knowing why, and bundled edits that fail leave you not knowing which one hurt.
Write the behavior the fix restored as a contract and check outputs against it with python3 bin/prompt_debug.py check output.txt --contract contract.json. Contracts support required and forbidden strings, regex patterns, JSON validity and required keys, and word-count bounds. Deterministic rules first; where behavior is a judgment call (tone, correct escalation decision), add a short written rubric with observable criteria and grade against it separately, never a vibe. Example contract and promptfoo-style suite layout are in references/teardowns.md. Run the contract checks in CI or before any deploy that touches the prompt, exactly like a code test suite.
Every debugging session ends with a short report plus artifacts:
publisher key 2e43c913833850e6d80f939677e3de76e806d47785c0f1caaca90f9d18c98e1e
No ratings yet — be the first to rate it.