Skip to content

FREE LESSON · MODULE 03

The anatomy of a good prompt

A real lesson from the course. Learn to write a precise request, compare three examples and take away a reusable template for your project.

12 min reading100% writtenNo signup

The quality of what Claude Code produces depends directly on the quality of your requests. A good prompt isn't a magic formula: it's a short, clear specification. This lesson gives you a reusable structure.

The 6 elements of a good prompt

  1. Goal: what you want to achieve, in one sentence.
  2. Context: the project, the stack, the relevant files, what already exists.
  3. Expected behavior: what the user should see and be able to do.
  4. Constraints: security, conventions, libraries to use or avoid.
  5. Success criteria: how you'll know it's done (tests, commands, checks).
  6. Way of working: plan first? one step at a time? questions before coding?

Example: a sign-in page

Bad prompt

Make a login page.

Why it's not enough: which framework? which authentication system? which fields? what happens after signing in? on error? The AI will guess, and you'll spend more time fixing than describing.

Better prompt

Create a sign-in page with email and password using Supabase Auth. After signing in, redirect to /dashboard. Show an error message if the credentials are wrong.

Better: the technology, fields, redirect, and error case are specified. Still missing: project context, security constraints, and success criteria.

Excellent prompt

Goal: add email and password sign-in.

Context: Next.js project (App Router, strict TypeScript), Tailwind and shadcn/ui. Supabase is already configured: clients in src/lib/supabase/server.ts and src/lib/supabase/client.ts. The sign-up page src/app/register/page.tsx exists: match its style.

Expected behavior:

  • /login page with email and password fields, and a "Forgot password?" link;
  • field validation with Zod (valid email, non-empty password);
  • sign-in through a Server Action using signInWithPassword;
  • on success, redirect to /dashboard;
  • on failure, a generic message "Incorrect email or password" (don't reveal whether the email exists);
  • if the email isn't confirmed, a message asking the user to check their inbox;
  • button disabled while submitting.

Constraints: no secret key client-side; accessible (labels, visible focus, error messages linked to fields).

Success criteria: npm run lint and npx tsc --noEmit pass; I can sign in with a test account and I'm redirected; a wrong password shows the error message.

Way of working: first present your plan and the list of files you'll create or modify, then wait for my approval.

This prompt is longer, but it saves a lot of time: fewer back-and-forths, a result consistent with the existing code, and clear criteria to verify.

Do prompts always need to be this long?

No. Match the precision to the risk and size of the task:

  • Small tweak (change a color, fix a typo): one sentence is enough.
  • New feature: goal, context, behavior, criteria.
  • Sensitive topic (payments, permissions, personal data): everything, including security constraints and tests.

Key takeaways

  • Goal, context, behavior, constraints, success criteria, way of working.
  • The riskier the task, the more precise the prompt.
  • Ask for a plan before execution on important tasks.

Your turn · 10 minutes

Turn your idea into a first prompt.

Choose a small feature: a contact form, a task list or an appointment booking. Fill in the template, then check that every success criterion can be tested.

GOAL
I want to build: …

CONTEXT
My audience: …
My existing project and tools: …

EXPECTED BEHAVIOUR
The user should be able to: …
On error: …

CONSTRAINTS
Do not expose secret keys. Check permissions on the server.

SUCCESS CRITERIA
I will verify that: …

WORKING METHOD
Propose a plan, identify missing information, then proceed in small, verifiable steps.

How do you check your answer?

Your prompt names a user, an observable action, an error case and a specific test. ‘Make a nice website’ is vague. ‘The form rejects an invalid email, keeps the other fields and displays a keyboard-accessible error’ is testable. Ask the AI to clarify missing information before coding.