# Prompting

> Prompting is the craft of writing the text a model responds to. Good prompts state the instruction clearly, supply examples when the format matters, set a role or system prompt that frames the whole conversation, ask for output in a usable shape, and improve through deliberate iteration rather than repeated retries.

Page: https://schubergphilis.github.io/ai-training/topics/concepts/prompting/
License: CC BY-SA 4.0, https://creativecommons.org/licenses/by-sa/4.0/

*Concepts* · topic `concepts/prompting`

Prompting is the craft of writing the text a model responds to. Good prompts state the instruction clearly, supply examples when the format matters, set a role or system prompt that frames the whole conversation, ask for output in a usable shape, and improve through deliberate iteration rather than repeated retries.

## Concepts

- **Instruction**: The part of a prompt that says what to do. A clear instruction names the task, the input it applies to, the constraints to respect and what a good result looks like. Vague instructions are filled in by the model with plausible defaults, so most prompt failures trace back to something the instruction left unsaid rather than to the model misunderstanding. [glossary](https://schubergphilis.github.io/ai-training/glossary/#instruction)
- **Example (few-shot)**: One or more worked input-output pairs placed in the prompt so the model can copy the pattern. Few-shot examples are the most reliable way to fix a format, tone or edge-case behavior that is hard to describe in words. Two or three well-chosen examples usually beat a long paragraph of rules, and a bad example teaches the mistake just as well. [glossary](https://schubergphilis.github.io/ai-training/glossary/#few-shot-example)
- **Role and system prompt**: Text set before the conversation starts that frames every later turn. A system prompt typically assigns a role, sets tone, states standing rules and lists what the model must never do. In chat products the vendor writes one you cannot see; in agents and custom applications the developer writes it, and it is where recurring behavior is fixed. [glossary](https://schubergphilis.github.io/ai-training/glossary/#role-and-system-prompt)
- **Iteration**: Improving a result by changing the prompt after reading the output, rather than resending the same prompt hoping for a better draw. Each round adds a missing constraint, an example of the failure, or a sharper definition of done. Iteration is the normal way to reach a reliable prompt; a first attempt that works is the exception. [glossary](https://schubergphilis.github.io/ai-training/glossary/#iteration)
- **Structured output**: Asking the model to answer in a fixed shape, such as a table, a numbered list with named fields, or a machine-readable format like JSON, so the next step can use the result without a human reformatting it. Naming the fields and giving one example of the shape makes the output far more consistent and makes missing information visible. [glossary](https://schubergphilis.github.io/ai-training/glossary/#structured-output)

## Links

- **Builds on:** [How language models work](https://schubergphilis.github.io/ai-training/topics/concepts/how-models-work/)
- **Leads to:** [What an agent is](https://schubergphilis.github.io/ai-training/topics/concepts/what-is-an-agent/), [Working with an assistant](https://schubergphilis.github.io/ai-training/topics/using-agents/assistant-work/)
- **Competencies drawing on it:** [Writes prompts that get reliable results](https://schubergphilis.github.io/ai-training/competencies/concepts/prompts-reliably/)

## Lessons

- [Change the prompt before you retry](https://schubergphilis.github.io/ai-training/concepts/iterating-on-a-prompt/) (tutorial)
- [Show one example](https://schubergphilis.github.io/ai-training/concepts/one-example/) (tutorial)
- [Instruction, context and format](https://schubergphilis.github.io/ai-training/concepts/prompt-anatomy/) (tutorial)
- [Output the next step can use](https://schubergphilis.github.io/ai-training/concepts/structured-output/) (tutorial)
- [The prompt before the conversation](https://schubergphilis.github.io/ai-training/concepts/system-prompt/) (explanation)

## Sources

- `DLAI-1` [ChatGPT Prompt Engineering for Developers](https://www.deeplearning.ai/courses/chatgpt-prompt-eng), DeepLearning.AI (course)
- `DLAI-3` [AI Prompting for Everyone](https://www.deeplearning.ai/courses/ai-prompting-for-everyone), DeepLearning.AI (course)
- `Brown 2020` [Language Models are Few-Shot Learners](https://proceedings.neurips.cc/paper/2020/hash/1457c0d6bfcb4967418bfb8ac142f64a-Abstract.html), Advances in Neural Information Processing Systems 33 (NeurIPS 2020) (paper)
- `Learn Prompting` The community prompt engineering guide, Learn Prompting (reference)
- `Academy ai-fluency-framework-foundations` [AI Fluency: Framework and foundations](https://academy.claude.com/courses/ai-fluency-framework-foundations), Claude Academy (course)
- `Academy building-with-the-claude-api` [Building with the Claude API](https://academy.claude.com/courses/building-with-the-claude-api), Claude Academy (course)
