Build a coding prompt that includes a Goal, Context, Constraints, and Output format.
Take a moment to think about it this way
A good coding prompt has four parts. Goal — what should happen. Context — which stack, which file, which pattern to follow. Constraints — libraries not to use, APIs not to break, accessibility requirements. Output — which file to change, what to explain back. A bare "write it for me" leaves the AI guessing. The more it has to guess, the more you'll have to fix.
Let's connect this to everyday life
Bad prompt: "build a navbar." Good prompt: "Next.js App Router, Tailwind, hamburger menu on mobile, Tutorials/Search links on desktop, 44px touch targets, only edit the existing Header.tsx, don't add any new library. When you're done, explain what you changed in 3 sentences." Written this way, the AI is far less likely to open the wrong file or break the design system.
Let's try it hands-on, together
Goal: Add a lesson complete checkbox that persists in localStorage.
Context: React client component, key = tutorialSlug/lessonSlug.
Constraints: no new dependencies, 44px target, no cookies.
Output: edit LessonCompleteToggle.tsx only + say how to test it.Be able to write a reusable coding prompt template.5-minute try-it
Write a prompt for a feature you're building, covering Goal / Context / Constraints / Output. Compare it side by side with a weak version.
One quick warning
Never treat AI output as the final, correct answer. Read through code, secrets, and user data yourself, test it, and only then put it to use.