Skip to main content

Patch

AI pair programming in your terminal

Website · GitHub

PyPI Python versions GitHub Stars License

Patch lets you pair program with LLMs to start a new project or build on an existing codebase.

Features

Cloud and local LLMs

Patch connects to cloud and local LLMs, giving you the flexibility to use the models that work best for you.

Maps your codebase

Patch maps your entire codebase, which helps it work well in larger projects.

100+ code languages

Patch works with Python, JavaScript, TypeScript, Rust, Ruby, Go, C++, PHP, HTML, CSS, and dozens more.

Git integration

Patch automatically commits changes with sensible commit messages. Use familiar Git tools to diff, manage, and undo AI changes.

Use in your IDE

Use Patch from within your favorite IDE or editor. Ask for changes by adding comments to your code and Patch will get to work.

Images & web pages

Add images and web pages to the chat to provide visual context, screenshots, reference docs, etc.

Voice-to-code

Speak with Patch about your code. Request new features, test cases, or bug fixes using your voice and let Patch implement the changes.

Linting & testing

Automatically lint and test your code every time Patch makes changes. Patch can fix problems detected by your linters and test suites.

Copy/paste to web chat

Work with any LLM via its web chat interface. Patch streamlines copying code context and edits between your terminal and browser.

Getting Started

Patch supports Python 3.10 through 3.14. Install it from PyPI and run the patch command:

python -m pip install patch-chat

# Start Patch in your codebase
cd /to/your/project
patch

To hack on Patch itself, install it from source in editable mode instead:

git clone https://github.com/PierrunoYT/patch.git
cd patch
python -m pip install -e .

See CONTRIBUTING.md for the full development setup.

Security Boundaries

Patch treats both model output and the repository under edit as untrusted input.

Writes stay inside the repository. Every model-supplied path is resolved canonically and must land inside the repository root before anything is created or modified. Absolute paths, .. traversal, and symlinks pointing outside the tree are refused, including under --no-git and --yes, and including the patch format's Move to: target. Files added with --read or /read-only are never written to at all: they are reference material, so an edit targeting one is refused whether it sits inside the repository or outside it.

The repository's own config is not trusted. A .patch.conf.yml or .env discovered inside the repository cannot set execution-capable options (test, test-cmd, lint-cmd, load, notifications-command, editor, verify-ssl, git-commit-verify, allow-private-urls, gui-address) or environment variables that redirect API endpoints or proxies (*_API_BASE, *_BASE_URL, HTTP(S)_PROXY, REQUESTS_CA_BUNDLE, ...). Nor can it name another file for Patch to trust — env-file, model-settings-file and model-metadata-file are refused from repository config for that reason. The same applies to a .patch.model.settings.yml or .patch.model.metadata.json in the repository, whose extra_params would otherwise set api_base, api_key and extra_headers for every model. A repository .env may also only add environment variables, never replace ones you exported in your shell: a project that ships OPENAI_API_KEY would otherwise send your prompts to the real provider on someone else's account. Ignored settings and files are reported at startup. Your home-directory config and any file you pass explicitly on the command line with --config, --env-file, --model-settings-file or --model-metadata-file are trusted as usual — they still override your shell, because naming a file is an instruction — and only a flag actually present in the command line counts, never one a repository config supplied.

Pass --trust-repo-config to opt back in for a repository you trust. You can also set PATCH_TRUST_REPO_CONFIG in your shell. The setting is ignored when it comes from the repository's own config or .env, so a repository cannot grant itself trust.

Scraping stays on public addresses. /web, and any URL Patch fetches on your behalf, is refused when it resolves to a private, loopback or link-local address. Cloud metadata services answer on 169.254.169.254 and hand out IAM credentials to whatever asks, and the URL usually comes from the repository — a README is enough to aim it. Names are checked after resolution, so a hostname with an A record pointing at a private address is refused too, as is a redirect that arrives at one. Pass --allow-private-urls to scrape a local dev server deliberately; a repository config cannot set it.

The browser UI listens on this machine only. --browser / --gui binds 127.0.0.1. The UI has no authentication and can edit your repository and spend your API credits, so it is not something to put on a shared network by accident. --gui-address ADDR moves it deliberately — --gui-address 0.0.0.0 accepts connections from anywhere and says so at startup.

Running in a container. The boundary above distinguishes your files from the repository's by comparing against your home directory, so do not set HOME to the directory you mount the project into — the two become indistinguishable and every filter above stops applying. The bundled docker/Dockerfile keeps HOME at /home/appuser and mounts your project at /app; mount a volume at /home/appuser/.patch if you want the caches to outlive the container.

Running Commands

/run, /test and --test-cmd stop a command after 120 seconds and report exit status 124, so a hung command cannot stall the session. Raise the limit with --command-timeout SECONDS, or pass --command-timeout 0 to remove it entirely:

patch --test-cmd "pytest" --command-timeout 600   # allow ten minutes
patch --test-cmd "pytest" --command-timeout 0     # no limit

Output is streamed to your terminal in full; only the copy kept for the chat is capped, at 1 MB, with the oldest lines dropped first.

Development

See CONTRIBUTING.md for local development instructions. Amp orbs use the repository's executable .agents/setup script to provision the complete development and optional-feature toolchain automatically on fresh remote machines.

More Information

Documentation

Community & Resources

Release files for patch-chat 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for patch-chat 0.5.0
File Size Uploaded
patch_chat-0.5.0.tar.gz 1.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for patch-chat 0.5.0
File Interpreter ABI Platform
patch_chat-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.7 MB

Release files / patch_chat-0.5.0.tar.gz

Download URL patch_chat-0.5.0.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
64a4bfb293cdca298f8026e6529a04cc67cc2864afcdc53951b3abe6f6f60177
BLAKE2b-256 checksum
How to use checksums
cabd21ae5125d16b6a4252812e3ed305b0a88045696f0b6aac7f909963e89f2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / patch_chat-0.5.0-py3-none-any.whl

Download URL patch_chat-0.5.0-py3-none-any.whl
Size 282.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
988720a1ccb0961c10e1d1b0a54d104f58c9adcb444bac0d5cb729b61b8b573a
BLAKE2b-256 checksum
How to use checksums
df35344e8beda572fa53237df63e4f3d57741c39d13a5888718128714ef936f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release history Release notifications | RSS feed

0.5.1

2 release files

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page