Optimize a Prompt Without Breaking It: A Claude Skill
September 18, 2026
A good prompt optimizer classifies what the prompt is for, judges how sophisticated it already is, and changes only what that context justifies, copying code, flags, model IDs, and URLs verbatim. The Prompt Optimizer skill does this in five steps and ships as a single downloadable skill.md file for Claude.
Why do prompt optimizers make prompts worse?
Most prompt-optimization templates fail in one of two ways. They take a simple request and inflate it into a massive, over-engineered prompt, or they quietly alter technical details that were already correct: code snippets, file paths, version pins, generator flags.
Both failures have the same cause. The optimizer applies one generic recipe to every prompt, regardless of what the prompt is for or how much structure it already has.
What does the skill do?
The skill runs five steps every time you ask Claude to improve a prompt.
| Step | What Claude does |
|---|---|
| 1. Classify the context | Decides whether the target is code generation, image generation, structured output, human communication, research, or creative work. |
| 2. Assess sophistication | Rates the existing prompt Simple, Intermediate, Advanced, or Expert. |
| 3. Apply optimization moves | Builds the rewrite with a Persona, Instruction, Principles, and Anti-patterns (the PIP frame). |
| 4. Preserve technical parameters | Copies code, numbers, flags, model IDs, error messages, and URLs character for character. |
| 5. Output the results | Returns the classified context, the optimized prompt, and a short note on what changed and why. |
How does it classify a prompt's context?
Each context has its own best practices, so the skill reads the prompt for signals before touching it.
| Context | Signals in the prompt |
|---|---|
| Code generation | A language name, function or class names, code fences, stack traces, "debug", "refactor" |
| Image generation | Aspect ratios, rendering terms, generator flags such as --ar or --style |
| Structured output | A request for JSON, YAML, CSV, or a schema as the deliverable |
| Human communication | An email, memo, or message; a named tone or recipient |
| Research and analysis | "Analyze", "summarize", "compare", with an expectation of citations or findings |
| Creative enhancement | A story, poem, genre, characters, or plot |
If a prompt matches several contexts, the skill prioritizes the primary one and keeps the relevant details from the secondary one.
How does it decide how much to change?
The skill rates the prompt you gave it, then adds only the structure the next level up needs.
| Level | What the prompt looks like | What optimization means |
|---|---|---|
| Simple | One sentence, no constraints, vague verbs | Add intermediate-level structure, not an expert-level prompt |
| Intermediate | Some constraints, missing examples and edge cases | Add depth: examples, edge cases, success criteria |
| Advanced | Clear format and constraints, missing persona or failure modes | Add role framing and explicit anti-patterns |
| Expert | Persona, constraints, examples, and anti-patterns already present | Tighten wording and remove ambiguity, without adding structure |
Turning a Simple prompt into an Expert one in a single pass overwhelms the downstream model. When unsure, the skill defaults to Intermediate-level structure or asks.
What is the PIP frame?
PIP stands for Persona, Instruction, Principles, and Anti-patterns. Persona says who the model should act as. Instruction says what to produce. Principles set guardrails and quality standards. Anti-patterns say what to avoid.
For a bare debugging request such as "my code doesn't work, fix it", the skill builds:
- Persona: an expert software engineer specializing in root cause analysis.
- Instruction: think through potential causes step by step before answering.
- Principle: request what a debugger actually needs (the exact error, the relevant code, expected versus actual behavior).
- Anti-pattern: don't guess at a fix without that information.
The skill writes these narratively rather than filling a rigid template.
What does "strict technical preservation" cover?
Before finalizing, the skill scans the original prompt and copies the following into the optimized version exactly:
- Code fences and inline code
- Exact numbers, versions, flags, and file paths (for example
--ar 16:9or/api/v1/optimize) - Model IDs and proper nouns
- Error messages and stack traces, verbatim
- URLs and email addresses
It never "corrects" what looks like a typo. If something is ambiguous, it leaves it untouched and flags it in the closing note.
What are the limits of this skill?
It is a heuristic pass. The skill says so plainly in its output: it does not claim a confidence score, and it does not imply the prompt went through a trained model or a full LLM-based optimization pipeline. For evaluated, tested optimization, see the Prompt Optimizer platform, which generates and validates skills like this one.
How do I install it?
- Download
prompt-optimizer.md. - Save it as
~/.claude/skills/prompt-optimizer/SKILL.md(or in a project's.claude/skills/folder). - Ask Claude to optimize, refine, or rewrite a prompt.
The source is also in the GitHub repository.
FAQ
Does the skill change my code blocks or flags?
No. Code fences, inline code, versions, flags, model IDs, URLs, and stack traces are copied character for character.
What if my prompt is already good?
An Expert-level prompt gets tightened and de-ambiguated, not restructured. The skill does not add structure you did not ask for.
Which contexts does it support?
Code generation, image generation, structured output, human communication, research and analysis, and creative enhancement.
Is this the same as the Prompt Optimizer platform?
No. The skill is a standalone heuristic pass. The platform runs a full pipeline with evaluation and routing.
This skill was first shared on r/PromptEngineering by u/Parking-Kangaroo-63.