kit/plugins/plan-agent/skills/refine-prompt/SKILL.md
Refine-prompt: interviews users and assembles a structured AI prompt using Anthropic best-practice techniques. Use when the user runs /plan-agent:refine-prompt or asks to refine a prompt.
npx skillsauth add shawn-sandy/agentics refine-promptInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Interview the user about their prompting need, classify the prompt type, apply the applicable Anthropic best-practice techniques, and deliver a copy-pasteable, well-structured AI prompt.
On invocation via /plan-agent:refine-prompt, $ARGUMENTS contains the user's
initial intent or topic. If $ARGUMENTS is non-empty, use it to seed Phase 1
(Classify) and skip the "what do you need?" opener. If empty, ask: "What kind of
prompt do you need help crafting?"
Identify the prompt type from $ARGUMENTS or the user's stated need. Classify into one of four types:
| Type | When to use | | -------------- | ------------------------------------------------------------------------------- | | system | A system prompt or persona for an AI assistant, chatbot, or agent | | task | A one-shot task instruction (refactor code, summarize document, translate text) | | creative | Creative writing, storytelling, tone generation, or style mimicry | | analytical | Research, analysis, comparison, or synthesis of information or documents |
After classifying, apply the technique matrix — the set of Anthropic best-practice layers that apply to this type:
| Prompt type | Applicable techniques |
| ----------- | ----------------------------------------------------------------------------------------------------- |
| system | Role assignment, XML structure (<instructions>, <constraints>), output format, guardrails |
| task | Clarity/directness, XML structure (<context>, <example>), thinking/CoT scaffolding, output format |
| creative | Role assignment, tone/voice instructions, context/motivation, output format, positive framing |
| analytical | Long-context patterns (<document>, <quote>), thinking/CoT, self-check, output format |
If the input does not clearly match any single type, ask the user to clarify via
AskUserQuestion with the four types as options: "Which best describes what
you're building?" — then proceed with the chosen type.
Announce the classified type and selected technique matrix to the user in one short sentence:
"Classified as task prompt — I'll apply: clarity, XML context tags, CoT scaffolding, and output format."
Gather context from the user using type-specific questions grounded in Anthropic's "Add context to improve performance" principle. The key is to extract the user's why, not just their what.
Use AskUserQuestion with a batched set of 2–3 essential questions determined by the classified type:
system prompt questions:
task prompt questions:
creative prompt questions:
analytical prompt questions:
After the first AskUserQuestion batch, ask: "Would you like to go deeper for a more refined prompt? I can ask 2–3 follow-up questions." Only run a second AskUserQuestion batch if the user confirms.
Apply the XML structural techniques selected by the technique matrix from Phase 1 to the gathered interview responses.
Map interview answers to XML layers:
<role>...</role><instructions>...</instructions>, constraints in
<constraints>...</constraints><context>...</context><example>...</example> slot with
placeholder from interview answer<thinking>...</thinking>
scaffold before the main instruction<document>{{DOCUMENT_CONTENT}}</document> wrapper and quote-extraction
instructionSkip any layer whose type is not in the technique matrix for this prompt.
Assemble the final prompt by reading the relevant template from this skill's references/ directory, substituting the structured Phase 3 output into the template placeholders.
Template selection by type:
${CLAUDE_PLUGIN_ROOT}/skills/refine-prompt/references/system-prompt-template.md${CLAUDE_PLUGIN_ROOT}/skills/refine-prompt/references/task-prompt-template.md${CLAUDE_PLUGIN_ROOT}/skills/refine-prompt/references/creative-prompt-template.md${CLAUDE_PLUGIN_ROOT}/skills/refine-prompt/references/analytical-prompt-template.mdRead the template with the Read tool, resolving the path as
${CLAUDE_PLUGIN_ROOT}/skills/refine-prompt/references/<type>-prompt-template.md.
If ${CLAUDE_PLUGIN_ROOT} is unavailable, fall back to a Glob search:
Glob("**/plan-agent/skills/refine-prompt/references/<type>-prompt-template.md").
Substitute all {{PLACEHOLDER}} values in the template with the structured
content from Phase 3, the interview answers from Phase 2, and the user's intent
from Phase 1. Remove any placeholder lines where the technique was not selected
by the matrix (e.g. remove <thinking> block for creative prompts).
Apply these writing rules from Anthropic's best practices:
Search the session's live tool registry for installed skills, agents, or commands that match the user's intent — they may supersede the need for a custom prompt entirely.
Use ToolSearch with 2–3 keyword queries derived from the user's intent and the classified prompt type:
If no relevant tools are found, skip the recommendation block silently.
Present the assembled prompt in a fenced code block the user can copy-paste directly. Include:
Format:
**Prompt type:** task — techniques applied: Clarity, XML structure, CoT scaffolding, Output format
```text
[assembled prompt here]
```
**Installed tools that may achieve this directly:**
- /code-review — Reviews code for bugs and quality. Use when the refactoring goal is code quality rather than transformation.
After delivering, offer: "Want me to refine this further? I can add examples, tighten the output format, or adjust the tone."
After delivering the prompt in Phase 6, save it as a markdown file in the
resolved prompts/ directory.
Resolve the output directory (first match wins):
promptsDirectory from .claude/settings.json (check project-level
.claude/settings.json first, then ~/.claude/settings.json). If the key is
present and non-empty, strip any trailing slash and use that path as the
output directory.git rev-parse --show-toplevel and
join the result with docs/prompts (e.g. $(git rev-parse --show-toplevel)/docs/prompts).
If git rev-parse fails (not a git repo), fall back to docs/prompts relative to $PWD.Create the directory if it does not already exist:
mkdir -p "<resolved-directory>"
Derive the filename:
Build the filename from three parts joined with hyphens, all lowercase kebab-case:
task, system, creative,
analytical)YYYY-MM-DD formatPattern: {type}-{intent-slug}-{YYYY-MM-DD}.md
Examples:
task-refactor-auth-middleware-2026-06-04.mdsystem-customer-support-bot-2026-06-04.mdanalytical-compare-pricing-models-2026-06-04.mdUniqueness guard: before writing, check whether
{resolved-directory}/{filename} already exists. If it does, append -2 to the
base name (before .md), then -3, etc., until the path is unique.
Write the file using the Write tool. The file content must be:
---
type: {classified type}
intent: {one-sentence summary of the user's stated goal}
techniques: {comma-separated list of techniques applied}
created: {YYYY-MM-DD}
---
# {Prompt type}: {intent slug, title-cased}
{the raw assembled prompt text from Phase 4 — substituted content, NOT the Phase 6 fenced display block; embed the prompt as plain text}
Confirm to the user in one line after saving:
"Saved to
{resolved-directory}/{filename}."
development
Turns a React component into a social card with preview, code, and props table. Builds a static preview and screenshots react-card.html via Playwright. Use when asked to share a React component.
development
Plan review Agent Team. Reviews HTML implementation plans in parallel, synthesizes findings, and applies improvements in place. Use when the user asks to review or improve an implementation plan.
data-ai
Craft-prompt: interviews users and assembles a structured AI prompt using Anthropic best-practice techniques. Use when the user runs /plan-agent:craft-prompt or asks to craft a prompt.
development
Generates a SOCIAL.md project sharing config by analyzing the codebase. Use when asked to set up social sharing preferences or create a SOCIAL.md file.