AI / A CONCEPT NOTE
Prompt Engineering
crafting inputs to get reliable, structured outputs from LLMs
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
The way you phrase a prompt dramatically affects the quality and format of an LLM response. Good prompt engineering uses clear instructions, few-shot examples (showing the model what you want), role-setting ('You are a senior DevOps engineer'), and output formatting (JSON, markdown). Systematic approaches like chain-of-thought improve reasoning tasks.
02 / FOLLOW THE MECHANISM
How a prompt is structured
System message
sets the model's persona and constraints — e.g., 'You are a Terraform expert. Answer concisely.'
Few-shot examples
provide 1-3 examples of ideal Q&A pairs to demonstrate format, tone, and depth.
Context injection
retrieved documents, schema definitions, or API docs are inserted as grounding material.
User query
the actual question or task, often with explicit instructions like 'respond in JSON with keys: summary, steps, risk.'
Output parsing
the response is validated against the expected format and error-handled if the LLM deviates.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
test prompts via Ollama locally
ollama run llama3 'Write a prompt that...'The ellipsis omits required code or values. This sketch is not runnable as written.
call OpenAI with a system message
curl -X POST -d '{"model":"gpt-4","messages":[{"role":"system","content":"You are a terse Linux expert"}]}' https://api.openai.com/v1/chat/completions05 / CHECK YOURSELF
Could you explain Prompt Engineering to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.
Up next in AI engineeringFine-Tuningspecializing a base model on your domain data