prompt-optimize

prompt-optimize is a command for coding agents from acaprino/daodan. It costs 45 tokens per session (1,796 once invoked), scanned A, original, MIT.

A command for reviewing and rewriting prompts, system messages, or agent instructions. It creates several versions that trade lower token use against clearer or more reliable results.

In plain words
What is it for?
Use it to optimize a prompt from a file or pasted text. It can present alternatives for efficiency, effectiveness, or a chosen optimization goal.
Why use it?
It helps when instructions are unclear, too long, or unreliable. You can compare the trade-offs before approving any change to the original.

Command

Installs and runs on its own, but its text points at files inside its plugin — anything it tells you to read at a ${CLAUDE_PLUGIN_ROOT} path is only there once the plugin is installed. Installing the plugin gets both.

Part of the ai-tooling plugin — 1 skill, 1 command, 1 agent shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/acaprino/daodan/prompt-optimize
Clone the repo
git clone --depth 1 https://github.com/acaprino/daodan

Or install ai-tooling, the plugin that ships this one along with the rest of its 1 skill, 1 command, 1 agent.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for prompt-optimize

README.md
[![agentmods](https://agentmods.dev/badge/commands/acaprino/daodan/prompt-optimize.svg)](https://agentmods.dev/commands/acaprino/daodan/prompt-optimize)
Your own site
<a href="https://agentmods.dev/commands/acaprino/daodan/prompt-optimize"><img src="https://agentmods.dev/badge/commands/acaprino/daodan/prompt-optimize.svg" alt="Measured on agentmods" height="20"></a>
Per session 45 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,796 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00045 $0.01796
Opus 5 $0.00023 $0.00898
Sonnet 5 $0.00009 $0.00359
Haiku 4.5 $0.00005 $0.00180

Measured 5d ago against content hash a5000b9b72f7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

prompt-optimize scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

exports/claude/plugins/ai-tooling/commands/prompt-optimize.md · 138 lines

How it starts

The opening of the file, as written. The whole thing — 138 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Prompt Optimization

CRITICAL RULES

  1. Read the prompt first. If $ARGUMENTS is a file path, read the file. If inline text, use it directly.
  2. Never modify the user's original prompt until they approve a variant.
  3. Show the frontier. Efficiency vs effectiveness is the user's call, not the optimizer's: present variants along that axis with honest cost labels, and let the user pick. --optimize-for is the shortcut for users who already know their pole.
  4. Never enter plan mode. Execute immediately.

Step 1: Analysis and variant frontier (single subagent pass)

Execute the full analysis and variant generation in a single prompt-engineer subagent call. The agent analyzes first, natively, and returns only the observable artifacts defined in Phase 2: no explicit reasoning scaffold is imposed on it, per its own anti-pattern rules for reasoning models.

Agent:
  subagent_type: "prompt-engineer"
  description: "Analyze the prompt and generate the variant frontier"
  prompt: |
    You are evaluating and optimizing a prompt.

    ## Input
    - Original Prompt: [Insert the prompt from $ARGUMENTS]
    - Optimization Target: [--optimize-for flag value, or "frontier" when absent]
    - Target Model: [--model flag value, default "claude"]

    ## Phase 1: Analysis (private)
    Analyze the prompt thoroughly before writing any output. Extract its behavioral contract
    first, then classify the archetype and score on a 1-5 scale only the rubric dimensions that
    archetype wants, marking the rest N/A. Identify ambiguities, missing edge cases, structural
    weaknesses, and injection vulnerabilities.
    Do not include this working in the response: Phase 2 defines the only output you produce.

    Usage-profile check: determine how the prompt is used (one-off, repeated system prompt,
    agent loop) and whether prompt caching applies. Which tokens matter follows from this:
    output tokens bill at full price and dominate latency; a cached prefix bills ~0.1x on
    reads, so shortening it saves ~10% of what it appears to, and cache-breaking edits
    re-bill it at 1.25x.

    Reasoning-pattern check: first determine the target model class. For reasoning models
    (extended thinking, o-series, R1 class), default to NO explicit scaffold: direct
    instructions plus precise success criteria; consult the "Reasoning models change the
    defaults" section of `${CLAUDE_PLUGIN_ROOT}/references/reasoning-patterns.md` before adding
    any pattern. Otherwise, decide whether the task would benefit from a structured
    reasoning scaffold beyond plain instructions (CoT, Step-Back, ReAct, Tree-of-Thought,
    Self-Consistency, Reflexion, Plan-and-Solve, Least-to-Most, Self-Ask, Skeleton-of-Thought).
    If yes, read `${CLAUDE_PLUGIN_ROOT}/references/reasoning-patterns.md`, pick the pattern
    that matches the task shape using the selection cheat sheet, and apply it in Phase 2.
    For the efficiency variant, always consult that file's token-efficient patterns
    (Chain of Draft, Concise CoT, token-budget prompting, Sketch-of-Thought) and its
    "Cost-aware selection" section: the efficiency pole is built from those techniques,
    not from bare word-deletion.
    If the existing prompt already scores 4+ on every dimension, do not add a pattern just
    for completeness -- record the decision in the analysis instead.

    ## Phase 2: Output
    Based on your analysis, respond strictly in this format:

    ### Diagnostic Scorecard (original, predicted)
    State the archetype in one line, then one row per applicable dimension. Include the
    conditional dimensions (output determinism, tool-use correctness, trust boundaries,
    evalability, creative latitude) only when this archetype wants them, and list the ones you
    marked N/A with a short reason underneath.

    | Dimension | Score (1-5) | Key issue |
    |-----------|:---:|-------|
    | Intent alignment | X | ... |
    | Instruction clarity | X | ... |
    | Constraint correctness | X | ... |
    | Model fit | X | ... |
    | Context efficiency | X | ... |
    | Robustness | X | ... |

    ### Variant Frontier
    Produce 3 variants by default:
    - **A. Max effectiveness**: prioritize quality, robustness, and output control; token cost is secondary.
    - **B. Balanced**: resolve the analysis issues at neutral or lower token cost.
    - **C. Max efficiency**: minimum tokens at estimated parity, built with a token-efficient
      technique where reasoning is involved.

    Collapse to fewer variants only when they would genuinely converge (trivial or already
    near-optimal prompts); say that you did and why. Each variant is a fully rewritten,
    ready-to-use prompt in its own fenced block. Use XML tags if the target model is Claude
    and the prompt mixes instructions, context, or examples; headings suffice for simple prompts.

    ### Comparison
    | Variant | Tokens (est.) | Delta vs original | Technique applied | Predicted effect (unmeasured) | What you give up |

    Token estimates: characters/4 on the prompt text, labeled "est.". If a variant also
    constrains reasoning or output length, state the expected output-token effect
    separately: that is where most of the real savings live.

    ### Behavioral changes
    For each variant, report what changed in behavior rather than in wording: constraints
    strengthened or relaxed, behaviors removed or added, interface changes, tool-policy or
    reasoning-strategy changes, trust boundaries hardened or weakened. Print only the lines that
    are true. If a variant changes nothing behavioral, say so in one line. Lead with any
    relaxation or removal instead of burying it under the token saving.

    ### Honesty note
    Close with these caveats, adapted to the case:
    - Label every quality claim predicted, measured, or verified. A score this pass assigned is
      predicted by definition, including the scorecard above.
    - Predicted scores and parity are single-pass estimates by the same model that wrote
      the variants, not measurements; small formatting changes alone are known to swing
      task accuracy, so treat the deltas as hypotheses.
    - To actually verify "fewer tokens, same results": run a paired eval (identical inputs
      per variant, pre-declared non-inferiority margin). The prompt-engineer prompt-evals
      guidance covers the method; promptfoo fits in CI.
    - If the prompt is a cached system prompt, repeat the cache-economics warning from
      the analysis.

Read the full file on GitHub · 138 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 138 lines · 45 tokens per session scan A a5000b9b72f7

Subscribe to this mod's changes

prompt-optimize is a command published in the GitHub repository acaprino/daodan (8 stars, last pushed 9d ago), licensed MIT. It adds 45 tokens to every session and 1,796 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.