best-practices
Transforms vague prompts into optimized Claude Code prompts. Adds verification, specific context, constraints, and proper phasing. Invoke with /best-practices.
What this skill does
# Best Practices — Prompt Transformer
> Transform prompts by adding what Claude needs to succeed.
## Start Here
Based on user's request:
**User provides a prompt to transform:**
→ Ask using AskUserQuestion:
- **Question:** "How should I improve this prompt?"
- **Header:** "Mode"
- **Options:**
1. **Transform directly** — "I'll apply best practices and output an improved version"
2. **Build context first** — "I'll gather codebase context and intent analysis first"
**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
---
## If "Transform directly"
Apply the 5 principles below and output the improved prompt immediately.
## If "Build context first"
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]")
```
### What Each Agent Returns
| 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 |
### After Agents Return
1. **Synthesize findings** — Combine intent + best practices + codebase context
2. **Apply matching patterns** — Use examples from best-practices-referencer as templates
3. **Ground in codebase** — Add specific file paths from codebase-context-builder
4. **Transform the prompt** — Apply the 5 principles with all gathered context
5. **Output** — Show improved prompt with before/after comparison
### Agent Definitions
The agents are defined in `agents/`:
- `agents/task-intent-analyzer.md` — Analyzes intent, gaps, and edge cases
- `agents/best-practices-referencer.md` — Finds relevant examples and patterns from references/
- `agents/codebase-context-builder.md` — Explores codebase for files and conventions
---
## Transformation Workflow
When transforming (after mode selection):
1. **Identify what's missing** — Check against the 5 principles below
2. **Add missing elements** — Verification, context, constraints, phases, rich content
3. **Output the improved prompt** — In a code block, ready to copy-paste
4. **Show what changed** — Brief comparison of before/after
---
## The 5 Transformation Principles
Apply these in order of priority:
### 1. Add Verification (Highest 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."
```
### 2. Provide Specific Context
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:
- Not contradict project conventions
- Reference project-specific patterns when relevant
- Note any project constraints that apply
```
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"
```
### 3. Add Constraints
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"
```
### 4. Structure Complex Tasks in Phases
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:**
- Uncertain about the approach
- Change modifies multiple files
- Unfamiliar with the code being modified
**Skip phases when:**
- Could describe the diff in one sentence
- Fixing a typo, adding a log line, renaming a variable
```
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"
```
### 5. Include Rich Content
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.Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.