Prompting Basics
The cheapest lever in AI engineering
Prompts are the primary interface to an LLM: role, instructions, context, output format and constraints. Well-structured prompts get dramatically better results with zero infrastructure.
What you will learn
- Structure prompts role → task → constraints → format
- Write stable, testable prompt text
- Iterate on prompts like code
What is this?
A prompt is a set of instructions + context handed to an LLM. Its anatomy: role (who the model plays), task (what to do), context (what to use), constraints (what not to do), output format (how the answer should look). Ordering and clarity measurably change quality — prompting is engineering, not magical phrasing.
Why do you need it?
- It's the only lever that costs zero infra and works on every model.
- Clear constraints prevent the 'fluent-but-off' failure mode.
- Structured prompts are debuggable and A/B-testable.
- Small refinements compound across thousands of calls.
Mental model
A clear brief beats a vague one
Prompting
Two freelancers get the same job: one is told 'summarize it', the other 'you're a reviewer; summarize in 3 bullet points, 40 words max, flag anything unverified'. The second brief produces usable work the first time — prompting is writing that brief.
How it works
- Set the role: 'You are a concise support specialist.'
- State the task in one imperative sentence.
- Include the data/context the model should use.
- Add constraints: length, tone, banned claims, required fields.
- Specify output format (bullet, JSON, table) and re-state key rules at the end.
A stable prompt skeleton.
In production
- System prompts follow the same skeleton and stay versioned.
- Prompt files live in the repo, diffable like code.
- Template variables (user data) fill context slots safely.
Best practices
- Keep prompts concrete: numbers, examples, explicit negatives.
- End with a one-line restatement of the key constraint.
- Version prompts; ship changes through the same review pipeline.
- Prefer explicit rules over 'be careful' prose.
Common mistakes
- One giant prose paragraph instead of structured instructions.
- Over-prompting ('be super ultra helpful') that dilutes real rules.
- Editing prompts in production dashboards without logs/rollback.
Common issues
Outputs ignore the instruction entirelyPrompt buried under context or ambiguous role
Restructure role/task before data; re-state rules at the end.
Strange regressions with no prompt changeModel/provider offset drift
Pin model version and re-run prompt regression tests.
Debugging tips
- Output drifts from format → the format instruction is vague; give a schema.
- Model ignores a constraint → move it to the start AND end of the prompt.
- Behavior changed after a model bump → re-check prompt anatomy against the new model.
Interview checkpoint
Quick quiz
Which element is LEAST useful in a prompt?
Key constraints should be restated near the end of a prompt.