How PrePrompt Works in Cursor
When you submit a prompt in Cursor's Agent mode with PrePrompt installed, the following happens:
- The UserPromptSubmit hook fires before the prompt reaches the LLM.
- PrePrompt's heuristic classifier scores the prompt locally in under 1ms — no API call.
- If the score is below 38, the prompt passes through untouched.
- If the score is 38 or above, Claude Haiku rewrites the prompt to be more specific and actionable.
- Cursor sends the (possibly rewritten) prompt to the LLM.
- The interaction is logged locally to
~/.preprompt/history.db.
Stack memory compounds over time: as PrePrompt sees more of your prompts, it learns your preferred language, framework, and conventions, injecting them into future rewrites automatically.
Installation
-
Install PrePrompt
pip install preprompt
-
Run the setup wizard
This saves your Anthropic API key and registers PrePrompt with the IDEs it detects on your system.
preprompt-install
Alternatively, register Cursor specifically:
python -c "from scripts.install_cursor import main; main()"
-
Verify the Cursor config was written
cat ~/.cursor/mcp.json
You should see a
prepromptentry in themcpServersobject. -
Restart Cursor
MCP servers are loaded at startup. Restart Cursor to pick up the new configuration.
-
Test the integration
In Cursor Agent mode, send a vague prompt like "write middleware that validates tokens and handles refresh". You should see a PrePrompt annotation in the terminal output, and Cursor will receive the rewritten prompt.
The MCP Configuration Entry
preprompt-install writes the following to ~/.cursor/mcp.json:
{
"mcpServers": {
"preprompt": {
"command": "python",
"args": ["-m", "mcp_server.server"],
"env": {
"ANTHROPIC_API_KEY": "your-api-key-here"
}
}
}
}
If you need to configure this manually, add the above entry to your existing ~/.cursor/mcp.json. If the file does not exist, create it with the full content above.
What Gets Optimized
PrePrompt's classifier routes each prompt through one of three paths:
- Pass — short prompts, factual questions ("what is JWT"), conversational responses ("thanks", "yes"). Zero latency, zero cost.
- Enrich — complex, vague, or multi-requirement prompts scoring 38+. Rewritten by Haiku. ~1–2 second latency, ~$0.001 cost.
- Clarify — very short vague prompts without technical context ("fix this", "improve it"). Returns a clarifying question to guide you toward a better prompt.
Frequently Asked Questions
A: No. MCP tools only activate in Cursor's Agent mode. Ask and Plan modes do not invoke MCP servers at all. For those modes, you can use the preprompt-optimize "your prompt here" CLI command to optimize manually and paste the result.
A: ~/.cursor/mcp.json. Running preprompt-install writes the correct entry automatically, detecting whether Cursor is installed on your system.
A: No. The heuristic classifier adds under 1ms to every prompt — imperceptible. Simple prompts (questions, short commands) pass through untouched at zero cost. Only complex prompts above the quality threshold trigger a Haiku rewrite, adding approximately 1–2 seconds.
Get started in two commands
Install PrePrompt and register it with Cursor (and any other compatible IDEs you have installed).
View full install guide →See Also
- PrePrompt for Windsurf — Windsurf MCP integration guide
- PrePrompt for Claude Code — automatic interception via UserPromptSubmit hook
- What is an MCP Server? — how the MCP protocol works
- How to Write Better Prompts — manual techniques that complement PrePrompt