An OpenCode plugin that automatically evaluates prompts for clarity and triggers research-based clarification when prompts are vague or ambiguous.
Based on claude-code-prompt-improver.
bun add @codymclain/opencode-prompt-improverOr add to your OpenCode config:
{
"plugins": ["@codymclain/opencode-prompt-improver"]
}The plugin intercepts user messages and evaluates them for clarity using pattern matching. When a prompt is determined to be vague (score < 60/100), it automatically injects context instructing the agent to:
- Research Phase: Explore the codebase, check conversation history, find relevant files
- Generate Clarifying Questions: Ask 1-4 targeted questions with options grounded in actual codebase findings
- Wait for User Response: Don't proceed until clarification is received
- Execute with Context: Use original intent + clarifications + research findings
Prompts are scored on:
- Target Specificity: Does it mention specific files, functions, or components?
- Action Clarity: Is the action clearly defined with specifics?
- Success Criteria: Are expected outcomes described?
- Context: Is there sufficient context to execute?
The following prefixes bypass evaluation:
*- Force immediate execution/- Slash commands#- Memory/notes!- Shell commands
Manually evaluate a prompt for clarity.
evaluate_prompt("fix the bug")
// Returns: { isVague: true, score: 15, reasons: [...], suggestions: [...] }
Generate improvement context for a vague prompt.
improve_prompt("add authentication")
// Returns detailed research and clarification instructions
User: "fix the bug"
Plugin injects context instructing agent to:
1. Search for TODOs, failing tests, recent commits
2. Ask which specific bug to fix with options from codebase
3. Wait for user selection before proceeding
User: "Refactor getUserById in src/api/users.ts to use async/await"
Plugin: Score 85/100 - Clear enough, no clarification needed
# Install dependencies
bun install
# Type check
bun tsc --noEmit
# Build
mise run build
# Test
mise run testMIT