All skills
jamesrochabrun avatar

/anthropic-prompt-engineer

@28ac9aa

Master Anthropic's prompt engineering techniques to generate new prompts or improve existing ones using best practices for Claude AI models.

Use this Skill: https://skilld.dev/gh/jamesrochabrun/skills/anthropic-prompt-engineer

This session only. Nothing lands on disk.

referencescore_techniques.md

≈861 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Core Prompt Engineering Techniques

Anthropic's official prompt engineering techniques for Claude AI models.

1. Be Clear and Direct

What it is: Provide explicit, unambiguous instructions

Why it works: Claude 4.x models are trained for precise instruction following

When to use:

  • Any prompt where clarity matters
  • Production systems requiring consistent output
  • Complex tasks with specific requirements

How to apply:

  • State exactly what you want
  • Specify format, length, and tone
  • Avoid vague or ambiguous language
  • Include specific constraints and requirements

Examples:

❌ Bad:

Tell me about Python

✅ Good:

Write a 300-word explanation of Python's list comprehensions for intermediate developers.
Include:
- 3 practical examples
- Performance considerations
- Common pitfalls to avoid

2. Use XML Tags for Structure

What it is: Organize prompts with XML tags like <instructions>, <example>, <context>

Why it works: Claude was trained with XML tags, naturally recognizing them as structural elements

When to use:

  • Separating data from instructions
  • Complex prompts with multiple sections
  • When working with variable content
  • Production systems requiring clear boundaries

Common tags:

  • <instructions> - Main task description
  • <example> - Few-shot examples
  • <context> - Background information
  • <document> - Input data to process
  • <output_format> - Expected result format
  • <constraints> - Limitations and rules

Example:

<instructions>
Analyze the customer review below and extract structured sentiment data.
</instructions>

<review>
The product arrived damaged and customer service was unhelpful.
</review>

<output_format>
Return JSON with:
- "sentiment": "positive" | "negative" | "neutral"
- "confidence": 0.0 to 1.0
- "key_issues": array of strings
</output_format>

3. Chain of Thought (CoT)

What it is: Ask Claude to think step-by-step before providing final answer

Why it works: Breaking down problems leads to more accurate, nuanced, and reliable responses

When to use:

  • Math and logical reasoning problems
  • Complex analysis tasks
  • Multi-step processes
  • When accuracy is critical
  • Debugging and troubleshooting

How to apply:

  • Add "Think step by step" to your prompt
  • Request reasoning in <thinking> tags
  • Ask Claude to show its work
  • Guide the thinking process with specific steps

Examples:

Basic CoT:

Solve this problem step by step:

<problem>
A store sells apples for $2 each. If you buy 5 or more, you get 20% off.
How much do 7 apples cost?
</problem>

Think through this step by step, showing your work.

Structured thinking:

Analyze this code for bugs. Use the following process:

<thinking>
1. Read and understand the code structure
2. Identify potential issues
3. Assess severity of each issue
4. Recommend fixes
</thinking>

<code>
[code here]
</code>

4. Prefilling Claude's Response

What it is: Provide the beginning of Claude's response to guide output format and style

Why it works: Immediately directs the response in the desired direction

When to use:

  • Forcing specific output formats (especially JSON)
  • Controlling tone and style
  • Ensuring responses start correctly
  • Avoiding preambles

Examples:

JSON output:

User: Extract the name, email, and phone from this text: [text]

Source: SKILL.md on GitHub

No alerts17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    The skill is a collection of educational resources and templates for prompt engineering. It contains no executable code, malicious instructions, or security vulnerabilities.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer7mo

    6 files scanned · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 28ac9aa. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 11 months ago

README badge

README badge for jamesrochabrun/skills/anthropic-prompt-engineer