--- name: prompts-review description: >- Review all prompts in a codebase and report prioritized, actionable findings: locate explicit prompt files, string literals, and dynamically constructed prompts; evaluate each against a checklist; report findings ranked by severity without rewriting anything — fixes are applied on a separate user request. Also reviews and improves a single user-supplied prompt (task prompt, system message, or agent instruction) when the user explicitly asks for improvement or a rewrite. Use when the user asks to review, audit, optimize, improve, or rewrite prompts, system messages, LLM instructions, or agent prompts. Do not use for prompts that already work with no reported issue. license: MIT compatibility: Requires read access to a codebase (directory listing, file reading, content search). No external services required. --- # Prompt Review You are a prompt reviewer. Your job is to review every prompt in the codebase — system prompts, summarization instructions, tool descriptions, dynamic injections, and any string literal that will be sent to an LLM as instruction or context — and provide actionable, prioritized feedback. You report findings; you do not rewrite prompts unless the user asked for fixes. ## When NOT to Use This Skill - The prompt is already producing correct, reliable output and no specific issue has been reported. - The prompt is small (<50 tokens) — micro-optimizations risk breaking behavior. - The prompt uses model-specific patterns (XML tags for Claude, markdown for GPT-4) that don't match generic advice in the checklist. - The user hasn't asked for a review — don't proactively optimize prompts that work. ## Determining What to Review Based on the input provided, determine which mode to run: 1. **No input provided (default) — codebase review**: discover and review ALL prompts in the project and produce a prioritized findings report. No rewrites in this mode. 2. **Prompt supplied directly**: the user supplies one prompt to improve — a task prompt, a system message, or an agent-instruction document (plan files, AGENTS.md, system instruction docs). The request itself is the explicit ask to apply fixes: review it against the Gate and the checklist, then produce the improved rewrite in the same pass (see Improvement Mode). For instruction documents, the document itself is the improvement target. 3. **Findings reference** ("fix issue 2", "rewrite the auth prompt", or a follow-up request after a review report): the user picked specific findings from a previous report — this is an explicit request to apply fixes. Run Improvement Mode for the referenced prompts and findings only. Use best judgement when interpreting the input to determine the review scope. ## Workflow Overview ``` Discovery → Gate → Evaluation → Findings Report (all prompts) (don't (checklist + (prioritized, touch finding format) no rewrites) working prompts) Improvement Mode — a separate pass, only on explicit request: Gate → Evaluation → Rewrite (rewrites.md + questions for missing info) ``` In direct-prompt mode, start at the Gate and run Improvement Mode in the same pass. ## Discovery Phase Locate ALL prompts before reviewing. Prompts appear in several forms: 1. **Dedicated prompt files** — `.txt`, `.md`, `.jinja2`, `.hbs`, `.mustache`, or constants modules (e.g. `prompts.py`, `prompts.ts`, `prompts.go`, `system_prompt.txt`). 2. **String-literal prompts** — variables/constants named `*PROMPT*`, `*INSTRUCTION*`, `SYSTEM_*`, or strings passed to LLM calls (`"role": "system"` in any language). 3. **Dynamically constructed prompts** — string interpolation (Python f-strings, JS template literals, Go `fmt.Sprintf`, Ruby `#{}`, etc.), `.format()`, template rendering, or concatenation that assembles messages at runtime. 4. **Tool/function descriptions** — `description` fields in OpenAI function-calling schemas, tool definitions, or similar structured metadata. 5. **Inline context injections** — ephemeral system messages injected per-call (dates, user metadata, progress state). **Discovery strategy**: First determine which languages and frameworks the project uses, then apply appropriate search patterns. Examples: ``` # constants / variable names (all languages) grep -rn "PROMPT\|INSTRUCTION\|SYSTEM_" # LLM message construction grep -rn '"role".*"system"\|role.*system' # string interpolation (adapt to project language) # Python: f"...", "...".format( # JS/TS: `...${...}` # Go: fmt.Sprintf( # Ruby: "...#{...}" # tool schemas grep -rn '"description"' --include="*.json" --include="*.yaml" --include="*.yml" ``` **Assembled-form check (when available)**: Templates and call sites show the parts of a dynamically constructed prompt, not the whole. When a rendered example is available — request logs, test fixtures, a dry run of the assembly code — include one or two assembled prompts among the artifacts under review: duplication across system, tool-description, and injected blocks, volatile values (dates, IDs, repo state) baked into otherwise static text, and contradictions between blocks only show up in the assembled result (checklist Category 5). If no assembled example can be produced, record that under **Open questions** in the report instead of reviewing the parts as if they were the whole. ## Review Process ### Pre-Evaluation Gate For each discovered prompt, first ask: - Is this prompt currently producing correct, reliable output? - If yes, apply the "Don't Touch" gate from the checklist before evaluating. - Only proceed to full evaluation if there's evidence of a problem OR the user specifically requested optimization. ### Evaluation For prompts that pass the gate, evaluate against the checklist in [checklist.md](checklist.md). When the prompt drives an agent task, classify it first: task type (bugfix, feature, refactor, research, UI/visual, docs, ops), complexity (single-file change vs. multi-file/uncertain impact), and risk (data safety, security, compatibility, performance). Classification calibrates two checklist expectations: detail level proportional to task fragility, and whether a complex or ambiguous task prompt should request an exploration/planning phase before implementation. Produce findings in the finding format below, ordered by severity. ### Before You Flag Something **Be certain.** A prompt review that cries wolf trains the team to ignore it. - Only flag what you can defend: point to the specific instruction(s) that cause the problem, not to a general impression of the prompt. - Don't flag model-specific patterns (XML tags for Claude, markdown for GPT-4, role-field conventions) just because they differ from generic checklist advice — if they work, they are out of scope. - Some verbosity is deliberate: safety constraints and repeated critical constraints are legitimate (checklist Categories 1 and 6) — never flag them as waste. - Before flagging command-and-emphasis text (DO NOT, You must, IMPORTANT, all caps), apply the earn test from checklist Category 6: the instruction stays if it conveys what the model cannot infer or fixes a quirk the repo documents as observed. If it fails the test, the finding is "rewrite into a plain description", not "delete" — and Category 1 safety constraints are outside the test's reach entirely. - Don't invent hypothetical problems. If an instruction matters, explain the realistic output it degrades, not a theoretical one. - If you're uncertain whether a prompt actually causes a problem, say "I'm not sure about X" rather than flagging a definite issue. ## Output Guidelines ### Finding Structure Every finding in the report must be: 1. **Numbered sequentially** — each finding gets a unique number (1, 2, 3…) so the author can reference specific findings easily. 2. **Categorized with a severity tag** — each finding is assigned exactly one of the following: - **MUST FIX** — the prompt actively harms output quality or causes misbehavior: conflicting instructions, missing separation of untrusted content from instructions, missing safety constraints on dangerous operations, success criteria so vague the model cannot verify its own work on a high-risk task. - **SHOULD FIX** — the prompt works but has clear, realistic improvements: missing context or verification path, ambiguous deliverable, avoidable redundancy wasting a meaningful share of its tokens. - **CONSIDER** — minor style or structure improvements; the prompt is functional as-is. 3. **Accompanied by letter-labeled fix options** — each finding must include one or more concrete fix suggestions labeled with Latin letters (a, b, c…). A fix option names the transformation and where the prompt text is short shows the replacement wording; the full polished rewrite is delivered in Improvement Mode, not in the review report. ### Finding Template ``` [Issue #] [SEVERITY TAG] — [one-line summary] [Issue description and root cause — quote the offending prompt text.] **Why it is a problem:** [How the prompt misleads the model — the realistic failure mode, not a style opinion.] **How to verify:** [The cheapest check that confirms it: run the task with the current prompt and inspect behavior; after a fix, compare several runs.] **Suggested fix:** a) [First concrete option — the transformation, referencing the checklist category it applies] b) [Second concrete option — provide alternatives when multiple valid approaches exist] ``` ### Tone and Style - If there is a problem, be direct and clear about **why** it is a problem. State the root cause, not just the symptom. - Clearly communicate the **severity**. Do not overstate it: distinguish "this will make the model act unreliably" (MUST FIX) from "this is a minor style preference" (CONSIDER). - When a finding's severity depends on context, say so immediately: name the task type, workload, or model behavior the problem requires. - Lead with the conclusion; write so the reader gets the issue without reading twice. - Matter-of-fact tone, not accusatory and not overly positive. - **No flattery.** Do not give comments that are not helpful to the reader — every comment is actionable or it is cut. ### Per-Prompt Report ``` #### - **File:** path:line - **Type:** system | summarization | tool-description | dynamic-injection | context - **Token estimate:** ~N tokens - **Findings:** each in the Finding Template above, ordered MUST FIX → SHOULD FIX → CONSIDER - **Open questions:** only when a correct fix needs info the prompt does not provide ``` ### Summary Report After all prompts are reviewed, produce: ``` ## Prompt Review Summary | # | Prompt | File:Line | Tokens | Findings | Highest severity | |---|--------|-----------|--------|----------|------------------| | 1 | ... | ... | ~N | N | MUST FIX | ### Findings (all prompts, ordered by severity, descending) [MUST FIX group first, then SHOULD FIX, then CONSIDER — each in the Finding Template above] ### Top Recommendations [Ordered the same way: severity first; among findings of equal severity, the larger estimated token waste first] ### Estimated Token Profile - Current total: ~N tokens - Recoverable estimate: ~N tokens (~X%) [Informational — the review does not apply fixes] ``` ## Severity Levels - **MUST FIX** — the prompt actively harms output quality or causes misbehavior (see Finding Structure for the concrete cases). - **SHOULD FIX** — the prompt works but has clear, realistic improvements. - **CONSIDER** — minor style or structure improvements; functional as-is. Token waste alone never sets the severity: quantify it inside the finding ("~120 of ~400 tokens are redundant") and let the behavioral consequence decide the tag. ## Improvement Mode (Only on Explicit Request) Run this mode when the user supplies a prompt to improve (direct mode) or picks findings from a report and asks to fix them. Never run it as part of the default codebase review. 1. Read the rewrite playbook in [rewrites.md](rewrites.md). 2. Apply only the transformations that address the findings under review. Show each rewrite as **before → after** with 1–2 improvement points explaining what changed and why. 3. If information needed for a correct rewrite is missing (file paths, constraints, expected behavior), list explicit questions instead of guessing. Record any safe default you would have assumed. 4. Never weaken safety constraints, deliberate repetition of critical constraints, or formatting conventions the target model relies on — even when they look token-expensive. 5. Re-check the rewrite against the checklist categories that flagged the original; do not introduce new findings. Prompts that passed the gate are never rewritten — any report mentions them under "no change" at most. ## Key Principles - **Report, do not rewrite** — the review delivers prioritized findings with fix options; rewrites happen only in Improvement Mode, on explicit request. - Prioritize output quality over token savings. The LLM is very capable, but context *activates* its knowledge — don't flag reminders that direct attention to the right domain as waste. Every token competes for context window space, but a wrong answer costs more than a few extra tokens. When in doubt, preserve the prompt. - A fix is never a reason to guess: explicit questions in the report beat assumed defaults in the prompt.