Prompt engineering
Writing and refining instructions to get reliable output from a model: being specific about the goal, stating the format, giving examples, and saying what not to do. As models improved, the craft shifted from phrasing tricks toward supplying the right context and constraints.
At a glance
- Applies to
- A single request to a model
- Core moves
- Goal, scope, check, limits
- Matters most
- Stating how success is verified
- Largely obsolete
- Phrasing tricks and role-play openers
- Broader discipline
- Context engineering
How it works
A useful prompt to an agent answers four questions before the agent has to guess: what outcome you want, where in the codebase it lives, how you will know it worked, and what is off limits. "Fix the login bug" answers none of them. "Users with a plus sign in their email get a 400 from POST /api/session; reproduce it with a failing test, fix the validation in src/server/auth.ts, and do not change the session schema" answers all four.
Naming the check matters most. An agent that can run a test, a type check, or a curl command can verify its own work and iterate. One that cannot will stop at the first version that looks plausible.
Why it matters
Early prompt engineering was full of incantations: role-play openers, threats and rewards. Current models follow plain instructions well, and many reason before answering without being asked, so those tricks add little. What still moves results is information the model cannot infer: your conventions, the file that already solves a similar problem, the reason a tempting approach was rejected last month.
Standing guidance belongs in a project file the agent reads every session. The prompt then carries only what is specific to this task, which keeps it short enough to get right.
Prompt engineering versus context engineering
The line is scope. Prompt engineering is the instruction you write for one request. Context engineering is everything the model sees on that request: system prompt, project files, retrieved documents, tool results and history. In agentic coding the second usually dominates, because your typed prompt is a small fraction of what the model reads.
Example
Goal: CSV export on /reports should include the "region" column.
Scope: src/reports/export.ts and its test file only.
Done when: `pnpm test reports` passes with a new test that asserts the header row.
Do not: change the database query or add a dependency.Common mistakes
- Spelling out implementation steps in detail while never saying how the result will be checked.
- Stacking capitalized "never" and "do not" rules instead of explaining briefly why each rule exists.
- Re-prompting a session already full of a failed attempt when a fresh session with a sharper prompt would be faster.
In Fredrin
In Fredrin the ticket description is the prompt a Worker starts from, and the docs cover what to put in it and what to leave to the agent.
Writing a good ticketRelated terms
Frequently asked questions
Is prompt engineering still worth learning?
Yes, but the valuable part is clear specification, not phrasing tricks. Stating the outcome, the scope and the verification step improves results on every current model.
Should I tell the model to think step by step?
For a reasoning model it is usually redundant, since it deliberates anyway. For a fast non-reasoning model on a multi-step problem it can still help, but a concrete acceptance check helps more.