Skip to main content

AI code editor for terminals

Project description

cli-edit

A terminal-based code editor that uses AI to apply natural language edits to your files. Describe what you want changed, preview the diff, and accept or reject.

Install

pip install cli-edit

Or install from source:

git clone https://github.com/amgustav/cli-edit.git
cd cli-edit
pip install -e .

Setup

Set your API key:

export ANTHROPIC_API_KEY="your-key-here"
# or
export OPENAI_API_KEY="your-key-here"

Usage

# Open a file for editing
cli-edit main.py

# Start with a specific prompt
cli-edit main.py --prompt "add error handling to the fetch function"

# Use a specific model
cli-edit main.py --model claude-sonnet

# Non-interactive mode (auto-accept)
cli-edit main.py --prompt "fix the bug" --yes

# Disable backup
cli-edit main.py --no-backup

# More context lines in diff
cli-edit main.py --context-lines 5

How It Works

  1. Run cli-edit <file> - the file is displayed with syntax highlighting
  2. Type a description of the changes you want
  3. The AI generates edits and a diff is displayed
  4. Choose an action:
    • a - Accept the changes
    • r - Reject and try a different prompt
    • e - Edit your prompt and retry
    • u - Undo the last accepted change
    • q - Quit

Configuration

Create ~/.config/cli-edit/config.toml:

model = "claude-sonnet"
theme = "monokai"
context_lines = 3
backup_enabled = true
streaming = true

Or add .cli-edit.toml to your project root for per-project settings.

Supported Models

Shorthand Model Provider
claude-sonnet Claude Sonnet (default) Anthropic
claude-haiku Claude Haiku Anthropic
claude-opus Claude Opus Anthropic
gpt-4o GPT-4o OpenAI
gpt-4o-mini GPT-4o Mini OpenAI

Options

Usage: cli-edit [OPTIONS] FILE

Options:
  -m, --model TEXT          AI model to use
  -p, --prompt TEXT         Edit prompt (skips interactive prompt)
  -y, --yes                 Auto-accept changes
  --no-backup               Skip creating a backup file
  -c, --context-lines INT   Context lines in diff
  -t, --theme TEXT          Syntax highlighting theme
  --no-stream               Disable response streaming
  -v, --verbose             Enable debug logging
  --version                 Show version
  --help                    Show this message and exit

Development

pip install -e ".[dev]"
pytest
mypy src
ruff check src tests

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

cli_edit-0.1.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

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

cli_edit-0.1.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file cli_edit-0.1.0.tar.gz.

File metadata

  • Download URL: cli_edit-0.1.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for cli_edit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 af4d349b65f708e0dcb5306cf741aaa23f00ffe824bbce06a299ca9241979636
MD5 0e7c83435cddd80d55ac57e1620f056e
BLAKE2b-256 7d65290af0704c84e84e6779a0863b07ab37016efc7a9c23ab2be1c91b206ede

See more details on using hashes here.

File details

Details for the file cli_edit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cli_edit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for cli_edit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f70766bb9673ccb8029593cd2d5178a8ec6dddac9427d50f64c32d3f73f47448
MD5 bf69eb18e0f751a52219e7e0884ca737
BLAKE2b-256 fdffc3bd6e4414d9c6cdefac59e160c67f82bb8e94a3b2dddfe6eeb3dcf02666

See more details on using hashes here.

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