Prompt Optimize Command
Analyze and optimize LLM prompts for clarity, consistency, and effectiveness. Restructure system prompts, improve instruction specificity, reduce token usage, and generate A/B test variants for comparing prompt performance.
Command
/prompt-optimize
Description
Takes an existing LLM prompt (system, user, or tool prompt) and rewrites it for better performance. Analyzes for common anti-patterns, improves structure, reduces ambiguity, and generates optimized variants you can A/B test.
Behavior
- Analyze the current prompt for anti-patterns and inefficiencies
- Score against a prompt quality rubric
- Rewrite with improved structure and clarity
- Generate 2-3 variants for testing
- Provide evaluation criteria for measuring improvement
Analysis Rubric
| Criterion | Weight | Description |
|---|---|---|
| Clarity | 25% | Unambiguous instructions, no conflicting rules |
| Specificity | 20% | Concrete examples, not vague directives |
| Structure | 20% | Logical ordering, clear sections, scannable |
| Efficiency | 15% | Minimal tokens for maximum effect |
| Robustness | 10% | Handles edge cases, prevents jailbreaks |
| Testability | 10% | Success criteria are measurable |
Common Anti-Patterns Detected
## Anti-Pattern: Vague Instructions - BAD: "Be helpful and provide good answers" - GOOD: "Answer the user's question in 2-3 sentences. Include a code example if the question is about implementation." ## Anti-Pattern: Contradicting Rules - BAD: "Always respond in JSON" + "For errors, explain in plain text" - GOOD: "Always respond in JSON. For errors: {"error": "description"}" ## Anti-Pattern: Instruction Stuffing - BAD: 30 rules in a flat list - GOOD: Grouped rules under ## sections with priorities ## Anti-Pattern: No Examples - BAD: "Format output appropriately" - GOOD: "Format output as:\n| Name | Value |\n|------|-------|\n| CPU | 45% |" ## Anti-Pattern: Missing Edge Cases - BAD: "Translate the text to Spanish" - GOOD: "Translate to Spanish. If text is already Spanish, return it unchanged. If text contains code blocks, preserve them."
Output Format
## Prompt Analysis ### Current Score: 52/100 | Criterion | Score | Issues | |-----------|-------|--------| | Clarity | 6/10 | 3 ambiguous instructions | | Specificity | 4/10 | No examples provided | | Structure | 5/10 | Flat list, no grouping | | Efficiency | 7/10 | Some redundancy | | Robustness | 4/10 | Missing edge cases | | Testability | 3/10 | No success criteria | ### Optimized Prompt (Score: 87/100) [Rewritten prompt here] ### Variant A: Concise (Score: 82/100) [Shorter variant focusing on efficiency] ### Variant B: Comprehensive (Score: 85/100) [Longer variant with more examples] ### A/B Test Plan - **Metric**: Task completion accuracy on 50 sample inputs - **Duration**: 100 requests per variant - **Evaluation**: Compare output quality scores
Rules
- Preserve intent - never change what the prompt is trying to do
- Show reasoning - explain why each change improves the prompt
- Measure improvements - provide before/after scores
- Test-ready variants - outputs should be copy-paste ready
- Token awareness - report token count changes
Examples
# Optimize a prompt from a file /prompt-optimize src/prompts/summarizer.txt # Optimize inline prompt /prompt-optimize "You are a helpful coding assistant..." # Optimize with specific focus /prompt-optimize src/prompts/classifier.txt --focus efficiency
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Git Commit Message Generator
Generates well-structured conventional commit messages by analyzing staged changes. Follows Conventional Commits spec with scope detection.
React Component Scaffolder
Scaffolds a complete React component with TypeScript types, Tailwind styles, Storybook stories, and unit tests. Follows project conventions automatically.
CI/CD Pipeline Generator
Generates GitHub Actions workflows for CI/CD including linting, testing, building, and deploying. Detects project stack automatically.