Skip to main content

Developer-native TUI for refining prompts using Claude Code

Project description

⚡ Prompt Refiner

A developer-native terminal UI that automatically refines your prompts using proven prompt engineering techniques — powered by your existing Claude Code subscription. No separate API key required.

Python License PyPI

Screenshot

Prompt Refiner in action

Demo

┌─────────────────────────────────────────────────────────────────────┐
│  ⚡ Prompt Refiner   Model: [claude-sonnet-4-6 ▾]                   │
├────────────────────────┬────────────────────────────────────────────┤
│  YOUR PROMPT           │  REFINED PROMPT                            │
│                        │                                            │
│  write a function to   │  You are an expert software engineer.      │
│  parse json            │                                            │
│                        │  <instructions>                            │
│                        │  Write a function to parse JSON input.     │
│                        │  Think step by step before answering.      │
│                        │  </instructions>                           │
│                        │                                            │
│                        │  <output_format>                           │
│                        │  Provide a complete, documented function   │
│                        │  with type hints and error handling.       │
│                        │  </output_format>                          │
├────────────────────────┴────────────────────────────────────────────┤
│  ANNOTATIONS                                                        │
│  ► Role prompting — code generation task detected                   │
│  ► Chain-of-thought — improves accuracy on multi-step logic         │
│  ► XML structuring — delineates sections clearly for Claude         │
│  ► Output format — specifies expected structure and style           │
├─────────────────────────────────────────────────────────────────────┤
│  ^R Refine  y Accept  n Reject  e Edit+Refine  Tab Model  q Quit    │
└─────────────────────────────────────────────────────────────────────┘

Features

  • Auto-detects task type — code, debug, explanation, or general
  • Applies relevant techniques — role prompting, chain-of-thought, XML structuring, output format, constraint injection
  • Annotates every change — explains why each technique was applied
  • 3-action workflow — Accept (copies to clipboard), Reject, or Refine with comments
  • Model switching — cycle between Haiku, Sonnet, and Opus with Tab
  • Zero setup — uses your existing Claude Code login

Prerequisites

  • Claude Code installed and logged in (claude login)
  • Python 3.11+

Installation

Via pipx (recommended — isolated, no venv management):

pipx install claude-prompt-refiner

Via Homebrew:

brew tap richeshgupta/claude-prompt-refiner https://github.com/richeshgupta/claude-prompt-refiner
brew install claude-prompt-refiner

Via pip:

pip install claude-prompt-refiner

Usage

cpr                    # short alias
claude-prompt-refiner  # full command

Keybindings

Key Action
Ctrl+R Refine the prompt
y Accept — copies refined prompt to clipboard
n Reject — clears output, back to input
e Refine with comments — add guidance for the next pass
Tab Cycle model (Haiku → Sonnet → Opus)
q Quit

Prompt Techniques Applied

Task Type Techniques
Code generation Role prompting, Chain-of-thought, XML structuring, Output format, Constraint injection
Debugging Role prompting, Constraint injection, Chain-of-thought, XML structuring
Explanation Role prompting, Audience injection, XML structuring, Output format
General Role prompting, XML structuring, Output format, Chain-of-thought

Project Structure

├── main.py          # Entry point
├── app.py           # Textual TUI (layout, keybindings, workers)
├── engine.py        # RefinerEngine — prompt building + JSON parsing
├── claude.py        # Subprocess wrapper for claude CLI
├── techniques.py    # Task detection + technique catalogue
├── requirements.txt
└── tests/           # 17 unit tests

Running Tests

python -m pytest tests/ -v

Models

Model Use case
claude-haiku-4-5 Fast, lightweight refinements
claude-sonnet-4-6 Default — best balance of speed and quality
claude-opus-4-6 Most thorough refinements

Contributing

See CONTRIBUTING.md.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_prompt_refiner-1.0.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_prompt_refiner-1.0.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file claude_prompt_refiner-1.0.1.tar.gz.

File metadata

  • Download URL: claude_prompt_refiner-1.0.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for claude_prompt_refiner-1.0.1.tar.gz
Algorithm Hash digest
SHA256 74f1380dad5791c05d8d8e150f9aab4947ee7ce7bfae1d5f445f6c23940e1a50
MD5 f50f61652319d028c22542eb5bcee855
BLAKE2b-256 3bb4a5389ed58c9c24be02fa9d6a78baeae2cfff9bd493cdb9f3a2843ca35ad0

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_prompt_refiner-1.0.1.tar.gz:

Publisher: publish.yml on richeshgupta/claude-prompt-refiner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file claude_prompt_refiner-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for claude_prompt_refiner-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac6db6c83450c3f8fa3cabbace5398cc0da1fef61d5b9c9c251701f5a3b8edaa
MD5 d37ff38ec457ef7a2e88f0884f9cf7cb
BLAKE2b-256 80aabfc051a5e3567ec3bd4f14b27812721b30156e0e7a279829fa0270cc8b8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_prompt_refiner-1.0.1-py3-none-any.whl:

Publisher: publish.yml on richeshgupta/claude-prompt-refiner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page