Optimize vague or unclear prompts into specific, well-structured requests that get better results from Claude.
Optimizes vague prompts into specific, well-structured requests that get better results from Claude.
/plugin marketplace add Data-Wise/craft/plugin install data-wise-craft@Data-Wise/craftworkflow/Optimize vague or unclear prompts into specific, well-structured requests that get better results from Claude.
Help users write better prompts by:
/refine "<your prompt>" - Optimize a specific prompt/refine - Interactive mode (will ask for prompt)If provided as argument:
/refine "Can you help me write a function that does X?"
Use the provided text.
If invoked without argument:
š” PROMPT OPTIMIZER
Paste or type the prompt you want to optimize:
(Type 'cancel' to exit)
>
Wait for user input.
Before optimizing, gather context:
Project type - Check for:
Project instructions - Read if exists:
CLAUDE.md in project~/.claude/CLAUDE.md for user preferencesRecent work - Check git log (last 3 commits) for context
Coding patterns - Infer from context:
Identify issues:
Rewrite to be:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š ORIGINAL PROMPT
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
[User's original prompt, as-is]
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
⨠OPTIMIZED PROMPT
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
[Rewritten version with improvements]
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š IMPROVEMENTS MADE
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
⢠[Improvement 1] - [Why it matters]
⢠[Improvement 2] - [Why it matters]
⢠[Improvement 3] - [Why it matters]
Context used:
⢠[Context point 1 - e.g., "Detected Python project"]
⢠[Context point 2 - e.g., "Found pytest in dependencies"]
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
šÆ NEXT STEPS
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Estimated execution time: ~{duration}
1. Execute now (wait for completion) ā³
2. Execute in background (continue working) ā Recommended
3. Revise - Tell me what to change
4. Copy to clipboard
š” TIP: Choose #2 to continue working while I execute this!
>
If user chooses "1" or "Execute" or "yes" or "wait":
ā
Executing optimized prompt now...
[Proceed to execute the optimized prompt as if user had typed it]
[Wait for completion and show results]
If user chooses "2" or "background" or "bg": (NEW)
ā
Launching background agent with optimized prompt...
š Running in background. Continue your work!
Task ID: {task_id}
Estimated completion: {estimated_duration}
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š” What to do while waiting:
⢠Continue working on other tasks
⢠Check status: /workflow:task-status {task_id}
⢠View output when ready: /workflow:task-output {task_id}
I'll notify you when execution is complete!
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š Optimized prompt saved to PROMPTS.md for reference
Implementation:
run_in_background: truesubagent_type: "general-purpose"/workflow:refineWhen task completes (automatic notification):
š Prompt execution complete! (task: {task_id})
Original: "{original_prompt}"
Duration: {actual_duration}
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
View results now?
y / yes - Show execution results
later - Review later
>
If user says "y" or "yes":
If user says "later":
ā
Results saved
View anytime with:
/workflow:task-output {task_id}
Ready for next task!
If user chooses "3" or "Revise":
What would you like to change about the optimization?
Examples:
⢠"Make it simpler"
⢠"Add more about error handling"
⢠"Remove the testing requirement"
⢠"Focus on performance instead"
Your feedback:
>
[Wait for feedback, then regenerate optimization with their input, show new version, repeat choice prompt]
If user chooses "4" or types "copy":
ā
Copied to clipboard!
The optimized prompt is now in your clipboard.
Ready to paste anywhere:
⢠New Claude Code session
⢠claude.ai web interface
⢠Documentation
⢠Email/Slack
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Clipboard contains:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
[First 3 lines of optimized prompt...]
[...truncated for display]
Paste it wherever you need! āØ
[Use pbcopy on macOS, xclip on Linux to copy to clipboard]
If user types "cancel" or "exit":
Cancelled. No changes made.
User: /refine "Can you help me write a function that does X?"
Claude:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š ORIGINAL PROMPT
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Can you help me write a function that does X?
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
⨠OPTIMIZED PROMPT
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Write a Python function called `do_x()` that:
- Performs action X with input validation
- Handles edge cases: None, empty string, invalid types
- Returns a dict with 'result' (Any) and 'status' (str) keys
- Includes type hints for all parameters and return value
- Add a docstring with description, args, returns, and example
- Write 3 test cases covering: normal input, edge case, error case
Use pytest for tests and follow PEP 257 docstring conventions.
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š IMPROVEMENTS MADE
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
⢠Specified language (Python) - Detected from pyproject.toml
⢠Made directive instead of question - More effective prompting
⢠Added function name - Clear what to create
⢠Included edge cases - Better code quality
⢠Specified return type - Clear interface
⢠Added quality criteria - Tests, docs, type hints
⢠Referenced conventions - Matches project style
Context used:
⢠Detected Python project (has pyproject.toml)
⢠Found pytest in dev dependencies
⢠Your code style uses type hints (inferred from existing code)
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
šÆ NEXT STEPS
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
1. Execute now ā (Recommended)
2. Revise - Tell me what to change
š” Advanced: Type 'copy' to save to clipboard
>
User: /refine "make this code better"
Claude:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š ORIGINAL PROMPT
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
make this code better
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
⨠OPTIMIZED PROMPT
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Review and improve this R code with focus on:
1. Code quality:
- Apply tidyverse style guide conventions
- Improve variable naming for clarity
- Add roxygen2 documentation
2. Performance:
- Identify bottlenecks
- Suggest vectorization opportunities
- Recommend data.table if processing large datasets
3. Robustness:
- Add input validation with checkmate
- Handle edge cases (NA, NULL, empty vectors)
- Improve error messages
4. Testing:
- Suggest test cases for testthat
- Cover normal usage and edge cases
Please show the improved code with inline comments explaining changes.
[Paste the code you want to improve after this prompt]
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š IMPROVEMENTS MADE
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
⢠Added specific improvement areas - Guides the review
⢠Specified R language and tools - Detected from DESCRIPTION
⢠Structured as checklist - Easy to verify all aspects
⢠Included style guide reference - Matches R best practices
⢠Added testing framework - testthat is standard for R packages
⢠Made it actionable - Clear what to provide next
Context used:
⢠Detected R package (has DESCRIPTION file)
⢠Found testthat in Suggests field
⢠Package uses tidyverse (detected from DESCRIPTION Imports)
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
šÆ NEXT STEPS
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
1. Execute now ā (Recommended)
2. Revise - Tell me what to change
š” Advanced: Type 'copy' to save to clipboard
> 2
What would you like to change about the optimization?
> Focus more on performance, less on documentation
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
⨠REVISED OPTIMIZED PROMPT
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Review and improve this R code focusing on performance:
1. Performance optimization:
- Profile the code to identify bottlenecks
- Suggest vectorization opportunities
- Consider data.table for large dataset operations
- Recommend parallel processing with future/furrr if applicable
- Suggest memoization for repeated calculations
2. Code quality (minimal):
- Basic tidyverse style compliance
- Clear variable names
3. Robustness:
- Essential input validation only
- Handle edge cases that affect performance
Please show the optimized code with benchmark comparisons.
[Paste the code you want to improve after this prompt]
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š CHANGES FROM FIRST VERSION
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
⢠Emphasized performance as primary focus
⢠Reduced documentation requirements
⢠Added benchmarking request
⢠Suggested parallel processing
⢠Kept minimal quality checks
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
šÆ NEXT STEPS
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
1. Execute now ā (Recommended)
2. Revise - Tell me what to change
š” Advanced: Type 'copy' to save to clipboard
>
When user requests it, show why each change improves prompting:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
š LEARNING MODE: Why These Changes Matter
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Change: Made directive instead of question
Why: "Write X" is clearer than "Can you write X?"
Principle: Direct instructions produce better results
Change: Added specific edge cases
Why: Makes Claude consider failure modes upfront
Principle: Explicit constraints prevent assumptions
Change: Specified return type
Why: Defines clear interface contract
Principle: Specificity reduces ambiguity
[... more explanations]
š” Tip: These patterns apply to all prompts, not just code.
PROMPT REFINEMENT WORKFLOW:
Draft vague prompt
ā
/refine "..."
ā
See optimized version
ā
Choose:
1. Execute (80% of time)
2. Revise (15% of time)
copy. Save for later (5% of time)
/refine --template bug-report "..."
/refine --template feature-request "..."
/refine --template code-review "..."
/refine --explain "..."
[Shows prompt engineering principles for each change]
[Checks ~/.claude/ for custom skills]
[Tailors optimization to match available expertise]
Clipboard copy command:
# macOS
echo "$optimized_prompt" | pbcopy
# Linux
echo "$optimized_prompt" | xclip -selection clipboard
# Fallback
echo "Clipboard not available. Here's the prompt to copy manually:"
echo "$optimized_prompt"
Context detection:
Optimization principles:
User: /refine
Claude:
š” PROMPT OPTIMIZER
Paste or type the prompt you want to optimize:
>
User: help me with tests
Claude:
[Shows analysis of "help me with tests"]
[Optimizes to specific testing request based on project context]
[Shows improvements made]
šÆ NEXT STEPS:
1. Execute now ā (Recommended)
2. Revise - Tell me what to change
š” Advanced: Type 'copy' to save to clipboard
>
User: 1
Claude:
ā
Executing optimized prompt now...
[Proceeds with optimized testing help]