CompCode Academy

Lesson 1 of 5 · Free to read

What a good developer prompt contains

What a good developer prompt contains

Audience: Final-year students and engineers in their first three years
Prerequisites: Module 02 (the four prompt patterns)
Time: about 20 minutes
What you will keep: a six-part prompt checklist
This lesson does not cover: building AI features into a product.

Why this matters

Module 02 gave you four patterns: Specify, Iterate, Constrain and Critique. This module goes one layer down, into what goes inside a prompt so that the answer is useful the first time, and into how you check the answer without reading every word.

Most weak prompts are not badly worded. They are missing a part. Once you know the parts, you can spot what is missing before you press enter.

The six parts

A prompt for a development task usually needs some of these six parts. Short tasks need fewer.

PartQuestion it answersExample
ContextWhat is the situation?"A FastAPI service, Python 3.12, tests in pytest."
TaskWhat exactly should happen?"Write a function that parses YYYY-MM-DD dates from user input."
ConstraintsWhat must not happen?"Standard library only. Do not change other files."
InputsWhat material should it work from?The function, the failing test, the error message.
Output formatWhat shape should the answer take?"Return only a unified diff." or "A JSON list of objects with keys name and reason."
ExamplesWhat does good look like?Two sample inputs with the outputs you expect.

The two parts people skip most often are constraints and output format. Skipping constraints gives you over-built answers. Skipping the format gives you answers you cannot easily check.

Ask for an answer you can check

A paragraph of advice is hard to verify. A diff, a table, a list of test cases or a JSON object is easy. Whenever you can, ask for an output you could check in a few seconds:

  • "Return only the changed function." You can paste it and run the tests.
  • "List the five risks as a table: risk, likelihood, test that catches it." You can sort, compare and discard rows.
  • "Reply with JSON: {"tests": [{"name": ..., "input": ..., "expected": ...}]}." You can parse it, count it and spot gaps.

This one habit makes the rest of this module possible. Lesson 4 is about checking outputs, and checkable outputs are what make that fast.

Role prompts: use them lightly

You will see prompts that begin "You are a senior engineer...". A role can set tone and level of detail, but it does not add knowledge the model lacks, and it is no substitute for the six parts. "Act as a senior engineer and review this" is weaker than "Review this diff for SQL injection and missing input validation; list each finding with the line number."

A before-and-after

Before:

"Write tests for my login function."

After:

"Context: Next.js API route, TypeScript, tests use Node's built-in test runner. Task: write unit tests for validateLogin(email, password) in the file below. Constraints: no new packages; do not change the function. Output: one test file; one test per case; a one-line comment above each test naming the case. Cases to include: valid input, empty email, malformed email, empty password, a password with only spaces."

The second prompt is longer, but you can check its answer against your list of cases in thirty seconds.

Exercise: grade three of your old prompts

Find three prompts you sent to an AI tool recently. For each one, mark which of the six parts it had. Then rewrite the weakest so it has every part it needs, and note what changed in the answer. Keep all three in a file called PROMPT-AUDIT.md.

Key points

  • Context, task, constraints, inputs, output format, examples.
  • Constraints and output format are the parts most often missing.
  • Ask for an output you can check in seconds.

New free lessons and course updates. Unsubscribe from any email.