Claude Prompt Improver Plugin
A Claude Code plugin that automatically enhances and improves your prompts before they reach Claude. The plugin analyses prompt clarity, adds relevant context, and structures complex requests using XML tags for better AI understanding.
Features
- Opt-In or Automatic Improvement: Choose between opt-in mode (add
#improve tag) or automatic improvement for all prompts
- Smart Model Selection: Configure your preferred model (haiku for speed, sonnet for balance, opus for quality)
- Context Injection: Enriches prompts with relevant context from multiple sources:
- Available tools and capabilities
- Matching skills and agents
- Git context (branch, recent commits, changes)
- LSP diagnostics (errors and warnings)
- Specification awareness (.specify/ directory)
- Memory plugin integration
- Bypass Mechanisms: Skips processing for short prompts, #skip tagged prompts, low context, or forked sessions
- XML Structuring: Applies semantic XML tags (task, context, constraints) to complex prompts
Requirements
- Bun >= 1.0.0 (required - used for hooks and package management)
- Claude Code >= 2.0.0
Quick Start
Installation
Using the Enhance marketplace:
# Add the marketplace (one-time)
/plugin marketplace add GaZmagik/enhance
# Install the plugin
/plugin install claude-prompt-improver
Plugin Structure
.claude-plugin/
plugin.json # Plugin metadata
hooks/
hooks.json # Hook definitions
user-prompt-submit/
improve-prompt.ts # Main hook entry point
src/
core/ # Core types, config, error handling
services/ # Classification and improvement services
context/ # Context detection and building
integrations/ # Git, LSP, spec, memory integrations
utils/ # Logging, token counting, XML building
Configuration
Configuration is optional - the plugin works with sensible defaults.
On installation, the plugin creates .claude/prompt-improver.example.md with documented defaults. To customise:
mv .claude/prompt-improver.example.md .claude/prompt-improver.local.md
The configuration uses markdown with YAML frontmatter:
---
enabled: true
shortPromptThreshold: 10
compactionThreshold: 5
improverModel: haiku # Model for all improvements: haiku, sonnet, or opus
integrations:
git: true
lsp: true
spec: true
memory: true
session: true
dynamicDiscovery: true
pluginResources: true
logging:
enabled: true
logFilePath: .claude/logs/prompt-improver-latest.log
maxLogSizeMB: 10
maxLogAgeDays: 7
displayImprovedPrompt: true
---
# Your documentation here...
Add .claude/prompt-improver.local.md to your .gitignore to keep local settings private.
Configuration Options
| Option | Type | Default | Description |
|---|
enabled | boolean | true | Enable/disable the plugin globally |
forceImprove | boolean | false | Bypass all heuristic checks (for testing) |
defaultImprove | boolean | false | Enable automatic improvement by default (when false, requires #improve tag) |
shortPromptThreshold | number | 10 | Prompts with fewer tokens bypass improvement |
compactionThreshold | number | 5 | Skip when context availability is below this % |
improverModel | string | haiku | Model for all improvements: haiku (fast), sonnet (balanced), or opus (highest quality) |
integrations.git | boolean | true | Enable git context gathering |
integrations.lsp | boolean | true | Enable LSP diagnostics gathering |
integrations.spec | boolean | true | Enable specification awareness |
integrations.memory | boolean | true | Enable memory plugin integration |
integrations.session | boolean | true | Enable session context |
integrations.dynamicDiscovery | boolean | true | Enable dynamic discovery of skills, agents, commands, and output styles |
integrations.pluginResources | boolean | true | Enable plugin resource scanning (skills, agents, commands, output styles from installed plugins) |
logging.enabled | boolean | true | Enable logging |
logging.logFilePath | string | .claude/logs/... | Log file location |
logging.logLevel | string | INFO | Log level: ERROR, INFO, or DEBUG |
logging.maxLogSizeMB | number | 10 | Maximum log file size in MB |
logging.maxLogAgeDays | number | 7 | Maximum log age in days |
logging.displayImprovedPrompt | boolean | true | Show improved prompt in output |
logging.useTimestampedLogs | boolean | false | Create timestamped log files |
Both camelCase and snake_case key names are supported (e.g., shortPromptThreshold or short_prompt_threshold).
Usage
Opt-In Mode (Default)