Creative Coding Β· Session c11
Prompting (basic)
How to ask an AI for exactly the code you want β and check what it gives back.
Here's a superpower you're now ready for: an AI assistant can write code, explain it, and help fix bugs β the very same kind of assistant that helped build these lessons. But an AI is like an incredibly fast helper who does exactly what you ask, and nothing you forgot to say. Ask vaguely, and you get a vague, wrong answer. Ask well, and it's like magic. Asking well is a real skill, and it's called prompting.
And there's a golden rule that only makes sense because you did the last lesson: you must be able to check the AI's work. AI can be confidently wrong. Your debugging skills from c10 are exactly what keep you safe.
π§© The good-prompt recipe β 4 parts
GoalWhat do you actually want? "Make a game where a circle catches falling squares."
ContextWhat are you using / what have you tried? "I'm using p5.js. I'm a beginner. Here's my code so farβ¦"
LimitsAny rules? "Keep it under 40 lines. Use an array. Add a comment on each part."
ExampleShow what 'good' looks like if you can. "Make it feel like my firefly sketch from before."
The single biggest tip: be specific. Every detail you leave out, the AI has to guess β and it usually guesses wrong.
Vague vs specific β same request, very different results
β Too vague
"make a game"
The AI has to guess the language, the kind of game, the difficulty, everything. You'll get something, but almost never what you pictured.
β Specific
"In
p5.js, make a simple game: a circle at the bottom that I move with the mouse, catching squares that fall from the top. Use an
array for the squares. Keep it
under 40 lines and add a
comment on each part. I'm a
beginner, so explain anything tricky."
Goal, context (p5.js, beginner), limits (array, 40 lines, comments) β the AI now knows exactly what to build.
If the answer isn't right β don't start over, refine
Prompting is a conversation. When the code is close but not perfect, tell the AI what's wrong and ask again β it remembers what it just wrote.
β A good follow-up
"That works! Two changes: the squares fall too fast β slow them down by half. And add a
score that goes up by 1 each time the circle catches a square, shown in the top-left corner."
Asking for help with a bug
Prompting is brilliant for debugging β but give the AI everything you would need: the code, what you expected, and what actually happened.
β A good bug-help prompt
"Here's my p5.js code (pasted below). I expected the ball to bounce off the walls, but it flies straight off the screen instead. What's wrong, and how do I fix it? Please explain the fix so I understand it."
β Always check the AI's work β it can be confidently wrong.
- Read the code before you use it β don't paste in code you don't understand.
- Run & debug it with your c10 skills. AI code can have bugs too.
- Ask it to explain any line you don't get: "What does line 7 do?"
- If it insists something works and it doesn't β trust your own testing, not the AI.
Think of the AI as a fast, eager intern. It can do a lot of work in seconds, but it has no idea what you meant β only what you said. A good "boss" gives clear instructions, checks the work, and gives feedback. That's exactly what a good prompter does.
π Staying safe. Never put private information into an AI β no real full name, address, school, phone number, or passwords. And check with a parent about which AI tools are okay to use. An AI is a tool, not a friend, and not always right.
Challenges β become a prompt detective
- Fix the prompt: Improve this weak prompt so an AI could actually build it β "make something that moves." Use all four parts of the recipe.
- Feature prompt: Write a prompt asking an AI to add one new feature to your firefly sketch from c09 (for example: fireflies change colour when you click). Include the goal, that it's p5.js, and a limit.
- Bug prompt: Take Case 1 from the last lesson (the ball that won't bounce). Write a prompt asking an AI to find and fix it β remember to say what you expected vs what happened.
- Compare: If you have access to an approved AI tool (ask a parent), try your vague prompt and your specific prompt for the same idea. How different are the answers?
- Check its work: Whatever code an AI gives you, find one line you don't understand and ask it to explain that line. Never ship code you can't read.
You've levelled up π
You can now write code, hunt down your own bugs, and team up with an AI to go faster β while staying the one in charge who checks the work. That's exactly how real programmers work today. Next in the coding arc: putting it all together into your first proper mini-game.