Prompt engineering is the skill of writing better instructions for AI models to get better results. Think of it like learning how to give clear directions to a very smart person who is new to your team. The clearer and more specific you are, the better the output. Before you start tweaking prompts, make sure you have: * A clear definition of what a good response looks like for your use case * A way to test and measure whether your prompts are working * A first draft prompt you want to improve ---
> Show your prompt to a colleague with no context. If they would be confused by it, the AI will be confused too. Write prompts the way you would write instructions for a smart but brand-new team member. Be specific. Do not assume they know your context or your preferences. ---
### 1. Be Clear and Direct Vague prompts produce vague results. The more precisely you explain what you want, the better. **Instead of:** ``` Write something about our product. ``` **Write:** ``` Write a 3-sentence product description for a B2B SaaS tool that helps DevOps teams monitor server health. The tone should be professional and direct. The audience is engineering managers. ``` Tips: * Be specific about the format and length you want * Use numbered steps when order or completeness matters * If you want the AI to go above and beyond, say so explicitly - do not assume it will infer that --- ### 2. Give Context and Reason Explaining WHY you want something helps the AI understand your actual goal, not just the surface request. **Without context:** ``` Keep responses short. ``` **With context:** ``` Keep responses under 3 sentences. Our users read on mobile and long text causes drop-off. ``` The AI is smart enough to generalise from a good explanation. You do not need to anticipate every edge case if the reasoning is clear. --- ### 3. Use Examples Examples are one of the most reliable ways to get consistent output. A few good examples (called few-shot prompting) can dramatically improve results. When adding examples: * Make them relevant to your actual use case * Cover edge cases so the AI does not pick up unintended patterns * Wrap examples in `<example>` tags (multiple examples in `<examples>` tags) so the AI can distinguish them from instructions * 3 to 5 examples is the sweet spot ``` <examples> <example> Input: "Server went down at 3am" Output: "CRITICAL - Production outage at 03:00 IST. Immediate response required." </example> <example> Input: "CPU above 80% for 10 minutes" Output: "WARNING - Elevated CPU usage on prod-api-01. Monitor and investigate." </example> </examples> ``` --- ### 4. Structure Prompts with XML Tags When your prompt has multiple parts - instructions, context, examples, input data - XML tags help the AI understand what is what. ``` <instructions> Summarise the following incident report in 2 sentences. </instructions> <context> This summary will be sent to non-technical stakeholders. </context> <report> At 14:23 IST the payment service experienced a database connection pool exhaustion... </report> ``` Best practices: * Use consistent, descriptive tag names * Nest tags when content has a natural hierarchy * This is especially important for long or complex prompts --- ### 5. Give the AI a Role Setting a role in your system prompt focuses the AI's tone and behaviour. Even one sentence makes a difference. ```python system="You are a helpful coding assistant specialising in Python and DevOps automation." ``` The role does not need to be elaborate. Just enough to anchor the type of responses you want. --- ### 6. Long Context Tips When working with large documents (20,000+ tokens): * Put the long documents at the TOP of your prompt, above your instructions and questions. This can improve response quality by up to 30%. * Wrap each document in `<document>` tags with subtags like `<document_content>` and `<source>` * Ask the AI to quote relevant parts of the document before answering. This helps it focus on what matters. ``` <documents> <document index="1"> <source>incident-report-june-2026.pdf</source> <document_content> [paste document here] </document_content> </document> </documents> First, quote the sections of the document that are relevant to the root cause. Then summarise what happened in plain language. ``` ---
### Tell the AI what to do, not what NOT to do **Instead of:** ``` Do not use bullet points. ``` **Write:** ``` Write your response in flowing prose paragraphs. ``` Positive instructions are clearer and more reliably followed. ### Match your prompt style to the output you want If you write your prompt in bullet points, the AI tends to respond in bullet points. If you write in prose, it responds in prose. Your prompt style is itself a formatting signal. ### For detailed formatting control If you need very specific formatting, be explicit: ``` Write in clear prose paragraphs. Use markdown only for inline code and code blocks. Do not use bold text, bullet lists, or numbered lists unless the content is genuinely list-like. ``` ---
Claude models support an `effort` parameter that lets you trade off intelligence against speed and cost. | Level | Use When | | :--- | :--- | | `max` | Most demanding tasks — may have diminishing returns | | `xhigh` | Best for coding and agentic tasks | | `high` | Minimum for intelligence-sensitive work | | `medium` | Cost-sensitive workloads, some intelligence tradeoff | | `low` | Short, scoped tasks, latency-sensitive work | If the AI seems to be under-thinking a complex problem, raise the effort level rather than trying to prompt around it. For adaptive thinking (where the model decides when to think deeply): ```python client.messages.create( model="claude-opus-4-8", max_tokens=64000, thinking={"type": "adaptive"}, output_config={"effort": "high"}, messages=[{"role": "user", "content": "..."}] ) ``` ---
### Be Explicit About When to Use Tools Claude is trained to follow precise instructions. If you say "can you suggest some changes", it may suggest rather than implement. To get action: **Be explicit:** ``` Edit the file directly. Do not just suggest changes — make them. ``` ### Parallel Tool Calling Claude can run multiple tools at the same time. To ensure this happens: ``` If you intend to call multiple tools and there are no dependencies between them, make all of the independent tool calls in parallel. For example, when reading 3 files, run 3 tool calls simultaneously rather than one at a time. ``` To slow it down and run sequentially: ``` Execute operations one at a time, confirming each step before proceeding. ``` ---
Prompt engineering is the skill of writing better instructions for AI models to get better results. Think of it like lea...
> Show your prompt to a colleague with no context. If they would be confused by it, the AI will be confused too. Write p...
1. Be Clear and Direct Vague prompts produce vague results. The more precisely you explain what you want, the better. In...
Tell the AI what to do, not what NOT to do Instead of: Write: Positive instructions are clearer and more reliably follow...
Claude models support an effort parameter that lets you trade off intelligence against speed and cost. Level Use When ma...
Be Explicit About When to Use Tools Claude is trained to follow precise instructions. If you say "can you suggest some c...
Encouraging Step-by-Step Reasoning When thinking is off, you can still encourage careful reasoning: Asking the AI to Sel...
State Management Across Long Tasks For tasks that span many steps, help the AI track progress: Use JSON for structured s...
Problem: AI gives vague or generic answers Fix: Add more context, specify the audience, and provide examples of the outp...
For concise responses: For prose instead of bullets: For proactive tool use: For careful, safe agentic work: For coverin...
Technique When to Use Be specific and direct Always Add context and reasoning When the AI might misunderstand your inten...
Aligns directly with DevOps, Site Reliability (SRE), and Platform Engineering job descriptions.