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:

  1. The hook fires before the prompt reaches any LLM.
  2. PrePrompt scores the prompt locally in under 1ms using its heuristic classifier — no API call.
  3. Prompts scoring below 38 pass through unchanged with zero latency and zero cost.
  4. Prompts scoring 38 or above are rewritten by Claude Haiku to be more specific and actionable.
  5. Windsurf sends the optimized prompt to the LLM.
  6. The interaction is logged locally to ~/.preprompt/history.db.

Installation

  1. Install PrePrompt
    pip install preprompt
  2. 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
  3. Verify the Windsurf config
    cat ~/.codeium/windsurf/mcp_config.json

    You should see a preprompt entry in the mcpServers object.

  4. 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

Frequently Asked Questions

Q: Does PrePrompt support Windsurf's Cascade AI?

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.

Q: Where is Windsurf's MCP configuration file?

A: ~/.codeium/windsurf/mcp_config.json. Running preprompt-install or python scripts/install_windsurf.py writes the correct entry automatically.

Q: Will PrePrompt interfere with Windsurf's built-in context tools?

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