AgentDock
1.7k
Prompt LibraryEducationCodingDebugging Practice Generator

Debugging Practice Generator

Generate a short buggy code snippet with one planted bug, then reveal it through a three-step hint ladder ending at the exact line and fix.

Used 67 times

Prompt Template

You are a coding instructor who deliberately writes broken code for students to fix, because finding a bug someone else planted builds a different skill than writing correct code the first time, and that skill only develops if the student is allowed to struggle with it before being handed the answer.

My language is [LANGUAGE:select:Python,JavaScript,Java,C++], my topic is [TOPIC:select:loops,conditionals,functions,lists or arrays,string manipulation,recursion,basic object-oriented code], and my difficulty is [DIFFICULTY:select:beginner,intermediate].

Write a short snippet, roughly ten to twenty five lines, that uses [TOPIC] in [LANGUAGE], containing exactly one planted bug matched to [DIFFICULTY]. For beginner, use an obvious category of mistake, an off-by-one error in a loop bound, a wrong comparison operator, a typo in a variable name that still runs but reads the wrong value, or a missing return statement. For intermediate, use a subtler mistake, a mutable default argument, an off-by-one in a slice or substring boundary, inverted boolean logic that only fails on certain inputs, or a variable being reassigned inside a loop when it should accumulate. State in one sentence what the snippet is supposed to do when it works correctly, without hinting at where the bug lives or what kind of bug it is.

After presenting the code and its intended behavior, give only the first hint, a vague nudge toward the general region of the code most likely responsible, such as which function or which block to look at, without naming the concept or the exact issue. Tell me plainly that I can reply with "hint 2" for a more specific hint that names the actual concept involved, "hint 3" for a hint that points at the near-exact line, or "show the fix" to see the corrected code and a full explanation of what was wrong and why. Do not skip ahead to a later hint or the fix unless I explicitly ask for it, even if my guess in between hints is wrong, since guessing wrong and trying again is part of what makes this useful practice.

When I do ask for the fix, or successfully find the bug myself and want it confirmed, explain not just what the correct code is but why the original was wrong in terms of what the computer was actually doing differently than intended, and name the general category of mistake so I can recognize it faster next time.

Variables
3

select
select
select

Use this prompt anywhere

10,000+ expert prompts for ChatGPT, Claude, Gemini, and wherever you use AI.

Get Early Access

About Debugging Practice Generator

Reading a bug fix explained to you and finding a bug yourself build two different skills, and most practice resources only offer the first one, a broken snippet with the answer sitting right below it. This tool separates the two on purpose, generating a short buggy snippet in your chosen [LANGUAGE] and [TOPIC] and telling you only what it's supposed to do, not where the problem is.

The hint system is a ladder you control the pace of. The first hint is deliberately vague, pointing at a general region of the code without naming the concept. Reply hint 2 for a more specific nudge naming what kind of mistake to look for, hint 3 for a hint pointing at the near-exact line, or show the fix when you're ready for the full answer. Nothing skips ahead automatically, even if your guess in between hints is wrong, because working through a wrong guess and trying again is most of what makes debugging practice build the skill.

Set [DIFFICULTY] to beginner for obvious mistakes like an off-by-one loop bound or a wrong comparison operator, or intermediate for subtler ones like a mutable default argument or inverted boolean logic that only fails on certain inputs. Every fix explains what the computer was doing differently than intended. Run it in the Dock Editor for a set of practice sessions, move to the find the bug challenge to debug your own code, or the error message explainer when a new error appears.

How to Use Debugging Practice Generator

1

Pick Your Language, Topic, and Difficulty

Copy it into the Dock Editor, ChatGPT, Claude, or Gemini, and set [LANGUAGE], [TOPIC], and [DIFFICULTY], and a short snippet gets generated with exactly one planted bug matched to your settings.

2

Read the Intended Behavior

You're told in one sentence what the code is supposed to do when correct, with no hint about where the bug is or what kind it is.

3

Try to Spot It With Just the First Hint

The first hint only points at a general region of the code, a function or block to focus on, without naming the actual concept involved.

4

Ask for Hint 2 or Hint 3 As Needed

Reply hint 2 for a hint that names the concept behind the bug, or hint 3 for one that points at the near-exact line, working up the ladder only as far as you actually need.

5

Request the Fix When You're Ready

Reply show the fix for the corrected code plus an explanation of what the computer was actually doing wrong, and the general category of mistake so you recognize it faster next time.

Who Uses Debugging Practice Generator

Intro CS Students Building Debugging Skills

Practice finding bugs in short generated snippets that match whatever topic your course just covered, loops, conditionals, or functions, at a difficulty matched to where you are.

Self-Taught Beginners Who Only Ever Write New Code

Most self-taught practice is writing code from scratch. This flips it, generating broken code so you build the separate skill of finding what's wrong in code you didn't write.

Students Preparing for a Debugging-Focused Exam

Generate several rounds at intermediate difficulty to practice spotting subtler bugs, mutable default arguments or off-by-one slice boundaries, before a timed test.

Coding Club or Study Group Facilitators

Generate a fresh buggy snippet for group debugging practice, letting members work through the hint ladder together before revealing the fix and discussing the category of mistake.

Frequently Asked Questions

You Might Also Like

Discover more prompts that could help with your workflow.

Skip the copy-paste

10,000+ expert-curated prompts for ChatGPT, Claude, Gemini, and wherever you use AI. Our extension helps any prompt deliver better results.

Join the waitlist for exclusive early access to the AgentDock Platform