{"title":"Root Cause Analysis","description":"Systematically find the true root cause of a bug, not just a symptom.","tags":["rca","bug","investigation"],"content":"I have this bug: {{symptom}}\n\nHelp me find the root cause, not just a patch. Work through it:\n1. Restate the expected vs. actual behavior precisely.\n2. List the most likely hypotheses, ordered by probability.\n3. For each, name the single cheapest observation that would confirm or rule it out.\n4. Tell me exactly what to inspect, log, or run next.\n\nDo not propose a fix until we've isolated the cause. Ask for any log, stack trace, or code you need.","variables":[{"name":"symptom","description":"What's going wrong","required":true}]}
{"title":"Explain This Error","description":"Decode a stack trace or error message and pinpoint the fix.","tags":["error","stacktrace"],"content":"Explain this error and how to fix it:\n\n```\n{{error}}\n```\n\nTell me:\n1. In plain language, what the error actually means.\n2. The most likely cause given the trace.\n3. The specific line/condition to look at first.\n4. The minimal fix, and how to verify it's gone.\n\nIf the trace is ambiguous, list the top 2-3 causes and how to tell them apart.","variables":[{"name":"error","description":"The error message or stack trace","required":true}]}
{"title":"Add Strategic Logging","description":"Instrument code to capture exactly the evidence a bug requires.","tags":["logging","observability","diagnosis"],"content":"I'm chasing this intermittent bug: {{bug}}\n\nShow me where to add logging to capture the evidence needed to diagnose it. For each log point:\n- What to log (state, inputs, timing) and at what level.\n- Why that data discriminates between hypotheses.\n- How to keep it cheap enough to leave in production if useful.\n\nPrefer a few high-signal logs over blanket tracing.","variables":[{"name":"bug","description":"The bug you're tracking","required":true}]}
{"title":"Minimal Reproduction","description":"Reduce a bug to the smallest reliable reproduction.","tags":["repro","isolation"],"content":"Help me build a minimal reproduction of this bug: {{bug}}\n\nGuide me to strip it down:\n1. What to remove first to test whether it still reproduces.\n2. How to replace external dependencies with fakes/stubs.\n3. How to make it deterministic (seed randomness, pin time, fix ordering).\n\nThe goal is the smallest self-contained snippet that fails every time. Tell me what to try next based on what I report.","variables":[{"name":"bug","description":"The bug to reproduce","required":true}]}
{"title":"Why Is This Slow?","description":"Diagnose a performance problem before optimizing.","tags":["performance","profiling"],"content":"This is slow: {{what}}\n\nBefore changing anything, help me locate the bottleneck:\n1. What to measure and how (profiler, timing, counters).\n2. The usual suspects for this kind of workload, ranked.\n3. How to confirm the bottleneck is what we think before optimizing.\n\nOnce we've measured, propose the highest-leverage fix and predict its impact. Don't guess-optimize.","variables":[{"name":"what","description":"What is slow","required":true}]}
{"title":"Debug Failing Test","description":"Figure out why a specific test fails and whether the test or the code is wrong.","tags":["test","ci","flaky"],"content":"This test is failing:\n\n```\n{{test_and_output}}\n```\n\nDetermine:\n1. Is the test asserting the right thing, or is the test itself wrong?\n2. What is the actual vs. expected value, and where they diverge.\n3. The smallest change that makes it pass for the *right* reason.\n4. Whether it might be flaky (timing, ordering, shared state) rather than a real failure.","variables":[{"name":"test_and_output","description":"The test code and its failure output","required":true,"multiline":true}]}
{"title":"Bisect a Regression","description":"Track down which change introduced a regression.","tags":["regression","git-bisect","history"],"content":"Something that used to work now breaks: {{regression}}\n\nHelp me bisect it:\n1. Define a crisp pass/fail test I can run at any commit.\n2. Walk me through using git bisect (or manual halving) to find the culprit commit.\n3. Once found, explain how to read that diff to understand WHY it broke things.\n4. Recommend a fix that doesn't reintroduce whatever the bad commit was trying to do.","variables":[{"name":"regression","description":"What regressed","required":true,"multiline":true}]}
{"title":"Heisenbug Hunt","description":"Approach a bug that disappears under observation or happens only sometimes.","tags":["intermittent","race","nondeterminism"],"content":"I have an intermittent bug that's hard to pin down: {{bug}}\n\nTreat it as a non-determinism problem. Help me:\n1. Enumerate sources of non-determinism (threads, I/O ordering, time, randomness, uninitialized memory, network).\n2. Pick the cheapest way to make each source observable or controllable.\n3. Design a stress harness that makes it reproduce more often.\n\nGive me a concrete next experiment, not general advice.","variables":[{"name":"bug","description":"The intermittent bug","required":true}]}
{"title":"Diagnose a Memory Leak","description":"Find what is retaining memory that should be freed.","tags":["memory","leak","profiling"],"content":"Memory keeps growing in: {{context}}\n\nHelp me find the leak. Tell me what to capture (heap snapshots, retained-size comparison over time) and how to read it. The usual suspects: unbounded caches or maps, event listeners never removed, closures capturing large scopes, growing arrays. For each, how to confirm and fix. Give me the next concrete measurement to take.","variables":[{"name":"context","description":"Where memory is growing","required":true}]}
{"title":"Diagnose a Deadlock","description":"Find why concurrent code hangs.","tags":["deadlock","concurrency"],"content":"My program hangs here: {{symptom}}\n\nWalk me through diagnosing a deadlock: how to capture the state of all threads or tasks and see who is waiting on whom. Identify the lock-ordering or wait-cycle causing it. Propose a fix that breaks the cycle (consistent lock order, timeouts, lock-free, or removing the shared lock). Explain why your fix cannot reintroduce the deadlock.","variables":[{"name":"symptom","description":"How or where it hangs","required":true}]}
{"title":"Compare Expected vs Actual","description":"Systematically find where two outputs diverge.","tags":["diff","comparison"],"content":"Expected:\n{{expected}}\n\nActual:\n{{actual}}\n\nFind exactly where and why they diverge. Point to the first MEANINGFUL difference, not just the first textual one. Hypothesize the cause of that difference, then tell me what to inspect to confirm it. Ignore differences that are downstream effects of the first one.","variables":[{"name":"expected","description":"What you expected","required":true,"multiline":true},{"name":"actual","description":"What you got","required":true,"multiline":true}]}
{"title":"Validate an Assumption","description":"Test a belief you are relying on while debugging.","tags":["assumptions","verification"],"content":"While debugging, I am assuming: {{assumption}}\n\nThis might be wrong. Tell me the cheapest way to actually verify it (a log, an assert, a one-line check, a debugger watch). Do not let me keep building on an unverified assumption. If it is false, what does that immediately imply about where the bug really is?","variables":[{"name":"assumption","description":"The belief you are relying on","required":true}]}
{"title":"Read a Stack Trace","description":"Interpret a stack trace and find the real culprit.","tags":["stack-trace","diagnosis"],"content":"Help me read this stack trace:\n\n{{trace}}\n\nFind the frame where MY code actually went wrong, not just the top of the trace or the deepest library frame. Explain what the error type and message really mean. Translate the chain into a plain-language story of what happened. Then tell me the single most useful place to put a breakpoint or log, and what to inspect there.","variables":[{"name":"trace","description":"The stack trace","required":true,"multiline":true}]}
{"title":"Debug a Production-Only Bug","description":"Works locally, fails in production — find the difference.","tags":["production","environment"],"content":"This works locally but fails in production: {{symptom}}\n\nThe bug is almost certainly an environment difference. Walk me through the usual suspects: config and env vars, data volume and shape, concurrency and load, versions, timezones and locales, network and permissions, and resource limits. For each, how to check it quickly. Help me find the smallest difference that reproduces it, so I am not debugging blind against prod.","variables":[{"name":"symptom","description":"What fails in production","required":true}]}
{"title":"Debug with Print Statements","description":"Find a bug systematically when no debugger is handy.","tags":["print-debugging","logging"],"content":"I am stuck on this bug and only have print/log to work with: {{problem}}\n\nGuide me through binary-searching the code path: where to put the first prints to cut the suspect region in half, what to print (values AND that a line was reached), and how to read the output to halve it again. Stop me from scattering prints randomly. Tell me the one assumption to verify first, and when the output proves the bug is somewhere I wasn't looking.","variables":[{"name":"problem","description":"The bug you are chasing","required":true}]}
{"title":"Debug an Intermittent Failure","description":"Track down a bug that only happens sometimes.","tags":["intermittent","flaky","race"],"content":"This fails only sometimes: {{symptom}}\n\nIntermittent means timing, ordering, state, or external dependency. Help me make it reproducible: what to vary (load, concurrency, ordering, slow network) to raise the failure rate, and what to log so a rare failure leaves enough evidence. Identify whether it smells like a race, a resource limit, a dependency flake, or uninitialized state. Tell me how to confirm which, then fix the cause rather than adding a retry.","variables":[{"name":"symptom","description":"The intermittent symptom","required":true}]}
