
prompt-optimizer
Engineers prompts into clear, structured, model-optimized instructions using the 4-D methodology (Deconstruct, Diagnose, Develop, Deliver) with architecture-specific tuning. Use when a draft prompt, instruction set, or agent skill description needs refinement for clarity or improved performance.
- Installs
- 40
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/joellewis/skill-library --skill prompt-optimizer- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads prompt-optimizer automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Overview
Prompt optimization is the engineering of intent into machine-executable instructions. This skill applies the 4-D Methodology (Deconstruct, Diagnose, Develop, Deliver) to ensure that prompts are clear, structured, and optimized for specific model architectures (e.g., Claude's XML tagging vs. OpenAI's Markdown preference).
Iron Law
NO PROMPT SHIPS WITHOUT RUNNING THE 4-D AUDIT
Failing to audit a prompt leads to "drift"—where the AI's output gradually diverges from the user's intent due to ambiguity or structural weakness.
State Machine
digraph prompt_optimization_flow {
"Rough Input" [shape=doublecircle];
"Deconstruct: Intent & Context" [shape=box];
"Diagnose: Ambiguity Audit" [shape=box];
"Develop: Apply Frameworks" [shape=box];
"Deliver: Final Construction" [shape=box];
"Validation: Test Run" [shape=diamond];
"Optimized Prompt" [shape=doublecircle];
"Rough Input" -> "Deconstruct: Intent & Context";
"Deconstruct: Intent & Context" -> "Diagnose: Ambiguity Audit";
"Diagnose: Ambiguity Audit" -> "Develop: Apply Frameworks";
"Develop: Apply Frameworks" -> "Deliver: Final Construction";
"Deliver: Final Construction" -> "Validation: Test Run";
"Validation: Test Run" -> "Optimized Prompt" [label="pass"];
"Validation: Test Run" -> "Diagnose: Ambiguity Audit" [label="fail"];
}
When to Use This Skill
- When an AI provides "hallucinated" or irrelevant answers.
- When creating a new system prompt or "SKILL.md" file.
- When a complex task needs to be broken down for a model.
- When you need to force a model to follow a specific output format (JSON, XML, Markdown).
When NOT to Use This Skill
- For simple, conversational queries where high precision is unnecessary.
- When the bottleneck is the model's knowledge cutoff rather than the instruction set.
Core Process
Step 1: Deconstruct (Extract Core Intent)
Strip the prompt to its atomic parts. Identify:
- Role: Who is the AI supposed to be? (Source: Anthropic).
- Goal: What is the specific, measurable outcome?
- Constraints: What MUST NOT happen? (Source: OpenAI).
Step 2: Diagnose (Audit for "Leaks")
Look for structural weaknesses:
- Ambiguity: Are words like "better," "fast," or "creative" left undefined?
- Cognitive Load: Is the prompt trying to do too many things at once?
- Format Gaps: Is the desired output structure clearly defined? (Source: Anthropic).
Step 3: Develop (Apply Optimization Frameworks)
Select the appropriate technique based on task complexity:
- Chain of Thought (CoT): Force the model to "think" in
<thinking>tags before answering (Source: Anthropic). - Few-Shot Learning: Provide 2-3 high-quality examples of input/output pairs.
- XML Structuring: Use tags (e.g.,
<context>,<task>,<example>) to separate instructions from data (Source: Anthropic). - Reference Text: Provide the exact text the model should use to minimize hallucinations (Source: OpenAI).
Step 4: Deliver (Final Construction)
Assemble the optimized prompt using a "Bottom-Up" assembly:
- Role Definition.
- Context/Background.
- Task/Instructions (broken into steps).
- Output Format Specifications.
- Examples (if applicable).
Cross-Skill Invocations
- REQUIRED SUB-SKILL: writing-skills — To ensure the prompt adheres to TDD principles (testable outcomes).
- RECOMMENDED SUB-SKILL: non-fiction-precision — For clarity and concision in instruction wording.
Rationalization Table
| Thought | Reality |
|---|---|
| "It's just a simple request, no need for tags." | Simple requests are where models "lazy-reply" most often. |
| "The model is smart enough to figure it out." | Intelligence is not a substitute for clear intent engineering. |
| "I'll just add more words to make it clearer." | Wordiness often dilutes the model's attention; use structure instead. |
| "I don't have time for the 4-D audit." | A bad prompt wastes more time in revisions than an audit takes. |
Red Flags
- "The model isn't listening" → You likely have conflicting constraints or a weak Role definition.
- "Output is too generic" → You lack specific constraints or "Few-Shot" examples.
- "Wall of Text" → You haven't used delimiters (Markdown or XML) to help the model parse intent.
Diagnostic Checklist
- Does the prompt define a specific Role?
- Are instructions separated from data using XML tags or delimiters?
- Is there a Chain of Thought instruction (e.g., "Think step-by-step")?
- Are the Output Format requirements (e.g., JSON, length, tone) explicit?
- Does the prompt include at least one Negative Constraint (what to avoid)?
Sources
- OpenAI, Prompt Engineering Guide (Strategies for Task Decomposition).
- Anthropic, Prompt Engineering Documentation (Use of XML tags and Role Prompting).
- Anthropic, Prompt Engineering Documentation (4-D Methodology).
FAQ
What does the prompt-optimizer skill do?
Engineers prompts into clear, structured, model-optimized instructions using the 4-D methodology (Deconstruct, Diagnose, Develop, Deliver) with architecture-specific tuning. Use when a draft prompt, instruction set, or agent skill description needs refinement for clarity or improved performance.
How do I install prompt-optimizer?
Run npx skills add https://github.com/joellewis/skill-library --skill prompt-optimizer in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/prompt-optimizer/ (personal) or .claude/skills/prompt-optimizer/ (project).
Which AI agents can use prompt-optimizer?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is prompt-optimizer safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains prompt-optimizer?
It is published by joellewis in joellewis/skill-library. It has 40 recorded installs.
More from joellewis/skill-library
fiction-architect
joellewis/skill-library
Open the skill to read its SKILL.md instructions.
world-building-logic
joellewis/skill-library
Open the skill to read its SKILL.md instructions.
character-vulnerability
joellewis/skill-library
Use when a character feels flat, too competent, or unrelatable—identifies the Sacred Flaw (Storr's Theory of Control) and dials the Three Sliders (Sanderson) to create earned vulnerability.
problem-framing
joellewis/skill-library
Use when beginning analytical or strategic tasks, facing undefined problems, or facing analysis paralysis—requires explicit problem definition before proceeding.
Popular ai & agents skills
google-agents-cli-publish
google/agents-cli
This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).
google-agents-cli-eval
google/agents-cli
This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).
skill-creator
anthropics/skills
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
codex-pet
prime-skills/runcomfy-agent-skills
Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.
full-output-enforcement
leonxlnx/taste-skill
Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.
executing-plans
obra/superpowers
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available