From ai-helpers
Prompt design techniques for LLMs: structure, examples, reasoning patterns, and optimization. Invoke whenever task involves any interaction with AI instructions — crafting, debugging, improving, or evaluating prompts for skills, agents, output styles, or system configurations.
npx claudepluginhub xobotyi/cc-foundry --plugin ai-helpersThis skill uses the workspace's default tool permissions.
**Every prompt is an interface contract — clarity of intent determines quality of output.** Apply when crafting skills,
references/agent-authored-prompts.mdreferences/agent-patterns.mdreferences/claude-specific.mdreferences/learning-paradigms.mdreferences/long-context.mdreferences/optimization-strategies.mdreferences/persistent-context.mdreferences/reasoning-techniques.mdreferences/security.mdreferences/workflow-patterns.mdGuides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Automates semantic versioning and release workflow for Claude Code plugins: bumps versions in package.json, marketplace.json, plugin.json; verifies builds; creates git tags, GitHub releases, changelogs.
Every prompt is an interface contract — clarity of intent determines quality of output. Apply when crafting skills, agents, output styles, system prompts, or any AI instructions.
${CLAUDE_SKILL_DIR}/references/security.md]${CLAUDE_SKILL_DIR}/references/reasoning-techniques.md] CoT variants (zero-shot,
few-shot, auto), Tree-of-Thoughts, Self-Consistency, extended thinking details, academic citations${CLAUDE_SKILL_DIR}/references/learning-paradigms.md] In-context learning theory, paradigm
spectrum details, example ordering research, generated knowledge prompting${CLAUDE_SKILL_DIR}/references/workflow-patterns.md] Prompt chaining examples, iterative
refinement cycles, meta prompting templates${CLAUDE_SKILL_DIR}/references/security.md] Injection attack types, jailbreaking techniques,
defense strategies, security checklist${CLAUDE_SKILL_DIR}/references/optimization-strategies.md] Prompting vs RAG vs
fine-tuning decision flow, DSPy, cost-benefit analysis${CLAUDE_SKILL_DIR}/references/claude-specific.md] Prefilling examples, system prompt API
usage, extended thinking API details, technique combinations${CLAUDE_SKILL_DIR}/references/long-context.md] Document organization patterns, XML structuring
for multi-doc, query patterns, chunking strategies${CLAUDE_SKILL_DIR}/references/agent-patterns.md] ReAct, PAL, Reflexion, ART
implementation patterns, pattern selection table${CLAUDE_SKILL_DIR}/references/agent-authored-prompts.md] Workflow for agents writing
prompts, decomposition, self-evaluation, failure modes, quality dimensions, optimization patterns${CLAUDE_SKILL_DIR}/references/persistent-context.md] How techniques transfer to
skills/system prompts, research citations, declarative vs procedural, instruction degradation, few-shot positioningStart with the simplest technique that fits the problem. Most issues are solved by the first three.
The golden rule: Show your prompt to a colleague with minimal context. If they're confused, Claude will be too.
Tell Claude:
| Vague | Specific |
|---|---|
| "Summarize this" | "Summarize in 3 bullets, each under 20 words" |
| "Make it better" | "Fix grammar errors, reduce word count by 30%" |
| "Analyze the data" | "Calculate YoY growth, identify top 3 trends" |
Always specify format explicitly. Show an example if structure matters:
Extract the following as JSON:
- Product name
- Price (number only)
- In stock (boolean)
Example output:
{"name": "Widget Pro", "price": 29.99, "in_stock": true}
3-5 examples typically sufficient. Cover edge cases.
Examples function as calibration, not teaching — they help the model locate pre-trained patterns rather than learn new task semantics. Format, label space, and input distribution matter more than perfect label accuracy. Performance plateaus after 8-16 examples.
Text: "Great service!" → Positive
Text: "Worst purchase ever" → Negative
Text: "It works as expected" → Neutral
Text: "Absolutely love it!" → ?
Example selection rules:
<examples> tags for clear separation from instructionsChoosing the right paradigm:
Extended paradigm details and ICL theory: see [${CLAUDE_SKILL_DIR}/references/learning-paradigms.md].
Separate components for clarity and parseability:
<instructions>
Analyze the contract for risks.
</instructions>
<contract>
{{CONTRACT_TEXT}}
</contract>
<output_format>
List risks in <risks> tags, recommendations in <recommendations>.
</output_format>
Rules:
<contract>..."<outer><inner>...</inner></outer>For complex reasoning, ask Claude to show its work:
Think through this step by step, then provide your answer.
Or use structured tags:
Think through this in <thinking> tags.
Then provide your answer in <answer> tags.
Critical: Claude must output its thinking. Without outputting the thought process, no thinking actually occurs.
CoT vs Extended Thinking decision:
| Criteria | Standard CoT | Extended Thinking |
|---|---|---|
| Activation | Prompt: "think step by step" | API parameter |
| Token budget | Shared with output | Dedicated thinking budget |
| Prompting style | Prescriptive steps work well | High-level guidance better |
| Prefilling | Supported | Not supported |
| Best for | Clear problems with known steps | Complex STEM, constraint optimization, exploration |
Rule: Use extended thinking when the problem requires exploring multiple approaches or when thinking budget would exceed output. Use standard CoT for straightforward multi-step reasoning. Use neither for simple factual tasks.
With extended thinking, provide high-level guidance ("think thoroughly, consider multiple approaches") — not prescriptive steps. Claude's creativity often exceeds human-prescribed step sequences.
CoT trade-off — reasoning vs. instruction-following: Explicit CoT can degrade adherence to simple constraints (word limits, format rules, negative constraints like "no commas"). Reasoning widens the contextual gap between instructions and output, diverting attention from mechanical rules. Use CoT selectively: beneficial for structural formatting and complex logic, harmful for tasks with many simple constraints. For reasoning models (Claude 3.7+, o-series), adding CoT on top of native reasoning ("double thinking") amplifies the problem.
CoT variants, Tree-of-Thoughts, self-consistency sampling: see
[${CLAUDE_SKILL_DIR}/references/reasoning-techniques.md].
For multi-step tasks, number the steps:
Your task is to anonymize customer feedback.
Instructions:
1. Replace customer names with "CUSTOMER_[ID]"
2. Replace emails with "EMAIL_[ID]@example.com"
3. Redact phone numbers as "PHONE_[ID]"
4. Leave product names intact
5. Output only processed messages, separated by "---"
Numbered steps ensure Claude follows the exact sequence. Cap at ~10-15 steps per sequence; beyond that, decompose into sub-procedures (Hierarchical Task Networks — break a complex workflow into named sub-procedures, each with its own short step list).
${CLAUDE_SKILL_DIR}/references/agent-patterns.md]${CLAUDE_SKILL_DIR}/references/agent-patterns.md]${CLAUDE_SKILL_DIR}/references/agent-patterns.md]Diagnosis (using the table above):
Fixed prompt:
<instructions>
Review the provided code for three categories of issues:
1. Bugs — logic errors, off-by-one, null handling
2. Security — injection, auth bypass, data exposure
3. Performance — unnecessary allocations, O(n^2) loops
</instructions>
<output_format>
For each issue found, return:
- **Location:** file:line
- **Category:** Bug | Security | Performance
- **Severity:** Critical | Major | Minor
- **Fix:** concrete code change (not just description)
If no issues found in a category, state "None found."
</output_format>
<code>
{{CODE}}
</code>
What changed: Vague task → specific categories. No format → explicit structure with example fields. Persona ("helpful assistant") → removed (adds no value). Single paragraph → XML-separated components.
Techniques behave differently in persistent context (skills, system prompts, CLAUDE.md) vs. one-shot user messages. Apply these rules when writing instructions that persist across interactions.
Instruction placement — the U-shaped curve. Models follow instructions at the beginning and end of context most reliably; middle content suffers from attention decay ("lost in the middle"). Place identity and critical constraints at the top, reinforce critical rules at the end.
Declarative over procedural for constraints. Rules, conventions, and behavioral boundaries work better as declarative bullet lists than as step-by-step procedures. Reserve numbered steps for workflows with strict ordering. For complex procedures exceeding ~10-15 steps, decompose into sub-procedures (Hierarchical Task Networks) rather than extending a single numbered list.
Domain priming over persona assignment. "This is a security review task" outperforms "You are an expert security auditor." Identity-level framing in first position is more stable than role assignment.
CoT degrades instruction-following in persistent context. Reasoning chains widen the gap between instructions and output, causing the model to neglect simple constraints. Use high-level guidance ("think thoroughly") rather than prescriptive step-by-step reasoning.
Few-shot examples calibrate, not teach. In persistent context, examples help the model locate pre-trained patterns — they set format, tone, and label space. 3-5 is sufficient; returns diminish past 8-16. Place examples near the end of the skill (recency advantage) but not in the very last position (reserve that for critical rules).
Every instruction must earn its place. Research shows unnecessary requirements reduce task success even when the model can follow them. Every instruction competes for attention. Before adding a rule, verify the model's default behavior is insufficient — if deleting the rule doesn't change output quality, remove it.
Full research synthesis: see [${CLAUDE_SKILL_DIR}/references/persistent-context.md].
Start Claude's response to control format:
messages=[
{"role": "user", "content": "Extract as JSON: ..."},
{"role": "assistant", "content": "{"} # Prefill
]
Claude continues from {, outputting pure JSON without preamble.
Prefilling rules:
Use the system parameter to define Claude's role and context:
system="This is a web application security audit task. Apply OWASP Top 10."
System prompt rules:
Full API details and technique combinations: see [${CLAUDE_SKILL_DIR}/references/claude-specific.md].
When working with 20K+ token documents, follow these rules:
<documents>
<document index="1">
<source>annual_report_2023.pdf</source>
<document_content>{{CONTENT}}</document_content>
</document>
</documents>
Document organization patterns, chunking strategies, and query templates: see
[${CLAUDE_SKILL_DIR}/references/long-context.md].
When a single prompt produces error propagation (one mistake ruins everything), decompose into a chain of simpler prompts where each output feeds the next.
Chain patterns (sequential, branching, aggregating, looping), iterative refinement, and meta prompting: see
[${CLAUDE_SKILL_DIR}/references/workflow-patterns.md].
Start with prompt engineering. If quality plateaus, consider adding RAG (need current/accurate external data) or fine-tuning (need deep domain expertise prompting can't achieve). These compose — combine as needed.
Strategy comparison, decision flow, and cost-benefit analysis: see
[${CLAUDE_SKILL_DIR}/references/optimization-strategies.md].
When a prompt handles untrusted input (user-provided content, web scraping, external documents), apply these defenses:
System instructions (trusted):
[instructions here]
---USER INPUT BELOW (untrusted)---
{user_input}
Prompt injection cannot be fully prevented — it's inherent to how LLMs process natural language. Defense is about reducing attack surface, limiting blast radius, and detecting incidents.
Attack taxonomy, defense implementation details, full checklist: see [${CLAUDE_SKILL_DIR}/references/security.md].
When you (the AI) are authoring a prompt for another model to execute — skills, system prompts, subagent instructions, hook prompts — treat prompts as programs to be optimized, not strings to be written. Define the signature (inputs, outputs, success criteria) before writing text. Decompose into components, scaffold with XML, then draft.
Key failure modes to guard against: blob-prompts (unstructured paragraphs), confident sub-optimality (first draft looks good but underperforms — score against quality dimensions before delivering), instruction inflation (adding rules without removing redundant ones), persona defaulting ("You are an expert X" when domain priming is more reliable).
Full workflow, optimization patterns, and artifact-specific guidance: see
[${CLAUDE_SKILL_DIR}/references/agent-authored-prompts.md].
Before finalizing a prompt:
For persistent context (skills, system prompts, CLAUDE.md):
skill-engineering — applies prompt techniques to SKILL.md design, description formulas, and content architecturesubagent-engineering — applies prompt techniques to subagent system prompts, tool scoping, and delegation triggersoutput-style-engineering — applies prompt techniques to persona definition, tone examples, and behavioral rulesclaude-code-sdk — reference for Claude Code extensibility APIs when building any AI artifact