Index of every page on this site: llms.txt
All skills
joellewis avatar

/prompt-optimizer

@fcb67f8
Run it yourself

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.

Use this Skill: https://skilld.dev/gh/joellewis/skill-library/prompt-optimizer

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈79 tokens for metadata: the name and description. ≈1.3k when used: this file.

Description uses 3.9% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈315 characters, or 3.9%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

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:

  1. Role Definition.
  2. Context/Background.
  3. Task/Instructions (broken into steps).
  4. Output Format Specifications.
  5. 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).

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts23d4 checks · Risk SAFE
  • Gen Agent Trust Hub23d

    This skill is a documentation-only resource providing a methodology for prompt engineering. It contains no executable code, network operations, or sensitive data access, and it adheres to standard prompt engineering best practices.

  • Socket23d

    No alerts

  • Snyk23d

    Risk: LOW · No issues

  • Runlayer8mo

    1 file scanned · No issues

Signed by skilld at fcb67f8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 9 months ago
compatibility
Claude Code and compatible agent products
Other metadata
metadata
{
  "type": "meta",
  "family": "meta",
  "rigor": "full",
  "keywords": "prompt engineering, 4-D methodology, chain of thought, few-shot, XML tags, system prompt, optimization, clarity",
  "requires": "writing-skills",
  "enhances": "getting-started, using-skills",
  "sources_pdf": "",
  "sources_web": "OpenAI Prompt Engineering Guide, Anthropic Prompt Engineering Documentation"
}

README badge

README badge for joellewis/skill-library/prompt-optimizer