Cody Debugging Prompt Template
You get a short list of likely causes ranked by probability, plus the exact checks to run that confirm or rule out each one. This version is set up for Cody: use @ to mention the files or symbols involved. Cody uses code from your repository as context. Below you'll find the prompt, how to run it in Cody, a worked example and answers to common questions.
Help me debug a problem. I want to find the cause, not just patch the symptom. ## Symptom [what you see, how often, and since when] ## Environment [language, framework, versions, OS, local or production] ## Relevant code and logs [paste the code involved and any log output or stack trace] ## What changed recently [deploys, dependency updates, config changes, or "nothing I know of"] ## What I have already checked [and what each check showed] ## Instructions - List the likely causes, most probable first, and say why each fits the evidence. - For each cause, give one specific check (a log line to add, a command to run, a value to print) that confirms or rules it out. - Do not propose a fix until we have narrowed it down, unless the cause is obvious. ## Output format A numbered list: cause, why it fits, how to check it. Then one line on which check to run first. Context - Files involved: [list the files, or reference them in the chat] - How I build and test: [e.g. npm test]
How to use this prompt
- 1
Open Cody
Open Cody's chat in your editor and paste the prompt.
- 2
Give it context
Use @ to mention the files or symbols involved. Cody uses code from your repository as context.
- 3
Review and iterate
Ask follow-ups in the same chat and apply edits only after reading them.
Working in Cody
- •Cody is built around codebase context, so asking "where is this used?" before asking for a change often gives better results.
- •Mention the exact symbol names you mean; similar names elsewhere in the repo can confuse the answer.
- •Start a new chat when you switch tasks so old context doesn't leak in.
Worked example
What you give it
Symptom: add_tag returns tags from earlier calls. Calling add_tag("a") then add_tag("b") gives ["a", "b"] on the second call instead of ["b"].
Environment: Python 3.11, local script.
def add_tag(tag, tags=[]):
tags.append(tag)
return tags
What changed: nothing, it has always done this.What a good answer looks like (shortened)
1. Mutable default argument (very likely). The list [] is created once, when the function is defined, and every call without a tags argument reuses that same list.
Check: print(id(tags)) inside the function. If the id is the same on every call, this is the cause.
2. A caller is passing the same list in each time (less likely, since the calls you showed pass only one argument).
Check: search for calls to add_tag that pass a second argument.
Run check 1 first. If confirmed, the fix is:
def add_tag(tag, tags=None):
if tags is None:
tags = []
tags.append(tag)
return tagsTips for better results
- •Write "What I have already checked" with results, not just actions. "Restarted the server, error still happens on the first request" rules out more than "restarted the server."
- •Keep the instruction to hold off on fixes. It forces the AI to reason from your evidence instead of pattern matching on the error text.
- •Mention the exact symbol names you mean; similar names elsewhere in the repo can confuse the answer.
- •Avoid this: Leaving out what changed recently, which is often the fastest clue to an issue that started suddenly.
Get the free prompt pack
Our best coding prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.
Variations
Intermittent bug
Add this line to Symptom: It only happens [e.g. 1 in 20 requests, under load, after midnight UTC]. Focus on timing, concurrency and caching causes.
Production only
Add this line to Instructions: I cannot attach a debugger. Suggest only checks that work through logs, metrics or config.
Add logging
Change Output format to: The exact log statements to add, where to put them, and what each output would tell us.
Save it as a Retext snippet
Retext is a free text expander for Mac. Save this prompt once, then type ;debug in any app (ChatGPT, Claude, your editor, a browser tab) and the full prompt is pasted in.
- Click Add to Retext. The prompt installs as a snippet with the trigger ;debug.
- Change the trigger in Retext if you prefer a different one.
- Type the trigger wherever you want the prompt, then fill in the brackets.
Frequently asked questions
What is the difference between debugging and bug fixing prompts?
A debugging prompt is for when you do not know the cause yet, so it asks for hypotheses and checks. A bug fix prompt is for when you can reproduce the problem and want a patch.
Do I need to paste code into Cody?
Usually not. Mention the file or symbol with @ and Cody pulls it in. Paste only output that isn't in the repo, like a stack trace.
How do I debug when I cannot share the real code?
Rewrite the problem as a small standalone example that still shows the symptom. Doing that often reveals the cause, and it avoids pasting anything confidential.
How do I reuse this prompt without copying it every time?
Click Add to Retext to save it as a snippet. Then type ;debug in any Mac app, including your AI tool, and the full prompt is pasted in.
Related Templates
Get the free prompt pack
Our best coding prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.