Optimize system prompts for Claude Code agents using proven prompt engineering patterns. Use when users request prompt improvement, optimization, or refinement for agent workflows, tool instructions, or system behaviors.
Resolve SKILL_DIR to the absolute directory containing this SKILL.md, as
shown by the current host, before using any bundled path below.
Before a shell command uses $SKILL_DIR, assign it in that command or replace
it with the resolved path. It is not a host-exported environment variable.
Optimizes system prompts by applying research-backed prompt engineering patterns. This skill operates through human-in-the-loop phases: understand, plan, propose changes, receive approval, then integrate.
A well-optimized prompt achieves three things:
Optimization is complete when:
Use when the user provides a prompt and wants it improved, refined, or reviewed for best practices.
Do NOT use for:
Before ANY analysis, read the appropriate pattern reference(s). Each reference contains a Technique Selection Guide table mapping domains, trigger conditions, stacking compatibility, conflicts, and expected effects.
$SKILL_DIR/references/prompt-engineering-single-turn.md
This contains the complete catalog of single-turn patterns, including:
$SKILL_DIR/references/prompt-engineering-multi-turn.md
Read when the prompt involves:
Skip for: Static system prompts executed in a single LLM call, tool instructions, or one-shot prompts.
$SKILL_DIR/references/prompt-engineering-subagents.md
Read when the prompt involves:
Skip for: Single-agent prompts without coordination, handoffs, or parallel execution.
$SKILL_DIR/references/prompt-engineering-hitl.md
Read when the prompt involves:
Skip for: Fully autonomous prompts without human intervention points.
$SKILL_DIR/references/prompt-engineering-compression.md
Read when:
Skip for: Prompts where thoroughness is more important than brevity, or where compression would degrade output quality.
All technique selection decisions must be grounded in these references. Do not apply patterns from memory or general knowledge—consult the appropriate reference to ensure accuracy and to surface stacking/conflict information.
Not every prompt needs the full optimization process. Before proceeding, assess complexity.
Simple prompts (use lightweight process):
Complex prompts (use full process):
For simple prompts, skip section decomposition. Instead:
Do not over-engineer simple prompts.
Proceed to Phase 1.
Before decomposing or modifying anything, understand what the prompt is trying to accomplish and the context in which it operates. This understanding phase is essential—without it, technique selection becomes guesswork.
Answer these questions (internally, not presented to user unless clarification needed):
Before consulting the reference, write down specific observations about problems in the prompt. Examples of observable problems:
These observations become the input to technique selection in Phase 2.
With the prompt understood and problems documented, consult the reference to devise a plan.
For each problem identified in Phase 1.3, locate the relevant technique in the reference document and quote the specific text that justifies applying it. This grounding step prevents pattern-shopping and ensures accurate application.
For each candidate technique, extract from the reference:
### Technique: [Name]
**Quoted trigger condition**: "[exact text from Technique Selection Guide]"
**Quoted effect**: "[exact text describing behavioral impact]"
**Stacks with**: [list from reference]
**Conflicts with**: [list from reference]
**Problem this addresses**: [your observation from Phase 1.3]
**Why this matches**: [explain how the trigger condition matches the observed problem]
This quote-first approach forces commitment to specific evidence before reasoning about application. If you cannot quote a trigger condition that matches your observed problem, do not apply the technique.
Before finalizing the plan, verify each selection by asking yourself open verification questions (not yes/no questions, which bias toward confirmation):
If you cannot answer these questions by pointing to specific text in the reference or the prompt, reconsider the technique selection.
Present each proposed change as a visually distinct "card" using ASCII box drawing. This format prioritizes scannability—the user should grasp scope, problem, and proposed fix at a glance before approving.
Wait for explicit approval before proceeding to Phase 3.
Card Template:
╔══════════════════════════════════════════════════════════════════════════════╗
║ CHANGE N: [Short title - what this change does] ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ ║
║ SCOPE ║
║ ───── ║
║ Prompt: [prompt name or "multi-prompt: A → B"] ║
║ Section: [which part of the prompt] ║
║ Downstream: [what depends on this output, or "none"] ║
║ ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ ║
║ PROBLEM ║
║ ─────── ║
║ Issue: [One sentence - what's wrong] ║
║ ║
║ Evidence: "[quoted problematic text from the prompt]" ║
║ ║
║ Runtime: [What the user actually sees - concrete failure behavior] ║
║ ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ ║
║ TECHNIQUE ║
║ ───────── ║
║ Apply: [Technique name from reference] ║
║ ║
║ Trigger: "[quoted trigger condition from reference]" ║
║ Effect: "[quoted expected effect from reference]" ║
║ Stacks: [compatible techniques, or "none"] ║
║ ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ ║
║ BEFORE ║
║ ────── ║
║ ┌────────────────────────────────────────────────────────────────────────┐ ║
║ │ [Original prompt text - exact copy] │ ║
║ └────────────────────────────────────────────────────────────────────────┘ ║
║ ║
║ ▼ ║
║ ║
║ AFTER ║
║ ───── ║
║ ┌────────────────────────────────────────────────────────────────────────┐ ║
║ │ [Modified prompt text - exact copy] │ ║
║ └────────────────────────────────────────────────────────────────────────┘ ║
║ ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ ║
║ WHY THIS IMPROVES QUALITY ║
║ ───────────────────────── ║
║ [1-2 sentences: concrete behavioral improvement expected] ║
║ ║
╚══════════════════════════════════════════════════════════════════════════════╝
For multi-prompt changes, add an INTERACTION section between TECHNIQUE and BEFORE:
╠══════════════════════════════════════════════════════════════════════════════╣
║ ║
║ INTERACTION (how prompts connect) ║
║ ───────────────────────────────── ║
║ ║
║ Currently: ║
║ ┌──────────┐ free-form text ┌──────────┐ ║
║ │ Prompt A │ ─────────────────▶ │ Prompt B │ ──▶ [failure mode] ║
║ └──────────┘ └──────────┘ ║
║ ║
║ After change: ║
║ ┌──────────┐ structured XML ┌──────────┐ ║
║ │ Prompt A │ ─────────────────▶ │ Prompt B │ ──▶ [success outcome] ║
║ └──────────┘ └──────────┘ ║
║ ║
╠══════════════════════════════════════════════════════════════════════════════╣
After presenting all change cards:
**Compatibility check**:
- [Note any stacking opportunities]
- [Note any conflicts and how to resolve]
**Anti-patterns verified**: [Confirm you checked the Anti-Patterns section]
---
Does this plan look reasonable? I'll apply these changes once you confirm.
Do not proceed to Phase 3 without user confirmation.
With the plan approved, apply the changes to the prompt. The detailed approval happened in Phase 2; execution is straightforward.
Work through the approved changes in logical order (typically by prompt section). For each change:
No additional approval is needed per change—the plan was already approved in Phase 2.
When multiple techniques could apply to the same text but suggest different approaches, present the conflict to the user:
### Conflict: [Section Name]
**Context**:
> "[Quoted text in question]"
**Option A: [Technique Name]**
- Reference says: "[quoted justification]"
- Would change text to: [proposed modification]
- Improves: [what aspect]
- Trade-off: [what you might lose]
**Option B: [Technique Name]**
- Reference says: "[quoted justification]"
- Would change text to: [proposed modification]
- Improves: [what aspect]
- Trade-off: [what you might lose]
**My recommendation**: [Which option and why, based on the prompt's operating context]
Which approach would you prefer?
Wait for user decision before proceeding.
After section-by-section changes are approved, assemble the complete prompt and verify quality holistically.
Cross-section coherence: Do sections reference each other correctly? Are there dangling references to removed content?
Terminology consistency: Does the prompt use the same terms throughout? (e.g., don't switch between "user", "human", and "person")
Priority consistency: If multiple sections establish priorities, do they align?
Emphasis audit: Count emphasis markers (CRITICAL, IMPORTANT, NEVER, ALWAYS). Per the reference's anti-patterns section, if more than 2-3 items use highest-level emphasis, reconsider.
Flow and ordering: Does the prompt follow logical progression?
Verify the optimized prompt by asking open verification questions about each major change:
## Quality Verification
For each significant change, verify it achieves the intended effect:
### Change: [brief description]
- **Intended effect**: "[quoted from reference]"
- **Verification question**: "[open question to check if the change works]"
- **Assessment**: [Does the modified text actually achieve this?]
Example verification questions (use open questions, not yes/no):
If verification reveals issues, revise before presenting the final prompt.
Re-consult the reference's Anti-Patterns section. Verify the optimized prompt doesn't exhibit:
## Optimized Prompt
[Complete optimized prompt text]
---
## Summary of Changes
**Techniques applied** (with reference sections):
1. [Technique]: [which section, what it improved]
2. [Technique]: [which section, what it improved]
...
**Quality improvements**:
1. [Most significant improvement and why it matters]
2. [Second most significant]
3. [Third most significant]
**Preserved from original**: [What was already working well and kept unchanged]
**Verification completed**: [Confirm you ran quality verification on major changes]
---
Please review the complete prompt. Let me know if you'd like any adjustments.
Before presenting the final prompt, verify:
If any checkbox fails, address it before presenting the final prompt.
┌─────────────────────────────────────────────────────────────────┐
│ 1. READ THE REFERENCE(S) │
│ - Always: prompt-engineering-single-turn.md │
│ - If multi-turn/refinement: + multi-turn reference │
│ - If multi-agent/subagents: + subagents reference │
│ - If human approval gates: + hitl reference │
│ - If token efficiency: + compression reference │
├─────────────────────────────────────────────────────────────────┤
│ 2. UNDERSTAND THE PROMPT (Phase 1) │
│ - Operating context (single-shot? tool-use? constraints?) │
│ - Current state (working? unclear? missing?) │
│ - Document specific problems with quoted prompt text │
├─────────────────────────────────────────────────────────────────┤
│ 3. PLAN WITH VISUAL CARDS (Phase 2) │
│ - Present each change as a visual card with: │
│ SCOPE → PROBLEM → TECHNIQUE → BEFORE/AFTER │
│ - Quote trigger conditions from reference │
│ - Show exact text transformations for user approval │
│ - ⚠️ WAIT FOR USER APPROVAL before proceeding │
├─────────────────────────────────────────────────────────────────┤
│ 4. EXECUTE APPROVED CHANGES (Phase 3) │
│ - Apply the BEFORE → AFTER transformations │
│ - No additional approval needed (plan was approved) │
├─────────────────────────────────────────────────────────────────┤
│ 5. INTEGRATE AND VERIFY QUALITY (Phase 4) │
│ - Check cross-section coherence │
│ - Run quality verification on major changes │
│ - Final anti-pattern check │
│ - Present complete optimized prompt │
└─────────────────────────────────────────────────────────────────┘
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer