How PrePrompt Works in Windsurf
Windsurf implements the full Model Context Protocol, including the UserPromptSubmit hook. When you submit a prompt in Windsurf with PrePrompt installed:
- The hook fires before the prompt reaches any LLM.
- PrePrompt scores the prompt locally in under 1ms using its heuristic classifier — no API call.
- Prompts scoring below 38 pass through unchanged with zero latency and zero cost.
- Prompts scoring 38 or above are rewritten by Claude Haiku to be more specific and actionable.
- Windsurf sends the optimized prompt to the LLM.
- The interaction is logged locally to
~/.preprompt/history.db.
Installation
-
Install PrePrompt
pip install preprompt
-
Run the setup wizard
preprompt-install
This saves your Anthropic API key and registers PrePrompt with every compatible IDE detected on your system, including Windsurf.
To register Windsurf specifically:
python scripts/install_windsurf.py
-
Verify the Windsurf config
cat ~/.codeium/windsurf/mcp_config.json
You should see a
prepromptentry in themcpServersobject. -
Restart Windsurf
MCP servers are loaded at startup. Restart Windsurf to pick up the new configuration.
The MCP Configuration Entry
preprompt-install writes the following to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"preprompt": {
"command": "python",
"args": ["-m", "mcp_server.server"],
"env": {
"ANTHROPIC_API_KEY": "your-api-key-here"
}
}
}
}
What Gets Optimized
- Pass — factual questions, very short prompts, conversational responses. Zero cost, zero latency.
- Enrich — complex prompts with vague action verbs, missing constraints, or multi-step requirements. Rewritten by Haiku (~1–2 seconds, ~$0.001).
- Clarify — very short vague prompts without technical context. Returns a clarifying question to help you write a better prompt.
Frequently Asked Questions
A: Yes. PrePrompt works at the MCP protocol level, which sits beneath Windsurf's Cascade AI. Any prompt you submit through Cascade that passes through the UserPromptSubmit hook will be intercepted and (if needed) optimized before it reaches the model.
A: ~/.codeium/windsurf/mcp_config.json. Running preprompt-install or python scripts/install_windsurf.py writes the correct entry automatically.
A: No. PrePrompt only operates on the text of your prompt before it is sent. It does not modify files, does not interact with other MCP servers, and does not affect Windsurf's context window or repository indexing features.
Get started in two commands
Install PrePrompt and register it with Windsurf (and any other compatible IDEs you have installed).
View full install guide →See Also
- PrePrompt for Cursor — Cursor-specific MCP setup
- PrePrompt for Claude Code — automatic interception via UserPromptSubmit hook
- What is an MCP Server? — how the MCP protocol works across IDEs
- How to Write Better Prompts — manual techniques that complement PrePrompt