Get the FREE Ultimate OpenClaw Setup Guide →

anthropic-prompt-engineer

npx machina-cli add skill zircote/agents/anthropic-prompt-engineer --openclaw
Files (1)
SKILL.md
4.6 KB

Anthropic Prompt Engineer

Trigger Phrases

Activate when user says:

  • "improve this prompt", "optimize my prompt", "make this prompt better"
  • "write a prompt for", "create a prompt that", "generate a prompt"
  • "prompt engineering", "prompt best practices"
  • "help me with prompting", "how should I prompt this"
  • "fix my prompt", "debug this prompt", "my prompt isn't working"
  • "using anthropic techniques", "Claude prompt tips"

Master the art and science of prompt engineering with Anthropic's proven techniques. Generate new prompts from scratch or improve existing ones using best practices for Claude AI models (Claude 4.x, Sonnet, Opus, Haiku).

What This Skill Does

Helps you create and optimize prompts for Claude AI using Anthropic's official techniques:

  • Generate new prompts - Build effective prompts from requirements
  • Improve existing prompts - Optimize prompts for better results
  • Apply best practices - Use proven techniques from Anthropic
  • Avoid common mistakes - Prevent hallucinations and unclear outputs
  • Optimize for Claude 4.x - Leverage latest model capabilities
  • Structure complex prompts - Build multi-step, production-ready prompts

Why Prompt Engineering Matters

Without proper prompting:

  • Inconsistent or incorrect outputs
  • Hallucinations and made-up information
  • Unclear or verbose responses
  • Wasted tokens and API calls
  • Poor performance on complex tasks
  • Difficulty reproducing results

With engineered prompts:

  • Precise, reliable outputs
  • Factual, grounded responses
  • Clear, formatted results
  • Efficient token usage
  • Excellent complex task performance
  • Reproducible, production-ready results

Quick Start

Generate a New Prompt

Using the anthropic-prompt-engineer skill, create a prompt that:
- Extracts structured data from customer emails
- Returns JSON format
- Handles missing information gracefully
- Includes 2 examples

Improve an Existing Prompt

Using the anthropic-prompt-engineer skill, improve this prompt:

"Analyze this code and tell me if there are bugs"

Make it more effective using Anthropic's best practices.

Core Techniques Summary

1. Be Clear and Direct

Provide explicit, unambiguous instructions. Claude 4.x excels with precise direction.

2. Use XML Tags for Structure

Organize prompts with semantic tags like <instructions>, <example>, <context>.

3. Chain of Thought (CoT)

Ask Claude to think step-by-step for complex reasoning.

4. Prefilling

Start Claude's response to guide format and style.

5. Few-Shot Examples

Provide 2-5 diverse examples showing the pattern you want.

6. Role Assignment

Give Claude a specific role or persona for appropriate context.

Reference Materials

All techniques, examples, and templates are available in the references/ directory:

  • core_techniques.md - Essential techniques with examples
  • advanced_techniques.md - Advanced methods and optimization
  • common_mistakes.md - Pitfalls to avoid
  • claude_4_best_practices.md - Claude 4.x specific guidance
  • prompt_templates.md - Ready-to-use templates

Usage Examples

Example 1: Generate a Data Extraction Prompt

Create a prompt that extracts names, emails, and phone numbers from business cards.

Example 2: Improve a Vague Prompt

Transform "Write about machine learning" into a structured, effective prompt.

Example 3: Debug a Failing Prompt

Fix inconsistent outputs by adding structure, examples, and format specification.

Best Practices Checklist

  • Instructions are clear and specific
  • Output format is explicitly defined
  • Examples align with desired behavior
  • XML tags separate different sections
  • Context is minimal but sufficient
  • Edge cases are addressed
  • Tested on diverse inputs
  • Token usage is optimized

Key Principles

  1. Empirical Approach - Test, measure, iterate
  2. Context as Resource - Every token counts
  3. Clarity Over Cleverness - Explicit instructions work best
  4. Examples Teach Best - Show, don't just tell
  5. Structure Helps - Organization reduces confusion
  6. Iteration Improves - Refine based on results

Summary

Master prompt engineering to create:

  • Reliable and consistent outputs
  • Production-ready prompts
  • Token-efficient solutions
  • Easy to maintain systems

Apply Anthropic's proven techniques for best results.


Remember: Good prompts are engineered, not guessed.

Source

git clone https://github.com/zircote/agents/blob/main/skills/anthropic-prompt-engineer/SKILL.mdView on GitHub

Overview

This skill teaches crafting and refining prompts for Claude AI using Anthropic's official techniques. It covers generating new prompts, improving existing ones, applying best practices, and avoiding common mistakes to maximize accuracy and reduce hallucinations.

How This Skill Works

Leveraging Anthropic's techniques, you build prompts from requirements, structure output with XML tags, and guide reasoning with chain-of-thought when appropriate. The approach uses prefilling, few-shot examples, and explicit role assignments to produce production-ready, reproducible results for Claude 4.x models.

When to Use It

  • When you need to generate a brand-new prompt from requirements.
  • When existing prompts produce inconsistent or hallucinated outputs.
  • When you require structured outputs (e.g., JSON, tables) from Claude.
  • When building production-ready prompts with clear formats.
  • When debugging prompts and addressing edge cases with improvements.

Quick Start

  1. Step 1: Define the goal and the required output format (e.g., JSON with specific fields).
  2. Step 2: Add semantic XML tags (<instructions>, <example>, <context>) and 2-5 diverse examples.
  3. Step 3: Test, iterate, and lock in the structure and rules for consistency.

Best Practices

  • Define explicit outputs and formats for every prompt.
  • Use XML tags to separate sections like <instructions>, <example>, <context>.
  • Provide 2-5 diverse few-shot examples showing the pattern.
  • Assign a clear role or persona to Claude for context.
  • Prefill Claude's response to guide style and structure.

Example Use Cases

  • Example: Create a data-extraction prompt that pulls names, emails, and phone numbers from business cards.
  • Example: Transform a vague prompt like 'Write about machine learning' into a structured, effective prompt.
  • Example: Debug a failing prompt by adding structure, examples, and a format specification.
  • Example: Build a prompt with CoT to guide step-by-step reasoning for a complex task.
  • Example: Design a production-ready prompt with error handling and explicit outputs.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers