Metadata-Version: 2.5
Name: preprompt
Version: 0.2.0
Summary: PrePrompt for Claude Code and Cursor: rewrites vague prompts through your PrePrompt account
Project-URL: Homepage, https://preprompt.org
License: Proprietary
License-File: LICENSE
Keywords: ai,claude,cursor,llm,mcp,prompt-engineering
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: fastapi==0.141.1
Requires-Dist: mcp==1.28.1
Requires-Dist: posthog==7.39.1
Requires-Dist: pydantic-settings==2.15.0
Requires-Dist: pydantic==2.13.4
Requires-Dist: python-dotenv==1.2.2
Requires-Dist: uvicorn==0.52.3
Provides-Extra: dev
Requires-Dist: anthropic==0.122.0; extra == 'dev'
Requires-Dist: pytest-asyncio==1.4.0; extra == 'dev'
Requires-Dist: pytest-mock==3.15.1; extra == 'dev'
Requires-Dist: pytest==9.1.1; extra == 'dev'
Requires-Dist: redis==8.1.0; extra == 'dev'
Requires-Dist: sentry-sdk[fastapi]==2.68.0; extra == 'dev'
Requires-Dist: slowapi==0.1.10; extra == 'dev'
Requires-Dist: stripe==15.5.1; extra == 'dev'
Provides-Extra: dist
Requires-Dist: build; extra == 'dist'
Requires-Dist: twine; extra == 'dist'
Description-Content-Type: text/markdown

# PrePrompt

[![PyPI](https://img.shields.io/pypi/v/preprompt)](https://pypi.org/project/preprompt/)

> Underspecified prompts get mediocre answers. PrePrompt rewrites the vague
> ones — adding the missing context, constraints, and output format — before
> the model ever sees them.

## Get PrePrompt

**Most people want the Chrome extension.** It rewrites your prompts right where
you already work — ChatGPT, Claude, Gemini, and Perplexity — with nothing to
install locally.

👉 **[Add PrePrompt to Chrome → preprompt.org](https://preprompt.org)** — free, 30 rewrites/month.

**This package (`pip install preprompt`) brings the same service to your IDE and
terminal**: a hook and MCP server for Claude Code, Cursor, Windsurf, and Zed,
plus a small CLI. It uses the same PrePrompt account and the same monthly
credits as the extension.

## What it does

Most prompts sent to an LLM are underspecified — they're missing context,
output format expectations, or technical constraints that the developer has in
their head but didn't type. PrePrompt scores every prompt and rewrites the
complex ones. Simple prompts ("what is jwt") pass through untouched.

```
BEFORE  write a function that handles youtube oauth token refresh
        and manages expired credentials with error handling

AFTER   Write a Python function for FastAPI that handles YouTube OAuth 2.0
        token refresh. The function should: (1) detect expired credentials
        by checking the expiry timestamp, (2) use the refresh token to
        obtain a new access token via the YouTube API, (3) update and
        persist the new credentials (consider using a database or file
        storage), and (4) include comprehensive error handling for invalid
        refresh tokens, network failures, and API errors with appropriate
        logging and exception types.
```

In Claude Code, a rewritten prompt shows up as an annotation box:

```
╔═ PrePrompt +58 ════════════════════════════════════════════╗
║ The rewritten prompt specifies the technical               ║
║ implementation details, clarifies the complete workflow,   ║
║ and adds concrete error scenarios and storage              ║
║ considerations relevant to FastAPI applications.           ║
╠════════════════════════════════════════════════════════════╣
║ ORIGINAL  write a function that handles youtube oauth t... ║
║ OPTIMIZED Write a Python function for FastAPI that handles ║
║           YouTube OAuth 2.0 token refresh. The function    ║
║           should: (1) detect expired credentials by        ║
║           checking the expiry timestamp...                 ║
╚════════════════════════════════════════════════════════════╝
```

## Install

```bash
pip install preprompt
preprompt-install        # registers the hook + MCP server (Claude Code, and Cursor if installed)
preprompt-login          # paste a token from preprompt.org/dashboard/tokens
# Restart Claude Code or Cursor
```

A PrePrompt account is required — the free plan works. PrePrompt never asks
for, stores, or uses an Anthropic API key.

### Upgrading from 0.1.x

0.2.0 requires a PrePrompt account and no longer uses your own Anthropic key.
Upgrade, re-run `preprompt-install` (it replaces the old hook and Cursor entry,
which held your key), then sign in:

```bash
pip install --upgrade preprompt
preprompt-install
preprompt-login
```

0.1.x also saved the key in `~/.preprompt/.env`. 0.2.0 ignores it; delete that
line.

## How it works

Classification runs **on your machine**: a pure-heuristic scorer, no network
call, under 1ms per prompt.

- **Clear prompts pass through untouched** — nothing is sent anywhere.
- **Prompts that look like they contain a secret** (API keys, tokens, private
  keys) are never sent — they pass through unchanged.
- **Prompts that need work** are sent to PrePrompt's hosted engine, rewritten,
  and returned. Each delivered rewrite uses one credit.

```
SCORE  REWRITE  PROMPT
   48  YES      write me a middleware that validates tokens and handles refresh
  -35  no       what is jwt
  -45  no       thanks
   65  YES      refactor this to handle edge cases and manage errors properly
  -20  no       add tests
   70  YES      implement a rate limiter that tracks requests, manages quotas...
```

## Credits

Rewrites draw from your PrePrompt account's monthly credits — the same pool as
the Chrome extension. The free plan includes 30 rewrites/month; paid plans add
more. See [preprompt.org/pricing](https://preprompt.org/pricing).

You are not charged when a prompt passes through, when a secret is detected,
when you're signed out or out of credits, or when a rewrite fails.

## CLI

```bash
preprompt-install          # register the hook + MCP server (Claude Code, Cursor)
preprompt-uninstall        # remove everything preprompt-install added
preprompt-login            # sign in with a PrePrompt access token
preprompt-usage            # credits used / remaining this month
preprompt-history          # recent prompt events across all sessions
preprompt-stats            # rewrite stats (total, intercepted, avg score)
preprompt-test-classifier  # see how sample prompts are scored (runs locally)
preprompt-feedback         # rate recent rewrites
preprompt-watch            # live feed of rewrites in a second terminal
preprompt-clip             # rewrite the prompt on your clipboard
preprompt-optimize "..."   # rewrite a prompt from the command line
```

## MCP tools

| Tool | Parameters | Returns |
|------|-----------|---------|
| `optimize_prompt` | `user_prompt`, `conversation_history`, `turn_number` | `{optimized_prompt, was_intercepted, score, reason}` |
| `get_prompt_history` | `limit` (default 20) | list of recent prompt events for this session |
| `get_usage` | — | your plan's credit usage |

## Requirements

- Python 3.11+
- A PrePrompt account ([preprompt.org](https://preprompt.org))
- Claude Code, Cursor, Windsurf, or Zed

Local history is kept at `~/.preprompt/history.db`. See
[what's collected and why](https://preprompt.org/privacy).

## License

Proprietary — © 2026 PrePrompt. All rights reserved. See `LICENSE`.

Working on PrePrompt itself? Start with `AGENTS.md` in the repository.
