Workflow-005: Prompt Engineering Process
Document Control
- Workflow ID: 005
- Version: 1.0
- Complexity: Low-Medium
- Duration: 30 minutes - 2 hours
- Team Size: 1 developer
Overview
Systematic process for creating, testing, and optimizing prompts for Claude AI to achieve specific outcomes.
┌─────────────────────────────────────────────────────────────────────┐
│ PROMPT ENGINEERING CYCLE │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ [1] DEFINE [2] DRAFT [3] TEST [4] REFINE │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Goals │ ──► │ Initial │ ──► │ Run & Eval│──► │ Optimize │ │
│ │ Criteria │ │ Prompt │ │ Results │ │ & Iterate│ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
│ │ │ │
│ └───────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────┘Prerequisites
- Claude API access configured
- Understanding of task requirements
- Test data or scenarios prepared
Phase 1: Define Requirements
Step 1.1: Clear Objectives
bash
# Define what success looks like
claude-code "help me define clear success criteria for this prompt engineering task"Define:
- Output format (JSON, markdown, code, etc.)
- Quality metrics (accuracy, consistency, tone)
- Constraints (length, style, technical level)
Step 1.2: Gather Examples
bash
# Collect good examples
claude-code "analyze these examples of good outputs for this task"
# Identify patterns
claude-code "what patterns make these examples effective?"Phase 2: Draft Initial Prompt
Step 2.1: Structure Components
bash
# Use prompt generator
claude-code "create a structured prompt for [task] with these requirements: [list]"Prompt Structure:
markdown
# System Context
You are an expert [domain] specialist...
# Task Description
Your task is to [specific action]...
# Input Format
I will provide: [description]
# Output Format
Respond with: [exact format]
# Guidelines
- [specific rule 1]
- [specific rule 2]
# Examples
Input: [example]
Output: [desired response]Step 2.2: Add Techniques
bash
# Chain of thought
claude-code "add chain-of-thought reasoning to this prompt"
# Few-shot examples
claude-code "add 3 diverse examples to this prompt"
# XML structure
claude-code "format this prompt using XML tags for clarity"Phase 3: Test and Evaluate
Step 3.1: Run Test Cases
python
# test_prompt.py
import anthropic
def test_prompt(prompt, test_cases):
client = anthropic.Anthropic()
results = []
for test_input in test_cases:
response = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1000,
messages=[
{"role": "user", "content": prompt + "\n\n" + test_input}
]
)
results.append({
"input": test_input,
"output": response.content[0].text,
"tokens": response.usage.output_tokens
})
return resultsStep 3.2: Evaluate Quality
bash
# Systematic evaluation
claude-code "evaluate these prompt results against our success criteria"
# Identify patterns
claude-code "what patterns do you see in successful vs failed outputs?"Best Practices
1. Be Specific
markdown
# Vague
"Write good code"
# Specific
"Write Python code following PEP 8 style guidelines with type hints and docstrings"2. Use Examples
markdown
# Few-shot prompting
Input: "Calculate tax"
Output: {"operation": "tax_calculation", "requires": ["amount", "rate"]}
Input: "Send email"
Output: {"operation": "email_send", "requires": ["recipient", "subject", "body"]}
Input: "[user_input]"
Output:3. Chain of Thought
markdown
Before providing your answer, think through this step-by-step:
1. What is the user asking for?
2. What information do I need?
3. What's the best approach?
4. What should the output look like?