Skip to content
digitronikPublic

About

AI-powered text rewriter for your terminal. Fix grammar, rephrase, summarize — in any app, with one command.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

prosefmt

AI-powered text rewriting — system-wide, from any app, with a single hotkey.

CI PyPI Python License: MIT

Highlight text in any application — browser, email, Slack, VS Code, terminal — press your hotkey, and prosefmt rewrites it in place. Grammar fixed, tone shifted, translated, summarized — all without leaving the app you're in. Linux reads the highlighted selection directly; macOS and Windows copy the highlight with Cmd+C / Ctrl+C, then paste the rewrite back.

$ prosefmt "i can haz good grammer?"
I can have good grammar.

$ echo "this sentense has a typo" | prosefmt
This sentence has a typo.

$ prosefmt -m professional "lets meet tmrw and discuss"
Let's meet tomorrow to discuss.

$ prosefmt menu -s -n    # highlight text → picker → rewrite → paste back

Table of Contents


Why prosefmt?

Every other AI writing tool is a GUI desktop app — Electron, PyQt5, or Tauri. They weigh 100–200 MB, can't be scripted, and most are broken on Wayland.

prosefmt is different:

prosefmt GUI writing tools
Architecture CLI — 2 Python deps, ~90 KB Electron/PyQt GUI, 100–200 MB
Install pip install prosefmt Download installer or clone repo
Composability Pipes, scripts, shell automation Click through menus
Works on Wayland Yes — native wl-clipboard + wtype Usually broken
AI providers Ollama, OpenAI, Anthropic, any OpenAI-compat Varies, often 1–2
Modes/prompts User-editable TOML — you own every prompt Hardcoded, fork to change
Offline Ollama (local, private) is the default Cloud-only or optional
Mode picker Built-in (prosefmt menu) Their own UI or none
Per-mode model Yes — route tasks to different AI models No
prosefmt is to AI text tools what ripgrep is to grep —
fast, composable, Unix-native, and built for power users.

Quick Start

Get running in 2 minutes with Ollama (free, local, no API key):

# 1. Install prosefmt
pip install prosefmt          # or: uv tool install prosefmt

# 2. Install & start Ollama (https://ollama.com)
curl -fsSL https://ollama.com/install.sh | sh
ollama pull qwen2.5:1.5b
ollama serve                  # keep running in background

# 3. Create config + check everything works
prosefmt config init
prosefmt check

# 4. Try it!
prosefmt "me and him went to store yesterday"

That's it. For system-wide hotkeys, jump to System-Wide Hotkeys.


How It Works

┌──────────────────────────────────────────────────────────────┐
│                        INPUT                                 │
│                                                              │
│  Highlight text + hotkey (--system)                          │
│  Clipboard content (--clipboard)                             │
│  CLI argument: prosefmt "text"                               │
│  Pipe: echo "text" | prosefmt                                │
└─────────────────────────┬────────────────────────────────────┘
                          │
                          ▼
┌──────────────────────────────────────────────────────────────┐
│                    PICKER (optional)                         │
│                                                              │
│  prosefmt menu  →  rofi / wofi / fuzzel / dmenu / fzf        │
│  Choose a mode or type a free-form custom instruction        │
└─────────────────────────┬────────────────────────────────────┘
                          │ mode name (or custom prompt)
                          ▼
┌──────────────────────────────────────────────────────────────┐
│                    PROCESSING                                │
│                                                              │
│  config.toml        →  system_prompt + mode.prompt           │
│  AI provider        →  Ollama / OpenAI / Anthropic / compat  │
│  List preservation  →  bullets & numbered lists kept intact  │
└─────────────────────────┬────────────────────────────────────┘
                          │
                          ▼
┌──────────────────────────────────────────────────────────────┐
│                      OUTPUT                                  │
│                                                              │
│  "replace"    →  paste rewritten text back in-place          │
│  "popup"      →  show in a desktop popup (original untouched)│
│  "clipboard"  →  write to clipboard                          │
│  "stdout"     →  print to terminal                           │
│  "--diff"     →  show what changed (red/green diff)          │
└──────────────────────────────────────────────────────────────┘

Module Overview

src/prosefmt/
├── cli.py              CLI entry point (Click) — subcommands, flags, routing
├── config.py           TOML config loading — modes, providers, system prompt
├── core.py             Rewrite engine — prompt assembly, list preservation
├── modes.py            List-structure preservation helpers
├── clipboard.py        Cross-platform clipboard (X11, Wayland, macOS, Windows)
├── picker.py           Mode picker UI (rofi, wofi, fuzzel, dmenu, zenity, fzf)
├── popup.py            Result display popup (zenity, yad, kdialog, rofi)
├── diff.py             Text diff formatting (unified diff, ANSI colour)
├── notify.py           Desktop notifications (notify-send, osascript, toast)
└── providers/
    ├── base.py         Provider protocol
    ├── ollama.py       Ollama (local, default)
    ├── openai_compat.py OpenAI / Groq / Together / LM Studio / vLLM
    └── anthropic.py    Anthropic Claude

Design principles:

  • Config owns all prompts — every mode prompt and system instruction lives in default_config.toml (shipped with the package) and is loaded at runtime. Python code never hardcodes prompt text. Users can override any prompt via their config.toml.
  • Platform tools, not Python deps — clipboard, picker, popup, notifications are all subprocess calls to native OS tools. No PyQt, no Tkinter, no heavy GUI libraries.
  • Two runtime dependencies — click (CLI framework) and httpx (HTTP client). That's it.

Installation

Recommended: uv (isolated tool install)

uv tool install prosefmt

New to uv? Install with: curl -LsSf https://astral.sh/uv/install.sh | sh

With pip

pip install prosefmt

From source

git clone https://github.com/digitronik/prosefmt.git
cd prosefmt
uv sync --extra dev

Setup Guide

One-time setup — takes about 5 minutes.

1. Clipboard tools

prosefmt uses native OS clipboard tools. macOS and Windows users can skip this step.

Linux (X11) — GNOME, KDE, i3, XFCE, etc.
# Debian / Ubuntu / Mint / Pop!_OS
sudo apt install xclip xdotool

# Fedora / RHEL / CentOS / Rocky
sudo dnf install xclip xdotool

# Arch / Manjaro / EndeavourOS
sudo pacman -S xclip xdotool

# openSUSE
sudo zypper install xclip xdotool
Linux (Wayland) — GNOME on Wayland, Sway, Hyprland, etc.
# Debian / Ubuntu / Mint
sudo apt install wl-clipboard wtype

# Fedora / RHEL / CentOS
sudo dnf install wl-clipboard wtype

# Arch / Manjaro
sudo pacman -S wl-clipboard wtype

# openSUSE
sudo zypper install wl-clipboard wtype

Not sure? Run echo $XDG_SESSION_TYPE — it prints x11 or wayland.

2. AI provider

Pick one. You can always switch or add more later.

Option A — Ollama (local, free, private — recommended)

No API key needed. Runs entirely on your machine.

# Install Ollama → https://ollama.com/download
curl -fsSL https://ollama.com/install.sh | sh

# Pull a model (qwen2.5:1.5b is fast, works on CPU)
ollama pull qwen2.5:1.5b

# Start the server (keep running)
ollama serve

Other good models: llama3.2:3b, mistral:7b, phi3:mini

Option B — OpenAI
export OPENAI_API_KEY="sk-..."
# Add to ~/.bashrc or ~/.zshrc so it persists
Option C — Anthropic (Claude)
export ANTHROPIC_API_KEY="sk-ant-..."
# Add to ~/.bashrc or ~/.zshrc so it persists
Option D — Any OpenAI-compatible endpoint

Works with Groq, Together AI, LM Studio, vLLM, and anything that speaks /v1/chat/completions.

Configure the URL and model in your config file (next step).

3. Config file

prosefmt config init

This creates ~/.config/prosefmt/config.toml with all modes, providers, and prompts ready to edit. It also checks your clipboard tools and tells you what's missing.

Open and edit:

nano ~/.config/prosefmt/config.toml    # or: vim, code, etc.

The minimum config for Ollama (the defaults already cover this):

default_provider = "ollama"

[providers.ollama]
url   = "http://localhost:11434"
model = "qwen2.5:1.5b"

For OpenAI:

default_provider = "openai"

[providers.openai]
model = "gpt-4o-mini"    # API key from OPENAI_API_KEY env var

4. Picker tool (optional)

The prosefmt menu command opens an interactive mode picker. Install any one of these:

sudo dnf install rofi       # Fedora  (works on X11 + Wayland)
sudo apt install rofi       # Ubuntu/Debian
sudo pacman -S rofi         # Arch

# Or any of: wofi, fuzzel, dmenu, zenity, fzf
# prosefmt auto-detects the best one available

Skip this if you only use prosefmt -s -n (direct rewriting without a picker).

5. Verify

prosefmt check
✓ Clipboard tools installed
✓ Picker: rofi  (for 'prosefmt menu')
✓ Popup: zenity  (for --popup / default_output = "popup")
✓ Provider 'ollama' is reachable  (model: qwen2.5:1.5b)

If anything is missing, prosefmt check prints the exact command to fix it.


Usage

Basic usage

# Pass text as an argument (default mode: fix grammar)
prosefmt "me and him went to the store yesterday"

# Use a specific mode
prosefmt -m professional "lets meet tmrw and discuss"

# Pipe from stdin
echo "this sentense has a typo" | prosefmt

# Read from clipboard, print the result
prosefmt --clipboard

# Override provider/model for one run
prosefmt -p openai --model gpt-4o "some text here"

System-wide rewriting

Highlight text, press your hotkey, and the rewritten text replaces the original — without switching windows or touching the mouse. On Linux this reads the primary selection. On macOS and Windows, prosefmt sends Cmd+C / Ctrl+C itself (there is no primary selection), rewrites that text, then pastes it back over the highlight.

# Read highlighted text → rewrite → paste back in-place
prosefmt --system --notify

# With a specific mode
prosefmt -m professional -s -n

# Short form for hotkey bindings
prosefmt -s -n

How --system works:

  1. Reads the highlighted text (primary selection on Linux; Cmd+C / Ctrl+C on macOS and Windows)
  2. Sends it to the AI with the selected mode's prompt
  3. Saves the original for undo
  4. Writes the result to clipboard
  5. Simulates Ctrl+V / Cmd+V to paste it back
  6. Restores your previous clipboard content

Clipboard safety: Your Ctrl+C buffer is automatically saved before pasting and restored afterwards. prosefmt never destroys your clipboard.

Mode picker

prosefmt menu opens an interactive mode picker — no shell scripting required.

# Highlight text → pick a mode → rewrite → paste back
prosefmt menu -s -n

# Read from clipboard → pick a mode → rewrite
prosefmt menu -c

The picker auto-detects the best installed tool: rofi → wofi → fuzzel → dmenu → zenity → fzf → osascript.

Free-form prompts

Type anything into the picker that isn't a mode name, and prosefmt treats it as a one-shot custom instruction:

┌────────────────────────────────┐
│  ✎ prosefmt                    │
│  fix                           │
│  professional                  │
│  casual                        │
│  rephrase                      │
│  > translate to French    ←────│── typed freely, runs as ad-hoc prompt
│  > make this sound excited ←───│── also works
└────────────────────────────────┘

No config changes needed for one-off instructions.

Diff output

See exactly what changed — a unique feature no competitor offers:

# Show a diff of original vs. result
prosefmt --diff "Their were a few things we didnt finish"
--- original
+++ rewritten
-Their were a few things we didnt finish
+There were a few things we didn't finish.
# Diff in a popup window
prosefmt --diff --popup -s

# Diff works with any mode
prosefmt --diff -m professional "text here"

Popup output

Show the result in a desktop popup window instead of replacing the original text. Perfect for translations and summaries where you want to read the result, not paste it.

# Show rewrite in a popup
prosefmt --popup -s -m summarize

# Popup auto-detects: zenity → yad → kdialog → rofi → osascript → notify-send

Popup tools can be checked with prosefmt check.

Undo

Every rewrite saves the original text. One-step undo:

# Print the original text
prosefmt undo

# Paste it back to the active window
prosefmt undo -s

# Write to clipboard
prosefmt undo -c

Built-in Modes

prosefmt ships with 8 modes. All prompts are user-editable in config.toml.

Mode What it does Example
fix Fix grammar, spelling, punctuation "me and him went" → "He and I went"
professional Polished workplace tone "lets meet tmrw" → "Let's meet tomorrow."
casual Friendly, conversational "Please advise on the matter" → "What do you think?"
rephrase Improve clarity, keep meaning Better flow, different words
concise Same meaning, fewer words Removes filler and redundancy
expand Add detail and explanation Fills in context and nuance
summarize Key points only Condenses to 2–3 sentences
email Professional email format Adds greeting and sign-off
# List all modes (built-in + custom)
prosefmt list

# Mode names only (useful for scripts)
prosefmt list --names

Custom Modes

Add any number of custom modes in config.toml. All prompts are yours to edit — nothing is hardcoded.

# ~/.config/prosefmt/config.toml

[modes.translate-spanish]
prompt = "Translate to Spanish. Keep technical terms in English."
label  = "🇪🇸 Spanish"

[modes.slack]
prompt = "Rewrite for Slack: brief, friendly, one or two sentences max."
label  = "Slack-ready"

[modes.eli5]
prompt = "Explain this like I'm five — simple words, short sentences, no jargon."
label  = "Simplified"

[modes.code-comments]
prompt             = "Add clear, concise comments to this code. Do not change any code."
label              = "Comments added"
preserve_structure = false

Use them exactly like built-in modes:

prosefmt -m translate-spanish "Good morning, how are you?"
prosefmt -m slack "Please review the pull request I opened for the auth refactor."

Custom modes appear automatically in prosefmt menu — no config changes to your hotkey bindings needed.

Changing the default mode

Set default_mode so pressing your hotkey (without a picker) uses a different mode:

default_mode = "professional"

Now prosefmt -s -n rewrites in professional tone instead of fixing grammar.

Real-world example: translation workflow

You receive a message in Czech. You want to read it in English, write your reply, then send it back as Czech — all without switching apps.

Config:

[modes.translate-english]
prompt         = "Translate to English. Keep technical terms as-is."
label          = "→ English"
default_output = "popup"      # show translation in popup — don't replace original

[modes.translate-czech]
prompt         = "Translate to Czech. Keep technical terms in English."
label          = "→ Czech"
default_output = "replace"    # replace English with Czech in-place

Workflow:

1. Highlight Czech message → Mod+Shift+G → pick "translate-english"
   → popup shows English translation (Czech text untouched)

2. Read the popup, type your English reply

3. Highlight English reply → Mod+Shift+G → pick "translate-czech"
   → English replaced with Czech → hit send

The same pattern works for any language pair — Hindi, French, Spanish, Japanese.

Per-mode provider and model

Route different tasks to different AI models — fast local model for grammar, powerful cloud model for complex rewrites:

[modes.fix]
prompt   = "Fix grammar, spelling, and punctuation only. Preserve the original sentence structure, meaning, and tone."
provider = "ollama"
model    = "qwen2.5:1.5b"   # fast, local, CPU-friendly

[modes.review]
prompt   = "Review this text for clarity, tone, and impact."
provider = "openai"
model    = "gpt-4o"          # complex task → cloud model

CLI flags --provider and --model always override the mode config for that run.

Controlling output per mode

The default_output field decides what happens when a mode is used via --system:

Value Behaviour
"replace" Paste result back in-place (default)
"popup" Show in a popup window — original text untouched
"clipboard" Write to clipboard only, don't paste
[modes.summarize]
prompt         = "Summarize concisely. Key points only."
default_output = "popup"      # show summary, don't replace original

[modes.translate-czech]
prompt         = "Translate to Czech."
default_output = "replace"    # paste translation, replacing original

System-Wide Hotkeys

Two hotkey bindings give you the full prosefmt experience:

Hotkey Action Command
Mod+G Instant grammar fix (default mode) prosefmt -s -n
Mod+Shift+G Open mode picker → choose any mode prosefmt menu -s -n

Linux — i3wm / Sway

Add to ~/.config/i3/config (or ~/.config/sway/config):

bindsym $mod+g       exec --no-startup-id prosefmt -s -n
bindsym $mod+Shift+g exec --no-startup-id prosefmt menu -s -n

Reload with Mod+Shift+C.

Linux — Hyprland

Add to ~/.config/hypr/hyprland.conf:

bind = $mainMod,       G, exec, prosefmt -s -n
bind = $mainMod SHIFT, G, exec, prosefmt menu -s -n

Linux — GNOME / KDE

Add custom shortcuts in Settings → Keyboard → Custom Shortcuts:

Name Command Shortcut
prosefmt fix prosefmt -s -n Super+G
prosefmt menu prosefmt menu -s -n Super+Shift+G

macOS

Hammerspoon (recommended)

Install Hammerspoon, then add to ~/.hammerspoon/init.lua:

-- Cmd+G → grammar fix
hs.hotkey.bind({"cmd"}, "g", function()
  hs.task.new("/usr/local/bin/prosefmt", nil, {"--system", "--notify"}):start()
end)

-- Cmd+Shift+G → mode picker (uses Hammerspoon's native chooser)
hs.hotkey.bind({"cmd", "shift"}, "g", function()
  hs.task.new("/usr/local/bin/prosefmt", function(_, stdout)
    local choices = {}
    for line in stdout:gmatch("[^\n]+") do
      table.insert(choices, { text = line })
    end
    local chooser = hs.chooser.new(function(choice)
      if choice then
        hs.task.new("/usr/local/bin/prosefmt", nil,
          {"-m", choice.text, "--system", "--notify"}):start()
      end
    end)
    chooser:choices(choices)
    chooser:show()
  end, {"list", "--names"}):start()
end)

Reload from the Hammerspoon menu bar icon.

Automator / Shortcuts (simpler, fix-only)

Create a Quick Action in Automator that runs:

/usr/local/bin/prosefmt --system --notify

Assign a shortcut in System Settings → Keyboard → Keyboard Shortcuts → Services.

Windows

AutoHotkey v2

Create prosefmt-menu.ps1:

$modes = (& prosefmt list --names) -split "`n" | Where-Object { $_ }
$mode  = $modes | Out-GridView -Title "prosefmt — choose a mode" -PassThru
if ($mode) { & prosefmt -m $mode --system --notify }

AutoHotkey script:

#g::  Run "prosefmt --system --notify",, "Hide"
#+g:: Run 'powershell -WindowStyle Hidden -File "%USERPROFILE%\prosefmt-menu.ps1"',, "Hide"

Architecture

┌──────────────────────────────────────────────────────────────┐
│                       config.toml                            │
│  Single source of truth for all prompts, modes, providers    │
│  Python code NEVER references specific mode names            │
└─────────────────────────────┬────────────────────────────────┘
                              │
          ┌───────────────────▼────────────────────┐
          │            prosefmt CLI                 │
          │     Prompt-agnostic orchestrator        │
          │  (Click commands, input/output routing) │
          └───────────────────┬────────────────────┘
                              │
     ┌────────────────────────┼─────────────────────────┐
     │                        │                         │
     ▼                        ▼                         ▼
┌─────────┐          ┌──────────────┐          ┌──────────────┐
│Providers│          │  Core Engine │          │   Platform   │
│         │          │              │          │   Backends   │
│ Ollama  │          │ Prompt       │          │              │
│ OpenAI  │◄────────►│ assembly     │────────► │ Clipboard    │
│Anthropic│          │ List         │          │ Picker       │
│ Compat  │          │ preservation │          │ Popup        │
│         │          │ Undo         │          │ Notify       │
└─────────┘          └──────────────┘          │ Diff         │
                                               └──────────────┘
                                               All via subprocess
                                               to native OS tools
                                               Zero GUI dependencies

Key Design Decisions

  1. Config-driven — The Python code never contains the string "fix", "professional", or any mode name. All modes and prompts live in config.toml. Users can edit, reorder, add, or delete any mode without touching code.

  2. List-structure preservation — When rewriting bulleted or numbered lists, prosefmt strips the prefixes before sending to the AI (so the model doesn't lose or mangle them), then re-attaches them to the result.

  3. Clipboard save/restore — The --system flag wraps the paste operation in a context manager that saves your Ctrl+C clipboard, pastes the result, then restores the original clipboard content.

  4. Tool auto-detection — The picker, popup, and notification systems each maintain a priority list of native tools. prosefmt picks the best available one at runtime:

    • Picker: rofi → wofi → fuzzel → dmenu → zenity → fzf → osascript
    • Popup: zenity → yad → kdialog → rofi → osascript → notify-send
    • Notifications: notify-send (Linux), osascript (macOS), PowerShell toast (Windows)

Configuration Reference

Config file locations:

OS Path
Linux / macOS ~/.config/prosefmt/config.toml
Linux (custom) $XDG_CONFIG_HOME/prosefmt/config.toml
Windows %LOCALAPPDATA%\prosefmt\config.toml

Create it: prosefmt config init · View it: prosefmt config show

Top-level settings

Key Type Default Description
default_mode string "fix" Mode used when -m is not specified
default_provider string "ollama" Provider used when a mode has no provider override
temperature float 0.1 Sampling temperature — lower = more consistent output
seed int 42 Random seed for reproducible results; comment out to disable
system_prompt string built-in System instruction prepended to every mode's prompt

Provider fields ([providers.<name>])

Field Type Description
type string Provider type: "ollama", "openai-compat", "anthropic" — inferred from name if empty
url string API endpoint URL
model string Default model name
api_key_env string Custom env var name for the API key (e.g. "GROQ_API_KEY")
temperature float Override global temperature for this provider
seed int Override global seed for this provider

API keys are set via environment variables — never put them in config.toml.

Provider Environment variable
OpenAI PROSEFMT_OPENAI_API_KEY or OPENAI_API_KEY
Anthropic PROSEFMT_ANTHROPIC_API_KEY or ANTHROPIC_API_KEY
OpenAI-compat PROSEFMT_COMPAT_API_KEY

Mode fields ([modes.<name>])

Field Type Default Description
prompt string required Instruction sent to the AI
label string mode name Display name in notifications and picker
preserve_structure bool true Re-attach bullet/number list prefixes after rewrite
temperature float global default Override sampling temperature for this mode
provider string global default Override provider for this mode
model string provider default Override model for this mode
default_output string "replace" Output routing: "replace", "popup", or "clipboard"

Platform section ([platform])

Auto-detected on first run. Override if detection is wrong.

Field Type Description
os string "linux", "macos", or "windows"
display string "x11", "wayland", or "" (non-Linux)
distro string Linux distro name (e.g. "fedora", "ubuntu") or ""
pkg_manager string Package manager (e.g. "dnf", "apt", "pacman") or ""

Full example config

# ~/.config/prosefmt/config.toml

default_mode     = "fix"
default_provider = "ollama"
temperature      = 0.1
seed             = 42

system_prompt = """You are a text rewriter. Output ONLY the rewritten text.
No preamble, no explanation, no 'Here is'.
Keep technical terms, code, URLs, and formatting unchanged."""

# ── Providers ──────────────────────────────────────────────────

[providers.ollama]
url   = "http://localhost:11434"
model = "qwen2.5:1.5b"

[providers.openai]
model = "gpt-4o-mini"
# API key: OPENAI_API_KEY env var

[providers.anthropic]
model = "claude-haiku-4-5-20251001"
# API key: ANTHROPIC_API_KEY env var

# [providers.openai-compat]
# url   = "https://api.groq.com/openai/v1"
# model = "llama-3.3-70b-versatile"

# ── Modes ──────────────────────────────────────────────────────

[modes.fix]
prompt = "Fix grammar, spelling, and punctuation only. Do not add, remove, or rearrange words beyond what is needed. Preserve the original sentence structure, meaning, and tone. Keep the same number of sentences."
label  = "Grammar fixed"

[modes.professional]
prompt = "Rewrite this text in a professional, formal tone suitable for work emails and business communication. Keep the original meaning."
label  = "Made professional"

[modes.casual]
prompt = "Rewrite this text in a casual, friendly tone. Keep it natural and conversational. Preserve the original meaning."
label  = "Made casual"

[modes.rephrase]
prompt      = "Rephrase this text for better clarity and readability. Use different words while keeping the same meaning."
label       = "Rephrased"
temperature = 0.4

[modes.concise]
prompt = "Make this text shorter by removing unnecessary words. Keep the same meaning."
label  = "Made concise"

[modes.expand]
prompt      = "Expand this text with more detail and explanation. Keep the same meaning and tone."
label       = "Expanded"
temperature = 0.4

[modes.email]
prompt             = "Rewrite this as a professional email with an appropriate greeting and sign-off. Keep the core message intact."
label              = "Formatted as email"
preserve_structure = false

[modes.summarize]
prompt             = "Summarize this text in 2-3 sentences. Include only the key points."
label              = "Summarized"
preserve_structure = false
temperature        = 0.4
default_output     = "popup"

# ── Custom examples (uncomment to enable) ──────────────────────

# [modes.translate-english]
# prompt         = "Translate to English. Output only the translation."
# label          = "→ English"
# default_output = "popup"
# model          = "qwen2.5:7b"

# [modes.explain]
# prompt         = "Explain this in simple terms. Be brief."
# label          = "Explained"
# default_output = "popup"

CLI Reference

prosefmt [TEXT]                    Rewrite TEXT (default mode: fix)
prosefmt -m MODE [TEXT]            Rewrite with a specific mode
prosefmt -s / --system             Read highlighted text, paste result back
prosefmt -c / --clipboard          Read from clipboard
prosefmt -n / --notify             Show desktop notification when done
prosefmt --popup                   Show result in popup window
prosefmt --diff                    Show diff of original vs. result
prosefmt -p / --provider PROVIDER  Override AI provider
prosefmt --model MODEL             Override AI model
prosefmt --config-path PATH        Use a custom config file

prosefmt menu                     Open mode picker, then rewrite
prosefmt menu -s -n               Highlight → picker → rewrite → paste back
prosefmt menu -c                  Clipboard → picker → rewrite

prosefmt list                     List all modes (human-readable)
prosefmt list --names             Mode names only (one per line)
prosefmt undo                     Print the original text from last rewrite
prosefmt undo -s                  Paste original back to active window
prosefmt undo -c                  Write original text to clipboard
prosefmt check                    Verify clipboard, picker, popup, provider
prosefmt config init              Create config file
prosefmt config show              Show active configuration

prosefmt --version                Show version
prosefmt --help                   Show help

Flag combinations cheatsheet

Goal Command
Fix grammar of highlighted text prosefmt -s -n
Choose mode, rewrite highlighted text prosefmt menu -s -n
Fix grammar from clipboard prosefmt -c
Rewrite in professional tone prosefmt -m professional "text"
See what changed prosefmt --diff "text with erors"
Translate and show popup prosefmt --popup -m translate-english -s
Use OpenAI for this one run prosefmt -p openai --model gpt-4o "text"
Pipe through prosefmt cat draft.txt | prosefmt -m concise

FAQ

What happens to my clipboard when using --system?

prosefmt saves your current clipboard (Ctrl+C buffer) before pasting, then restores it afterwards. Your clipboard is never destroyed.

Can I use multiple AI providers at the same time?

Yes. Configure all your providers in config.toml, then assign different modes to different providers using the provider and model fields on each mode. For example, use Ollama for quick grammar fixes and OpenAI for complex rewrites.

Does it work offline?

Yes, with Ollama. Once you've pulled a model (ollama pull qwen2.5:1.5b), everything runs locally on your machine with no internet connection needed.

How do I use it with LM Studio / vLLM / Groq / Together AI?

Any service that speaks the OpenAI /v1/chat/completions format works out of the box:

[providers.openai-compat]
url   = "http://localhost:1234/v1"    # LM Studio default
model = "your-model-name"

Set PROSEFMT_COMPAT_API_KEY if the service requires authentication.

I get garbage output for translations to Hindi / Chinese / Arabic

Small language models (1.5B–3B parameters) struggle with non-Latin scripts. Use a larger model for translation modes:

[modes.translate-hindi]
prompt = "Translate to Hindi. Keep technical terms in English."
model  = "qwen2.5:7b"    # needs a larger model

Or route translation to a cloud provider: provider = "openai".

Can I write prompts optimized for my specific model?

Yes — that's the whole point. Every prompt in config.toml is yours to edit. Small local models work best with short, direct, single-instruction prompts. Cloud models can handle more nuanced instructions. The config file includes tips for prompt writing.

How is prosefmt different from Writing Tools / AI Shortcuts?

Those are GUI desktop apps (100–200 MB, Electron or PyQt5). They can't be piped, scripted, or used from hotkeys without their own UI. Most are broken on Wayland. prosefmt is a ~90 KB CLI tool with 2 Python dependencies that composes with Unix pipes and works everywhere.


Development

git clone https://github.com/digitronik/prosefmt.git
cd prosefmt
uv sync --extra dev

# Git hooks (ruff lint + format)
uv run pre-commit install
uv run pre-commit run --all-files

# Run tests
uv run pytest -v

# Lint
uv run ruff check src/ tests/
uv run ruff format --check src/ tests/

CI runs lint + tests on Python 3.11–3.14 across Linux, macOS, and Windows on every push and pull request.

Contributions welcome — open an issue or pull request on GitHub.


License

MIT

About

AI-powered text rewriter for your terminal. Fix grammar, rephrase, summarize — in any app, with one command.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages