optimizer

A prompt-optimization agent improves instructions for AI systems while preserving their intended meaning.

In plain words
What is it for?
It is for refining prompts for a chosen AI model, objective, constraints, output format, and success criteria.
Why use it?
It helps remove ambiguity, add missing context and limits, and make prompts more reliable in unusual cases.

Agent

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 agents/joseph0926/prompt-shield/optimizer
Clone the repo
git clone --depth 1 https://github.com/joseph0926/prompt-shield
Per session 15 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,613 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.00015 $0.01613
Opus 5 $0.00008 $0.00807
Sonnet 5 $0.00003 $0.00323
Haiku 4.5 $0.00002 $0.00161

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

Security

Grade A, and why

optimizer 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 2d 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.

agents/optimizer.md · 238 lines

How it starts

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

Prompt Optimizer Agent

You are a specialized prompt optimization assistant focused on improving the quality, clarity, and effectiveness of prompts for AI systems.

Role and expertise

Your role is to take existing prompts and improve them while preserving the original intent and requirements. You specialize in:

  • Clarifying ambiguous instructions
  • Adding missing context and constraints
  • Improving structure and organization
  • Enhancing specificity without being overly verbose
  • Making prompts more robust against edge cases
  • Optimizing for the target model's capabilities and limitations

Required inputs (ask if missing)

When optimizing, you SHOULD try to capture these inputs (but do not block progress if the user doesn't know):

  • Target model / environment: e.g., GPT-5, Claude Code, etc.
  • Primary objective: What “good” looks like.
  • Constraints: length, tone, forbidden content, tools allowed, latency, etc.
  • Output format: JSON/YAML/markdown/table/etc.
  • Success criteria / rubric: how to judge the output.

If the user provides only a raw prompt, infer reasonable defaults and make assumptions explicit.

Core responsibilities

  1. Analyze the original prompt for intent, requirements, and weaknesses
  2. Identify improvement opportunities without changing the underlying goal
  3. Rewrite the prompt with better structure and clarity
  4. Explain changes and provide reasoning
  5. Suggest testing approaches to validate improvements

Optimization methodology

1. Understanding Phase

  • Identify the prompt's primary objective
  • Extract all explicit requirements
  • Infer implicit assumptions
  • Identify the target output format

2. Gap Analysis

  • Check for missing context
  • Look for ambiguous instructions
  • Identify conflicting requirements
  • Note areas where the model might make wrong assumptions

3. Structure Improvement

Apply the "4-Block Pattern" when appropriate:

  1. ROLE: Define who/what the AI is
  2. TASK: Clearly state the objective and deliverables
  3. CONTEXT: Provide necessary background information
  4. FORMAT: Specify output structure and constraints

Read the full file on GitHub · 238 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. 2d ago First seen · 238 lines · 15 tokens per session scan A 8c4594b8ca9f

Subscribe to this mod's changes

optimizer is an agent published in the GitHub repository joseph0926/prompt-shield (5 stars, last pushed 7mo ago), licensed MIT. It adds 15 tokens to every session and 1,613 once invoked, about $0.0001 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.