Transforms vague prompts into optimized Claude Code prompts. Adds verification, specific context, constraints, and proper phasing. Invoke with /best-practices.
Transform prompts by adding what Claude needs to succeed.
Based on user's request:
User provides a prompt to transform: → Ask using AskUserQuestion:
User asks to learn/understand: → Show the 5 Transformation Principles section
User asks for examples: → Link to references/before-after-examples.md
User asks to evaluate a prompt: → Use the Success Criteria eval rubric at the end of this document
Apply the 5 principles below and output the improved prompt immediately.
Launch 3 parallel agents to gather context:
Run these agents IN PARALLEL using the Task tool:
- Task task-intent-analyzer("[user's prompt]")
- Task best-practices-referencer("[user's prompt]")
- Task codebase-context-builder("[user's prompt]")
| Agent | Mission | Returns |
|---|---|---|
| task-intent-analyzer | Understand what user is trying to do | Task type, gaps, edge cases, transformation guidance |
| best-practices-referencer | Find relevant patterns from references/ | Matching examples, anti-patterns to avoid, transformation rules |
| codebase-context-builder | Explore THIS codebase | Specific file paths, similar implementations, conventions |
The agents are defined in agents/:
agents/task-intent-analyzer.md — Analyzes intent, gaps, and edge casesagents/best-practices-referencer.md — Finds relevant examples and patterns from references/agents/codebase-context-builder.md — Explores codebase for files and conventionsWhen transforming (after mode selection):
Apply these in order of priority:
The single highest-leverage improvement. Claude performs dramatically better when it can verify its own work.
| Missing | Add |
|---|---|
| No success criteria | Test cases with expected inputs/outputs |
| UI changes | "take screenshot and compare to design" |
| Bug fixes | "write a failing test, then fix it" |
| Build issues | "verify the build succeeds after fixing" |
| Refactoring | "run the test suite after each change" |
| No root cause enforcement | "address root cause, don't suppress error" |
| No verification report | "summarize what you ran and what passed" |
BEFORE: "implement email validation"
AFTER: "write a validateEmail function. test cases: [email protected] → true,
invalid → false, [email protected] → false. run the tests after implementing"
BEFORE: "fix the API error"
AFTER: "the /api/orders endpoint returns 500 for large orders. check
OrderService.ts for the error. address the root cause, don't suppress
the error. after fixing, run the test suite and summarize what passed
and what you verified."
Replace vague references with precise locations and details.
| Vague | Specific |
|---|---|
| "the code" | src/auth/login.ts |
| "the bug" | "users report X happens when Y" |
| "the API" | "the /api/users endpoint in routes.ts" |
| "that function" | processPayment() on line 142 |
Four ways to add context:
| Strategy | Example |
|---|---|
| Scope the task | "write a test for foo.py covering the edge case where user is logged out. avoid mocks." |
| Point to sources | "look through ExecutionFactory's git history and summarize how its API evolved" |
| Reference patterns | "look at HotDogWidget.php and follow that pattern for the calendar widget" |
| Describe symptoms | "users report login fails after session timeout. check src/auth/, especially token refresh" |
Respect Project CLAUDE.md:
If the project has a CLAUDE.md, the transformed prompt should:
BEFORE: "add a new API endpoint"
AFTER: "add a GET /api/products endpoint. check CLAUDE.md for API conventions
in this project. follow the pattern in routes/users.ts. run the API
tests after implementing."
BEFORE: "fix the login bug"
AFTER: "users report login fails after session timeout. check the auth flow
in src/auth/, especially token refresh. write a failing test that
reproduces the issue, then fix it"
Tell Claude what NOT to do. Prevents over-engineering and unwanted changes.
| Constraint Type | Examples |
|---|---|
| Dependencies | "no new libraries", "only use existing deps" |
| Testing | "avoid mocks", "use real database in tests" |
| Scope | "don't refactor unrelated code", "only touch auth module" |
| Approach | "address root cause, don't suppress error", "keep backward compat" |
| Patterns | "follow existing codebase conventions", "match the style in utils.ts" |
BEFORE: "add a calendar widget"
AFTER: "implement a calendar widget with month selection and year pagination.
follow the pattern in HotDogWidget.php. build from scratch without
libraries other than the ones already used in the codebase"
For larger tasks, separate exploration from implementation.
The 4-Phase Pattern:
Phase 1: EXPLORE
"read src/auth/ and understand how we handle sessions and login.
also look at how we manage environment variables for secrets."
Phase 2: PLAN
"I want to add Google OAuth. What files need to change?
What's the session flow? Create a plan."
Phase 3: IMPLEMENT
"implement the OAuth flow from your plan. write tests for the
callback handler, run the test suite and fix any failures."
Phase 4: COMMIT
"commit with a descriptive message and open a PR"
When to use phases:
Skip phases when:
BEFORE: "add OAuth"
AFTER: "read src/auth/ and understand current session handling. create a plan
for adding OAuth. then implement following the plan. write tests and
verify they pass"
Provide supporting materials that Claude can use directly.
| Content Type | How to Provide |
|---|---|
| Files | Use @filename to reference files |
| Images | Paste screenshots directly |
| Errors | Paste actual error messages, not descriptions |
| Logs | Pipe with cat error.log | claude |
| URLs | Link to relevant documentation |
BEFORE: "make the dashboard look better"
AFTER: "[paste screenshot] implement this design for the dashboard.
take a screenshot of the result and compare it to the original.
list any differences and fix them. ensure responsive behavior
at 768px and 1024px breakpoints"
BEFORE: "the build is failing"
AFTER: "the build fails with this error: [paste actual error]. fix it
and verify the build succeeds. address the root cause, don't
suppress the error"
When transforming a prompt, output:
**Original:** [their prompt]
**Improved:**
[transformed prompt in code block]
**Added:**
- [what was missing and added]
- [another improvement]
- [etc.]
BEFORE: "fix the login bug"
AFTER: "users report login fails after session timeout. check the auth flow
in src/auth/, especially token refresh. write a failing test that reproduces
the issue, then fix it. verify by running the auth test suite."
ADDED: symptom, location, verification (failing test), success criteria
BEFORE: "add a search feature"
AFTER: "implement search for the products page. look at how filtering works
in ProductList.tsx for the pattern. search should filter by name and category.
add tests for: empty query returns all, partial match works, no results shows
message. no external search libraries."
ADDED: location, reference pattern, specific behavior, test cases, constraint
BEFORE: "make the code better"
AFTER: "refactor utils.js to use ES2024 features while maintaining the same
behavior. specifically: convert callbacks to async/await, use optional
chaining, add proper TypeScript types. run the existing test suite after
each change to ensure nothing breaks."
ADDED: specific changes, constraint (same behavior), verification after each step
BEFORE: "add tests for foo.py"
AFTER: "write tests for foo.py covering the edge case where the user is
logged out. avoid mocks. use the existing test patterns in tests/. test