patchwork is a free, open source frameworks & platforms project written in Python and released under AGPL-3.0. It has 1,579 GitHub stars, 108 forks and 201 open issues, and was last pushed 1 months ago. On this registry it ranks #86 of 107 tracked projects in Frameworks & Platforms, with 5 head-to-head comparisons available.

What is patchwork?

Patchwork is a self-hosted, Python-based agentic AI framework that automates repetitive development work — pull request reviews, bug fixing, security patching and documentation — for engineering teams who want an LLM-driven agent running on their own infrastructure and their own models.

What it is

Patchwork is an open-source CLI agent for workflow automation in the Python ecosystem, distributed on PyPI as patchwork-cli. It is organised around three composable primitives: Steps, which are reusable atomic actions such as creating a PR, committing changes or calling an LLM; Prompt Templates, which are customisable LLM prompts tuned for particular chores like library updates, code generation, issue analysis or vulnerability remediation; and Patchflows, which are LLM-assisted automations assembled from steps and prompts. Patchflows can be executed locally in the CLI or an IDE, or run as part of a CI/CD pipeline, and several ship out of the box.

The concrete problem it addresses is the volume of development gruntwork that otherwise consumes engineer time: reviewing incoming PRs, triaging and fixing issues, remediating vulnerabilities found by scanners, upgrading dependencies, and generating documentation such as docstrings and READMEs. Instead of a developer running each of these tasks by hand, a patchflow drives the LLM and the surrounding tooling — for example running Semgrep over the working directory and then patching the findings — and returns changes ready for review.

Key capabilities

  • Ships ready-made patchflows including AutoFix, DependencyUpgrade, ResolveIssue, PRReview, GenerateDocstring and GenerateREADME.
  • The AutoFix patchflow runs semgrep to identify vulnerabilities in the current directory and then patches the code, with its configuration set in patchwork/patchflows/AutoFix/defaults.yml.
  • Optional dependency groups extend the core install: patchwork-cli[security] installs semgrep and depscan for AutoFix and DependencyUpgrade, while patchwork-cli[rag] installs chromadb for ResolveIssue.
  • Patchflow invocations accept key=value arguments that override default or optional attributes, with a bare key treated as a boolean True flag, for example patchwork AutoFix openai_api_key= github_api_key=.
  • Model selection is flexible: an OpenAI key, a Google google_api_key together with a model value such as gemini-pro-1.5 for its 1 million token input context, or a patched_api_key from the hosted managed service.
  • Default configuration and prompts for every patchflow are held in the patchwork-configs repository, which can be cloned and passed to the CLI with --config /path/to/patchwork.
  • A notifications dependency group backs steps that send messages such as Slack notifications.

Who uses it and how

  • Developers running patchflows locally from the CLI or an IDE against the working directory of a repository they already have checked out.
  • Teams wiring patchflows into a CI/CD pipeline so that PR review and automated fixes happen as part of the normal merge workflow.
  • Security-minded maintainers who install the security extra so that dependency upgrades and vulnerability remediation run with semgrep and depscan.
  • Contributors extending the framework by building new patchflows from steps and prompts, working from the patchwork-configs repository as the reference implementation.

Getting started

Install from PyPI with pip install 'patchwork-cli[all]' --upgrade, or install the core dependencies alone with pip install patchwork-cli if you only need GenerateDocstring, PRReview and GenerateREADME; then invoke a patchflow with the patchwork command. Building from source with Poetry is documented in INSTALL.md.

How it compares

Patchwork stands alone in this registry; the supplied facts name no comparable project for it to be measured against.

When to use it — and when not

A self-hoster must supply their own credentials — an OpenAI or Google API key and a github_api_key, or a patched_api_key from the hosted service — and may need to install extra dependency groups for the security and RAG-backed patchflows. It suits teams already comfortable running an LLM agent in their pipeline under AGPL-3.0 terms; anyone unwilling to meet that licence's obligations, or looking for a tool with no API key or scanner dependencies at all, should look elsewhere. With 201 open issues, the project is actively evolving, and configuration details are spread across the CLI, defaults.yml files and the separate patchwork-configs repository rather than contained in one place.

project readme (upstream, from github) — read inline
Patchwork logo
Patchwork GIF

Build Discord Downloads Downloads

Demo | Docs

Patchwork automates development gruntwork like PR reviews, bug fixing, security patching, and more using a self-hosted CLI agent and your preferred LLMs. Try the hosted version here.

Key Components

  • Steps: Reusable atomic actions like create PR, commit changes or call an LLM.
  • Prompt Templates: Customizable LLM prompts optimized for a chore like library updates, code generation, issue analysis or vulnerability remediation.
  • Patchflows: LLM-assisted automations such as PR reviews, code fixing, documentation etc. built by combining steps and prompts.

Patchflows can be run locally in your CLI and IDE, or as part of your CI/CD pipeline. There are several patchflows available out of the box, and you can always create your own.

Demo

Patchwork CLI Quickstart

Installation

Using Pip

Patchwork is available on PyPI and can be installed using pip:

pip install 'patchwork-cli[all]' --upgrade

The following optional dependency groups are available.

  • security: Installs semgrep and depscan with pip install 'patchwork-cli[security]' and is required for AutoFix and DependencyUpgrade patchflows.
  • rag: Installs chromadb with pip install 'patchwork-cli[rag]' and is required for the ResolveIssue patchflow.
  • notifications: Used by steps sending notifications, e.g. slack messages.
  • all: installs everything.
  • Not specifying any dependency group (pip install patchwork-cli) will install a core set of dependencies that are sufficient to run the GenerateDocstring, PRReview and GenerateREADME patchflows.

Using Poetry

If you'd like to build from source using poetry, please see detailed documentation here .

Patchwork CLI

The CLI runs Patchflows, as follows:

patchwork <PatchFlow> <?Arguments>

Where

  • Arguments: Allow for overriding default/optional attributes of the Patchflow in the format of key=value. If key does not have any value, it is considered a boolean True flag.

Example

For an AutoFix patchflow which patches vulnerabilities based on a scan using Semgrep:

patchwork AutoFix openai_api_key=<YOUR_OPENAI_API_KEY> github_api_key=<YOUR_GITHUB_TOKEN>

The above command defaults to patching code in the current directory by running Semgrep to identify the vulnerabilities. You can view the default.yml file for the list of configurations you can set to manage the AutoFix patchflow. For more details on how you can use a personal access token from GitHub on CLI, can read this.

You can replace the OpenAI key with a key from our managed service by signing in at https://app.patched.codes/signin and generating an API key from the integrations tab. You can then call the patchflow with the key as follows:

patchwork AutoFix patched_api_key=<YOUR_PATCHED_API_KEY> github_api_key=<YOUR_GITHUB_TOKEN>

To use Google's models you can set the google_api_key and model, this is useful if you want to work with large contexts as the gemini-pro-1.5 model supports an input context length of 1 million tokens.

The patchwork-template repository contains the default configuration and prompts for all the patchflows. You can clone that repo and pass it as a flag to the CLI:

patchwork AutoFix --config /path/to/patchwork-configs/patchflows

Using open source models

Patchwork supports any OpenAI compatible endpoint, allowing use of any LLM from various providers like Groq, Together AI, or Hugging Face.

E.g. to use Llama 3.1 405B from Groq.com run:

patchwork AutoFix client_base_url=https://api.groq.com/openai/v1 openai_api_key=your_groq_key model=llama-3.1-405b-reasoning

You can also use a config file to do the same. To use Llama 3.1 405B from Hugging Face, create a config.yml file:

openai_api_key: your_hf_token
client_base_url: https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3.1-405B-Instruct-FP8/v1
model: Meta-Llama-3.1-405B-Instruct-FP8

And run as:

patchwork AutoFix --config=/path/to/config.yml

This allows you to run local models via llama.cpp, ollama, vllm or tgi. For instance, you can run Llama 3.1 8B locally using llama_cpp.server:

python -m llama_cpp.server --hf_model_repo_id bullerwins/Meta-Llama-3.1-8B-Instruct-GGUF --model 'Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf' --chat_format chatml

Then run your patchflow:

patchwork AutoFix client_base_url=http://localhost:8080/v1 openai_api_key=no_key_local_model

Patchflows

Patchwork comes with predefined patchflows, with more added over time. Sample patchflows include:

  • GenerateDocstring: Generate docstrings for methods in your code.
  • AutoFix: Generate and apply fixes to code vulnerabilities in a repository.
  • PRReview: On PR creation, extract code diff, summarize changes, and comment on PR.
  • GenerateREADME: Create a README markdown file for a given folder, to add documentation to your repository.
  • DependencyUpgrade: Update your dependencies from vulnerable to fixed versions.
  • ResolveIssue: Identify the files in your repository that need to be updated to resolve an issue (or bug) and create a PR to fix it.

Prompt Templates

Prompt templates are used by patchflows and passed as queries to LLMs. Templates contain prompts with placeholder variables enclosed by {{}} which are replaced by the data from the steps or inputs on every run.

Below is a sample prompt template:

{
  "id": "diffreview_summary",
    "prompts": [
      {
        "role": "user",
        "content": "Summarize the following code change descriptions in 1 paragraph. {{diffreviews}}"
      }
    ]
}

Each patchflow comes with an optimized default prompt template. But you can specify your own using the prompt_template_file=/path/to/prompt/template/file option.

Contributing

Contributions for new patchflows and steps, or to the core framework are welcome. Please look at open issues for details.

We also provide a chat assistant to help you create new steps and patchflows easily.

Roadmap

Short Term

  • Expand patchflow library and integration options
  • Patchflow debugger and validation module
  • Bug fixing and performance improvements
  • Refactor code and documentation

Long Term

  • Support large-scale code embeddings in patchflows
  • Support parallelization and branching
  • Fine-tuned models that can be self-hosted
  • Open-source GUI

License

Patchwork is licensed under AGPL-3.0 terms. However, custom patchflows and steps can be created and shared using the patchwork template repository which is licensed under Apache-2.0 terms.

Frequently asked questions

Is patchwork free to use?

patchwork is open source under the AGPL-3.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does patchwork do?

Agentic AI framework for enterprise workflow automation.

What is patchwork written in?

patchwork is primarily written in Python. Its source is publicly available at https://github.com/patched-codes/patchwork, and it has 1,579 GitHub stars.