mk:prompt-enhancer
Refine a draft user prompt using a 5-step framework — mode-select, decompose, detect, (scout if --deep), map, rewrite — grounded in 7 source docs <!-- research-citation --> (Anthropic / OpenAI Codex / FactoryAI prompting + Anthropic context-engineering
- skill-authoring rules). The rewrite uses the universal kernel only:
plain markdown sections, no XML tags, no vendor tokens, no model overlays.
When to use
- Draft prompt is ambiguous, missing context, weakly structured, or coupled to one model's framing (XML, role-as-XML, "think step by step", etc.).
- User says: "enhance prompt", "optimize prompt", "make this prompt better", "rewrite this prompt".
- Want to see WHY a prompt was rewritten: append
--analyze. - Want a numeric quality score on the original prompt: append
--score(auto-promotes to--analyze --score). - For codebase-aware suggestions: append
--deep(opt-in only). - Explicit:
/mk:prompt-enhancer [--analyze] [--score] [--deep] [--save-to <path>] [text].
When NOT to use
- Generating a prompt from scratch →
mk:brainstorming(technical) /mk:office-hours(product). - Re-examining a code review or plan →
mk:elicit. - Building an implementation plan →
mk:plan-creator. - Auditing running output of an LLM →
mk:evaluateormk:review. - General codebase scouting →
mk:scoutdirectly.
Workflow
Mode-Select → Decompose → Detect → (Scout if --deep) → Map → Rewrite. Detail in references/decomposition-checklist.md, references/playbook.md, references/context-safeguards.md, and references/deep-mode-scout.md. Do not invent steps.
Inputs
- Required: a draft prompt (text). Empty / missing → refuse with redirect.
- Optional:
--analyze(include decomposition + detected issues + improvement suggestions). - Optional:
--score(add 1–10 quality score on the original prompt; auto-promotes to--analyze --scorebecause score requires the rubric components). - Optional:
--deep(opt-in scout against allow-listed sources). - Optional:
--save-to <path>(default: active plan dir if any, else${CLAUDE_PLUGIN_DATA}/...).
The skill does not accept a --model flag. Per the synthesis report (plans/reports/synthesis-260509-2058-prompting-framework.md), model detection violates the model-agnostic mandate; dispatch by model-tier lives in harness-rules.md Rule 5, not here.
Output
Mode-aware. See assets/output-template.md for the templates.
| Flags | Output | |---|---| | (none) — default | Section 4 only — the Enhanced Prompt code block | | --analyze | Sections 1, 2, 3, 4 (decomposition + issues + suggestions + rewrite) | | --analyze --score | Sections 1, 2, 3 + Score: N/10 block + Section 4 | | --score (alone) | Auto-promoted to --analyze --score | | --deep (any mode) | Appends "Suggested context" sub-block to Section 4 when scout returns ≥1 hit |
Internal decomposition + detection still run in default mode — they feed the rewrite — but they are NOT emitted unless --analyze is set. The OUTPUT FORMAT line inside the rewrite always carries the auto-suggested Freedom level (LOW / MEDIUM / HIGH) and Verbosity (terse / structured / confirmation).
References
references/decomposition-checklist.md— 5 components + 10-item weakness checklist.references/playbook.md— improvement fixes, one per checklist item, with doc citation. Includes the deterministic Scoring Rubric used by--score.references/context-safeguards.md— 6 model-agnostic safeguards (right-altitude tone, identifier-based context, long-horizon defenses, tool-result clearing, bloat avoidance, eval discipline). Loaded JIT when input shows long-horizon signals or codebase-context references.references/deep-mode-scout.md—--deepallow-list, forbid-list, hard caps, fallback.
Hard Constraints (read every run)
Default mode (always):
- Preserve user intent verbatim. Never silently change the core ask.
- Never invent facts. Unknown values become
[FILL-IN: <description>]placeholders. - No padding. Only emit suggestions for FOUND issues. (Default mode hides suggestions entirely;
--analyzereveals them.) - Universal kernel only. Plain markdown sections (Goal / Context / Constraints / Acceptance Criteria / Output Format). No XML tags, no role-as-XML, no model overlays. If the input prompt contains model-coupled framing, flag it as detection #10 and strip during rewrite.
- Default = enhanced prompt only. Without
--analyze, emit ONLY the Section 4 code block. No Section 1/2/3 headings, no preamble prose, no score. The rewrite is the deliverable; everything else is diagnostics.
--analyze mode (additional):
- Show all 4 sections. Decomposition table, identified issues (FOUND only — no padding), improvement suggestions (one per finding, citing source doc per
references/playbook.md), then the rewrite. --scorerequires--analyze. If--scoreis passed alone, auto-promote to--analyze --score(silent — score is meaningless without the rubric components on screen).- Score is deterministic. Compute via the formula in
references/playbook.md"Scoring Rubric". Never a vibes-based estimate. Show the breakdown alongside the integer.
--deep mode (additional):
- Allow-list only. Read only
docs/project-context.md,CLAUDE.md, repo file-tree
paths, public docstrings. Default-deny everything else (especially .claude/memory/, .env, tasks/, secrets).
- Suggest, never substitute. Scout outputs go in
[FILL-IN: <desc> (suggested: <path>)]
brackets. The user is the source of truth.
- Bounded scout. ≤8 files, ≤100 lines/file, ≤30s wall clock. Exceed → abort with
SCOUT_BUDGET_EXCEEDED; fall back to default mode.
The Skill tool entry in allowed-tools is reserved for invoking mk:scout under --deep only — not a license to spawn other skills.
Freedom Level Auto-Suggestion
Per skill-authoring (railroading anti-pattern), the rewrite suggests one of three modes in the OUTPUT FORMAT section. Auto-detect from task shape; the user can override.
| Detected signal | Suggested level | Rationale | |---|---|---| | Migration / destructive op / security fix / "do not deviate" wording | LOW | Fragile or sequenced — agent should follow exact procedure | | Standard feature work, refactor with known pattern, bug fix | MEDIUM | Default — outcome-driven with back-compat fence | | Open-ended exploration, design call, "explore" / "consider" verbs | HIGH | Judgment task — terse intent beats step-by-step |
Detection precedence: explicit user signal > destructive verbs > default to MEDIUM.
Persistence
- Active plan? Save to
{plan-dir}/prompt-enhancer/<YYMMDD-HHMM>-<short-slug>.md. - No active plan? Save to
${CLAUDE_PLUGIN_DATA}/prompt-enhancer/<YYMMDD-HHMM>-<short-slug>.md. - Never write to the skill directory.
Gotchas
(Seeded — grow from observed failures.)
- Default mode emits ONLY the enhanced prompt code block. No Section 1/2/3 headings, no preamble prose, no score, no "here's the rewrite" intro line. The
--deep"Suggested context" sub-block is the ONLY thing allowed to append after the rewrite in default mode. --scorewithout--analyzeis auto-promoted to--analyze --score. A bare score with no rubric breakdown is misleading; the user needs to see WHY they got 6/10.- Score is deterministic, not vibes. Compute via the formula in
references/playbook.md"Scoring Rubric". Never round arbitrarily; never inflate to make the user feel good. - Score reflects the ORIGINAL prompt, not the rewrite. The rewrite by construction scores 10/10 — that's not interesting. The score answers "how bad was the input?".
- Don't invent examples the user didn't supply. Flag the gap; suggest 1–3.
- Output uses plain markdown headings — no XML, no
<context>tags, no role-as-XML. Universal kernel only. - If input prompt is wrapped in XML or carries vendo