Introduction to prompt engineering
What is a prompt?
A prompt is everything the model sees: system policy, the user question, retrieved docs, chat history, and tool results. The model will not infer success criteria you never wrote. OpenAI treats prompting as both craft and engineering: the same model, a clearer contract, a better output.
Prompt engineering is not spellcasting. It is writing a reviewable contract: who is speaking, what to deliver, what is forbidden, and which shape to return. Anthropic stresses be clear and direct. OpenAI stresses role in the system message, task and examples in the user message, and treating production prompts as code—git, PRs, evals.
Why this still matters in the agent era
Cursor, Claude Code, LangChain, and Dify all give the model tools. Tools stop the model from being “voice only.” They do not lower the bar for the contract:
This site’s agent courses assume you can already state a task. This primer fills that layer. See Tools and agents.
What a contract usually contains
The four core blocks live in Four building blocks. Splitting long text is in Structure and delimiters.
What this course covers — and what it does not
Covers:
- Turning a vague line into an executable contract
- Using XML / Markdown / delimiters so instructions and source material stay distinct
- Using a few examples to lock format and edge cases
- Using a schema so downstream code can ingest the result
- Regression with gold questions instead of one “feels fine” glance
Does not cover:
- Jailbreaks, bypassing safety policy, or prompt-injection attack steps
- Using prompts to impersonate people or evade review
- Hidden system prompts or undocumented model tricks
- Longer boilerplate as a substitute for a clearer task
Vendor docs move; this course sticks to stable engineering habits. Model names follow each product’s UI. Examples here use common placeholders such as gpt-4.1-mini.
Chat exploration vs production prompts
Throwaway chat is fine for exploration. If you reuse, share with a team, or run in CI, treat the prompt as source that changes product behavior. OpenAI recommends named modules, typed fill-ins, and the same PR as the feature. A Dify prompt box, Cursor rules, and LangChain system_prompt are different containers for that source.
One line: write the contract first, then pick the container.