Prompt Engineering — Operational Skill
Modern Best Practices (December 2025): versioned prompts, explicit output contracts, regression tests, and safety threat modeling for tool/RAG prompts (OWASP LLM Top 10: https://owasp.org/www-project-top-10-for-large-language-model-applications/).
This skill provides operational guidance for building production-ready prompts across standard tasks, RAG workflows, agent orchestration, structured outputs, hidden reasoning, and multi-step planning.
All content is operational, not theoretical. Focus on patterns, checklists, and copy-paste templates.
Claude 4+ Updates: This skill includes Claude 4.x and 4.5-specific optimizations:
- Action directives: Frame for implementation, not suggestions
- Parallel tool execution: Independent tool calls can run simultaneously
- Long-horizon task management: State tracking, incremental progress, context compaction resilience
- Positive framing: Describe desired behavior rather than prohibitions
- Style matching: Prompt formatting influences output style
- Domain-specific patterns: Specialized guidance for frontend, research, and agentic coding
- Style-adversarial resilience: Stress-test refusals with poetic/role-play rewrites; normalize or decline stylized harmful asks before tool use
Claude 4.5 Communication: Claude 4.5 is more concise by default. Request explicit summaries when needed for visibility into reasoning or work completed.
When to Use This Skill
Activate this skill when the user asks to:
- Write or improve a production-ready prompt
- Debug prompt failures or inconsistent outputs
- Create structured outputs (JSON, tables, schemas)
- Build deterministic extractors
- Design RAG pipelines with context grounding
- Implement agent workflows with tool calling
- Add hidden reasoning (CoT) without visible output
- Convert user tasks into reusable templates
- Validate prompt quality against operational checklists
- Standardize output formats across systems
Do NOT use this skill for:
- LLM theory or model architecture explanations
- General educational content about AI
- Historical background on prompt engineering
See Also: For specialized AI/LLM implementations, see "Related Skills" section at the end of this document.
Quick Reference
| Task |
Pattern to Use |
Key Components |
When to Use |
| Machine-parseable output |
Structured Output |
JSON schema, "JSON-only" directive, no prose |
API integrations, data extraction |
| Field extraction |
Deterministic Extractor |
Exact schema, missing→null, no transformations |
Form data, invoice parsing |
| Use retrieved context |
RAG Workflow |
Context relevance check, chunk citations, explicit missing info |
Knowledge bases, documentation search |
| Internal reasoning |
Hidden Chain-of-Thought |
Internal reasoning, final answer only |
Classification, complex decisions |
| Tool-using agent |
Tool/Agent Planner |
Plan-then-act, one tool per turn |
Multi-step workflows, API calls |
| Text transformation |
Rewrite + Constrain |
Style rules, meaning preservation, format spec |
Content adaptation, summarization |
| Classification |
Decision Tree |
Ordered branches, mutually exclusive, JSON result |
Routing, categorization, triage |
Decision Tree: Choosing the Right Pattern
User needs: [Prompt Type]
├─ Output must be machine-readable?
│ ├─ Extract specific fields only? → **Deterministic Extractor Pattern**
│ └─ Generate structured data? → **Structured Output Pattern (JSON)**
│
├─ Use external knowledge?
│ └─ Retrieved context must be cited? → **RAG Workflow Pattern**
│
├─ Requires reasoning but hide process?
│ └─ Classification or decision task? → **Hidden Chain-of-Thought Pattern**
│
├─ Needs to call external tools/APIs?
│ └─ Multi-step workflow? → **Tool/Agent Planner Pattern**
│
├─ Transform existing text?
│ └─ Style/format constraints? → **Rewrite + Constrain Pattern**
│
└─ Classify or route to categories?
└─ Mutually exclusive rules? → **Decision Tree Pattern**
Core Concepts vs Implementation Practices
Core Concepts (Vendor-Agnostic)
- Prompt contract: inputs, allowed tools, output schema, max tokens, and refusal rules.
- Determinism controls: temperature/top_p, constrained decoding/structured outputs, and strict formatting.
- Cost & latency budgets: prompt length and max output drive tokens and tail latency; enforce hard limits and measure p95/p99.
- Evaluation: golden sets + regression gates + A/B + post-deploy monitoring.
- Security: prompt injection, data exfiltration, and tool misuse are primary threats (OWASP LLM Top 10: https://owasp.org/www-project-top-10-for-large-language-model-applications/).
Implementation Practices (Model/Platform-Specific)
Do / Avoid
Do
- Do keep prompts small and modular; centralize shared fragments (policies, schemas, style).
- Do add a prompt eval harness and block merges on regressions.
- Do prefer “brief justification” over requesting chain-of-thought; treat hidden reasoning as model-internal.
Avoid
- Avoid prompt sprawl (many near-duplicates with no owner or tests).
- Avoid brittle multi-step chains without intermediate validation.
- Avoid mixing policy and product copy in the same prompt (harder to audit and update).
Navigation: Core Patterns
- Core Patterns - 7 production-grade prompt patterns
- Structured Output (JSON), Deterministic Extractor, RAG Workflow
- Hidden Chain-of-Thought, Tool/Agent Planner, Rewrite + Constrain, Decision Tree
- Each pattern includes structure template and validation checklist
Navigation: Best Practices
Best Practices (Core) - Foundation rules for production-grade prompts
- System instruction design, output contract specification, action directives
- Context handling, error recovery, positive framing, style matching, style-adversarial red teaming
- Anti-patterns, Claude 4+ specific optimizations
Production Guidelines - Deployment and operational guidance
- Evaluation & testing (Prompt CI/CD), model parameters, few-shot selection
- Safety & guardrails, conversation memory, context compaction resilience
- Answer engineering, decomposition, multilingual/multimodal, benchmarking
Quality Checklists - Validation checklists before deployment
- Prompt QA, JSON validation, agent workflow checks
- RAG workflow, safety & security, performance optimization
- Testing coverage, anti-patterns, quality score rubric
Domain-Specific Patterns - Claude 4+ optimized patterns for specialized domains
- Frontend/visual code: Creativity encouragement, design variations, micro-interactions
- Research tasks: Success criteria, verification, hypothesis tracking
- Agentic coding: No speculation rule, principled implementation, investigation patterns
- Cross-domain best practices and quality modifiers
Navigation: Specialized Patterns
RAG Patterns - Retrieval-augmented generation workflows
- Context grounding, chunk citation, missing information handling
Agent and Tool Patterns - Tool use and agent orchestration
- Plan-then-act workflows, tool calling, multi-step reasoning, generate–verify–revise chains with role-play + few-shot + targeted CoT per sub-agent
Extraction Patterns - Deterministic field extraction
- Schema-based extraction, null handling, no hallucinations
Reasoning Patterns (Hidden CoT) - Internal reasoning without visible output
- Hidden reasoning, final answer only, classification workflows
Additional Patterns - Extended prompt engineering techniques
- Advanced patterns, edge cases, optimization strategies
Navigation: Templates
Templates are copy-paste ready and organized by complexity:
Quick Templates
- Quick Template - Fast, minimal prompt structure
Standard Templates
- Standard Template - Production-grade operational prompt
- Agent Template - Tool-using agent with planning
- RAG Template - Retrieval-augmented generation
- Chain-of-Thought Template - Hidden reasoning pattern
- JSON Extractor Template - Deterministic field extraction
- Prompt Evaluation Template - Regression tests, A/B testing, rollout gates
External Resources
External references are listed in data/sources.json:
- Official documentation (OpenAI, Anthropic, Google)
- LLM frameworks (LangChain, LlamaIndex)
- Vector databases (Pinecone, Weaviate, FAISS)
- Evaluation tools (OpenAI Evals, HELM)
- Safety guides and standards
- RAG and retrieval resources
Related Skills
This skill provides foundational prompt engineering patterns. For specialized implementations:
AI/LLM Skills:
Software Development Skills:
Usage Notes
For Claude Code:
- Reference this skill when building prompts for agents, commands, or integrations
- Use Quick Reference table for fast pattern lookup
- Follow Decision Tree to select appropriate pattern
- Validate outputs with Quality Checklists before deployment
- Use templates as starting points, customize for specific use cases
1---2name: ai-prompt-engineering3description: Operational prompt engineering patterns, templates, and validation flows for Claude Code.4---5
6# Prompt Engineering — Operational Skill
7
8**Modern Best Practices (December 2025)**: versioned prompts, explicit output contracts, regression tests, and safety threat modeling for tool/RAG prompts (OWASP LLM Top 10: https://owasp.org/www-project-top-10-for-large-language-model-applications/).
9
10This skill provides **operational guidance** for building production-ready prompts across standard tasks, RAG workflows, agent orchestration, structured outputs, hidden reasoning, and multi-step planning.
11
12All content is **operational**, not theoretical. Focus on patterns, checklists, and copy-paste templates.
13
14**Claude 4+ Updates**: This skill includes Claude 4.x and 4.5-specific optimizations:
15
16- **Action directives**: Frame for implementation, not suggestions
17- **Parallel tool execution**: Independent tool calls can run simultaneously
18- **Long-horizon task management**: State tracking, incremental progress, context compaction resilience
19- **Positive framing**: Describe desired behavior rather than prohibitions
20- **Style matching**: Prompt formatting influences output style
21- **Domain-specific patterns**: Specialized guidance for frontend, research, and agentic coding
22- **Style-adversarial resilience**: Stress-test refusals with poetic/role-play rewrites; normalize or decline stylized harmful asks before tool use
23
24**Claude 4.5 Communication**: Claude 4.5 is more concise by default. Request explicit summaries when needed for visibility into reasoning or work completed.
25
26---
27
28## When to Use This Skill
29
30**Activate this skill when the user asks to**:
31
32- Write or improve a production-ready prompt
33- Debug prompt failures or inconsistent outputs
34- Create structured outputs (JSON, tables, schemas)
35- Build deterministic extractors
36- Design RAG pipelines with context grounding
37- Implement agent workflows with tool calling
38- Add hidden reasoning (CoT) without visible output
39- Convert user tasks into reusable templates
40- Validate prompt quality against operational checklists
41- Standardize output formats across systems
42
43**Do NOT use this skill for**:
44
45- LLM theory or model architecture explanations
46- General educational content about AI
47- Historical background on prompt engineering
48
49**See Also**: For specialized AI/LLM implementations, see "Related Skills" section at the end of this document.
50
51---
52
53## Quick Reference
54
55| Task | Pattern to Use | Key Components | When to Use |
56|------|----------------|----------------|-------------|
57| **Machine-parseable output** | Structured Output | JSON schema, "JSON-only" directive, no prose | API integrations, data extraction |
58| **Field extraction** | Deterministic Extractor | Exact schema, missing→null, no transformations | Form data, invoice parsing |
59| **Use retrieved context** | RAG Workflow | Context relevance check, chunk citations, explicit missing info | Knowledge bases, documentation search |
60| **Internal reasoning** | Hidden Chain-of-Thought | Internal reasoning, final answer only | Classification, complex decisions |
61| **Tool-using agent** | Tool/Agent Planner | Plan-then-act, one tool per turn | Multi-step workflows, API calls |
62| **Text transformation** | Rewrite + Constrain | Style rules, meaning preservation, format spec | Content adaptation, summarization |
63| **Classification** | Decision Tree | Ordered branches, mutually exclusive, JSON result | Routing, categorization, triage |
64
65---
66
67## Decision Tree: Choosing the Right Pattern
68
69```text
70User needs: [Prompt Type]
71 ├─ Output must be machine-readable?
72 │ ├─ Extract specific fields only? → **Deterministic Extractor Pattern**
73 │ └─ Generate structured data? → **Structured Output Pattern (JSON)**
74 │
75 ├─ Use external knowledge?
76 │ └─ Retrieved context must be cited? → **RAG Workflow Pattern**
77 │
78 ├─ Requires reasoning but hide process?
79 │ └─ Classification or decision task? → **Hidden Chain-of-Thought Pattern**
80 │
81 ├─ Needs to call external tools/APIs?
82 │ └─ Multi-step workflow? → **Tool/Agent Planner Pattern**
83 │
84 ├─ Transform existing text?
85 │ └─ Style/format constraints? → **Rewrite + Constrain Pattern**
86 │
87 └─ Classify or route to categories?
88 └─ Mutually exclusive rules? → **Decision Tree Pattern**
89```
90
91---
92
93## Core Concepts vs Implementation Practices
94
95### Core Concepts (Vendor-Agnostic)
96
97- **Prompt contract**: inputs, allowed tools, output schema, max tokens, and refusal rules.
98- **Determinism controls**: temperature/top_p, constrained decoding/structured outputs, and strict formatting.
99- **Cost & latency budgets**: prompt length and max output drive tokens and tail latency; enforce hard limits and measure p95/p99.
100- **Evaluation**: golden sets + regression gates + A/B + post-deploy monitoring.
101- **Security**: prompt injection, data exfiltration, and tool misuse are primary threats (OWASP LLM Top 10: https://owasp.org/www-project-top-10-for-large-language-model-applications/).
102
103### Implementation Practices (Model/Platform-Specific)
104
105- Use model-specific structured output features when available; keep a schema validator as the source of truth.
106- Align tracing/metrics with OpenTelemetry GenAI semantic conventions (https://opentelemetry.io/docs/specs/semconv/gen-ai/).
107
108## Do / Avoid
109
110**Do**
111- Do keep prompts small and modular; centralize shared fragments (policies, schemas, style).
112- Do add a prompt eval harness and block merges on regressions.
113- Do prefer “brief justification” over requesting chain-of-thought; treat hidden reasoning as model-internal.
114
115**Avoid**
116- Avoid prompt sprawl (many near-duplicates with no owner or tests).
117- Avoid brittle multi-step chains without intermediate validation.
118- Avoid mixing policy and product copy in the same prompt (harder to audit and update).
119
120## Navigation: Core Patterns
121
122- **[Core Patterns](resources/core-patterns.md)** - 7 production-grade prompt patterns
123 - Structured Output (JSON), Deterministic Extractor, RAG Workflow
124 - Hidden Chain-of-Thought, Tool/Agent Planner, Rewrite + Constrain, Decision Tree
125 - Each pattern includes structure template and validation checklist
126
127## Navigation: Best Practices
128
129- **[Best Practices (Core)](resources/best-practices-core.md)** - Foundation rules for production-grade prompts
130 - System instruction design, output contract specification, action directives
131 - Context handling, error recovery, positive framing, style matching, style-adversarial red teaming
132 - Anti-patterns, Claude 4+ specific optimizations
133
134- **[Production Guidelines](resources/production-guidelines.md)** - Deployment and operational guidance
135 - Evaluation & testing (Prompt CI/CD), model parameters, few-shot selection
136 - Safety & guardrails, conversation memory, context compaction resilience
137 - Answer engineering, decomposition, multilingual/multimodal, benchmarking
138
139- **[Quality Checklists](resources/quality-checklists.md)** - Validation checklists before deployment
140 - Prompt QA, JSON validation, agent workflow checks
141 - RAG workflow, safety & security, performance optimization
142 - Testing coverage, anti-patterns, quality score rubric
143
144- **[Domain-Specific Patterns](resources/domain-specific-patterns.md)** - Claude 4+ optimized patterns for specialized domains
145 - Frontend/visual code: Creativity encouragement, design variations, micro-interactions
146 - Research tasks: Success criteria, verification, hypothesis tracking
147 - Agentic coding: No speculation rule, principled implementation, investigation patterns
148 - Cross-domain best practices and quality modifiers
149
150## Navigation: Specialized Patterns
151
152- **[RAG Patterns](resources/rag-patterns.md)** - Retrieval-augmented generation workflows
153 - Context grounding, chunk citation, missing information handling
154
155- **[Agent and Tool Patterns](resources/agent-patterns.md)** - Tool use and agent orchestration
156 - Plan-then-act workflows, tool calling, multi-step reasoning, generate–verify–revise chains with role-play + few-shot + targeted CoT per sub-agent
157
158- **[Extraction Patterns](resources/extraction-patterns.md)** - Deterministic field extraction
159 - Schema-based extraction, null handling, no hallucinations
160
161- **[Reasoning Patterns (Hidden CoT)](resources/reasoning-patterns.md)** - Internal reasoning without visible output
162 - Hidden reasoning, final answer only, classification workflows
163
164- **[Additional Patterns](resources/additional-patterns.md)** - Extended prompt engineering techniques
165 - Advanced patterns, edge cases, optimization strategies
166
167---
168
169## Navigation: Templates
170
171Templates are copy-paste ready and organized by complexity:
172
173### Quick Templates
174
175- **[Quick Template](templates/quick/template-quick.md)** - Fast, minimal prompt structure
176
177### Standard Templates
178
179- **[Standard Template](templates/standard/template-standard.md)** - Production-grade operational prompt
180- **[Agent Template](templates/standard/template-agent.md)** - Tool-using agent with planning
181- **[RAG Template](templates/standard/template-rag.md)** - Retrieval-augmented generation
182- **[Chain-of-Thought Template](templates/standard/template-cot.md)** - Hidden reasoning pattern
183- **[JSON Extractor Template](templates/standard/template-json-extractor.md)** - Deterministic field extraction
184- **[Prompt Evaluation Template](templates/eval/prompt-eval-template.md)** - Regression tests, A/B testing, rollout gates
185
186---
187
188## External Resources
189
190External references are listed in [data/sources.json](data/sources.json):
191
192- Official documentation (OpenAI, Anthropic, Google)
193- LLM frameworks (LangChain, LlamaIndex)
194- Vector databases (Pinecone, Weaviate, FAISS)
195- Evaluation tools (OpenAI Evals, HELM)
196- Safety guides and standards
197- RAG and retrieval resources
198
199---
200
201## Related Skills
202
203This skill provides foundational prompt engineering patterns. For specialized implementations:
204
205**AI/LLM Skills**:
206
207- [AI Agents Development](../ai-agents/SKILL.md) - Production agent patterns, MCP integration, orchestration
208- [AI LLM Engineering](../ai-llm/SKILL.md) - LLM application architecture and deployment
209- [AI LLM RAG Engineering](../ai-rag/SKILL.md) - Advanced RAG pipelines and chunking strategies
210- [AI LLM Search & Retrieval](../ai-rag/SKILL.md) - Search optimization, hybrid retrieval, reranking
211- [AI LLM Development](../ai-llm/SKILL.md) - Fine-tuning, evaluation, dataset creation
212
213**Software Development Skills**:
214
215- [Software Architecture Design](../software-architecture-design/SKILL.md) - System design patterns
216- [Software Backend](../software-backend/SKILL.md) - Backend implementation
217- [Foundation API Design](../dev-api-design/SKILL.md) - API design and contracts
218
219---
220
221## Usage Notes
222
223**For Claude Code**:
224
225- Reference this skill when building prompts for agents, commands, or integrations
226- Use Quick Reference table for fast pattern lookup
227- Follow Decision Tree to select appropriate pattern
228- Validate outputs with Quality Checklists before deployment
229- Use templates as starting points, customize for specific use cases