prompt-engineering-patterns
Design effective prompts for LLM agents with structured input/output formats, chain-of-thought reasoning, few-shot examples, and system prompt architecture. Covers Claude-specific patterns and multi-turn conversation design. Triggers on prompt design, LLM interaction patterns, or system prompt architecture requests.
What this skill does
# Prompt Engineering Patterns
Design prompts that produce reliable, structured, high-quality outputs from language models.
## Prompt Architecture
### System Prompt Structure
```
┌─ Identity & Role ─────────────────┐
│ Who the model is, what it does │
├─ Context & Constraints ───────────┤
│ Domain knowledge, guardrails │
├─ Output Format ───────────────────┤
│ Structure, length, style │
├─ Examples (Few-Shot) ─────────────┤
│ Input/output pairs │
├─ Instructions ────────────────────┤
│ Step-by-step task guidance │
└────────────────────────────────────┘
```
### Priority Layering
When instructions conflict, models follow this precedence:
1. **System prompt** — Highest structural authority
2. **Most recent user message** — Immediate task context
3. **Earlier conversation** — Background context
4. **Training data** — Default behaviors
## Core Patterns
### Structured Output
```xml
<system>
Analyze the given code and return findings in this exact format:
<analysis>
<summary>One-sentence overall assessment</summary>
<findings>
<finding severity="high|medium|low">
<location>file:line</location>
<issue>Description</issue>
<fix>Recommended fix</fix>
</finding>
</findings>
<score>1-10</score>
</analysis>
</system>
```
### Chain of Thought
```
Before answering, think through the problem step by step:
1. Identify the core question
2. List relevant constraints
3. Consider 2-3 approaches
4. Evaluate tradeoffs
5. Recommend the best approach with reasoning
Show your reasoning in <thinking> tags, then give your final answer.
```
### Few-Shot Examples
```
Classify the following commit messages by type.
Examples:
- "Add user authentication with JWT" → feat
- "Fix null pointer in dashboard render" → fix
- "Update README with API documentation" → docs
- "Refactor database connection pooling" → refactor
Now classify:
- "Implement rate limiting for API endpoints" →
```
### Role Prompting
```
You are a senior security engineer reviewing code for a financial services application.
Your priorities are:
1. Authentication and authorization flaws
2. Data exposure risks
3. Input validation gaps
4. Dependency vulnerabilities
Review with the paranoia appropriate for systems handling financial data.
```
## Advanced Patterns
### Constraint Prompting
```
Generate a Python function with these constraints:
- No external dependencies (stdlib only)
- Must handle the empty input case
- Must include type hints
- Maximum 20 lines
- Must include a docstring
```
### Decomposition
Break complex tasks into sequential sub-prompts:
```
Step 1: Analyze the current code structure
Step 2: Identify the specific change needed
Step 3: Write the minimal diff
Step 4: Verify the change doesn't break existing behavior
```
### Self-Verification
```
After generating your response:
1. Re-read the original question
2. Check that every requirement is addressed
3. Verify any code compiles/runs mentally
4. Flag any assumptions you made
```
### Negative Prompting
Specify what NOT to do:
```
Important:
- Do NOT add error handling beyond what was requested
- Do NOT refactor surrounding code
- Do NOT add comments explaining obvious operations
- Do NOT change the function signature
```
## Claude-Specific Patterns
### XML Tags for Structure
Claude responds well to XML-tagged sections:
```xml
<context>
Repository: a-i--skills
Organ: IV (Orchestration)
Current branch: feature/governance-aware-skill-taxonomy
</context>
<task>
Create a new skill following the existing frontmatter format.
</task>
<constraints>
- Match the YAML frontmatter schema exactly
- Name must match directory name
- Include governance metadata fields
</constraints>
```
### Extended Thinking
For complex reasoning tasks, allocate thinking budget:
```python
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=16000,
thinking={
"type": "enabled",
"budget_tokens": 10000,
},
messages=[{"role": "user", "content": prompt}],
)
```
### Tool Use
Define tools for structured interaction:
```python
tools = [{
"name": "create_skill",
"description": "Create a new skill file",
"input_schema": {
"type": "object",
"required": ["name", "category", "description"],
"properties": {
"name": {"type": "string", "pattern": "^[a-z][a-z0-9-]*$"},
"category": {"type": "string"},
"description": {"type": "string", "maxLength": 600},
},
},
}]
```
## Multi-Turn Conversation Design
### Context Window Management
```
Conversation budget allocation:
- System prompt: ~2K tokens (fixed)
- Conversation history: ~50K tokens (growing)
- Current task context: ~10K tokens (variable)
- Response space: ~4K tokens (reserved)
```
### Conversation Summarization
When context grows large, summarize earlier turns:
```
<conversation_summary>
In previous messages, we:
1. Identified the bug in auth middleware (missing token refresh)
2. Agreed on fix approach (add refresh check before expiry)
3. Implemented the fix in src/auth/middleware.ts
</conversation_summary>
Now continuing with testing...
```
## Prompt Testing
### Evaluation Criteria
| Criterion | Test Method |
|-----------|-------------|
| Correctness | Compare output against known-good answers |
| Consistency | Run same prompt 5x, check variance |
| Format compliance | Validate output structure programmatically |
| Edge cases | Test with empty input, long input, adversarial input |
| Robustness | Rephrase prompt, check output stability |
### A/B Testing Prompts
```python
async def evaluate_prompts(prompts: list[str], test_cases: list[dict]) -> dict:
results = {}
for i, prompt in enumerate(prompts):
scores = []
for case in test_cases:
output = await generate(prompt, case["input"])
score = evaluate(output, case["expected"])
scores.append(score)
results[f"prompt_{i}"] = sum(scores) / len(scores)
return results
```
## Anti-Patterns
- **Vague instructions** — "Do something good" vs. "Return a JSON object with exactly 3 fields"
- **Conflicting constraints** — "Be concise" + "Explain thoroughly"
- **Prompt injection vulnerability** — Always separate system instructions from user input
- **No output format spec** — Always specify expected format for machine-consumed output
- **Over-prompting** — Adding unnecessary instructions that dilute important ones
- **Ignoring model capabilities** — Using chain-of-thought when a simple instruction suffices
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.