# Prompt Engineering

> Techniques for writing effective prompts for Claude. Covers structured outputs, chain of thought, few-shot examples, and system prompt design.

- Skill: `grandamenium/prompt-engineering` (Agent Skill)
- Install (CLI): `npx skillmds@latest add grandamenium/prompt-engineering`
- Raw SKILL.md: https://api.skillmd.com/api/skills/grandamenium/prompt-engineering/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: grandamenium (https://skillmd.com/u/grandamenium)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/grandamenium/prompt-engineering

---


# Prompt Engineering

Techniques for getting the best results from Claude.

## Core Techniques

### Be Specific and Direct
Bad: "Tell me about dogs"
Good: "List the top 5 dog breeds for apartment living, with a one-sentence reason for each"

### Use XML Tags for Structure
```
<context>
You are a customer support agent for Acme Corp.
</context>

<instructions>
Respond to the customer query below. Be helpful but concise.
</instructions>

<query>
{{customer_message}}
</query>
```

### Chain of Thought
```
Think through this step by step:
1. First, identify the key variables
2. Then, set up the equation
3. Finally, solve and verify
```

### Few-Shot Examples
```
Here are examples of the format I want:

Input: "The food was great but service was slow"
Output: {"sentiment": "mixed", "food": "positive", "service": "negative"}

Input: "Everything was perfect!"
Output: {"sentiment": "positive", "food": "positive", "service": "positive"}

Now analyze: "{{input}}"
```

### Structured Output with Prefill
Start Claude's response to force a format:
```python
messages=[
    {"role": "user", "content": "Extract the name and age from: 'John is 30'"},
    {"role": "assistant", "content": '{"name": "'}
]
```

## System Prompt Design
- Define the role clearly
- Set boundaries on what to do and not do
- Include output format requirements
- Add examples of ideal responses

