AI-assisted coding automation tool for streamlined LLM code integration
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
PatchCommander
PatchCommander is a Python-based tool designed to streamline AI-assisted development. It works by processing code changes generated by Large Language Models (LLMs) that follow a specific tag-based syntax. By instructing LLMs to format their code suggestions using PatchCommander's tags, developers can easily and reliably apply AI-generated changes across their codebase.
Purpose
Traditional copy-pasting of code suggested by LLMs is error-prone and time-consuming, especially when changes span multiple files or require careful integration into existing code. PatchCommander solves this by:
- Defining a structured tag syntax that LLMs can be instructed to follow
- Automatically processing these tags to make precise modifications to your codebase
- Providing safety features like diff previews and syntax validation before changes are applied
This creates a seamless workflow between AI code suggestions and practical implementation.
Features
- LLM-friendly tag syntax: Simple XML-like tags that AI models can easily adopt
- Multiple change types: Support for file, class, function, method, and operation modifications
- Smart method handling: Splits multiple method definitions automatically
- Diff preview: View changes before applying them
- Syntax validation: Automatically checks for syntax errors and reverts changes if errors are found
- Clipboard support: Read input directly from clipboard when no file is specified
- Multi-language support: Works with Python and JavaScript files
Installation
Option 1: Using pipx (recommended for command-line tools)
pipx install patchcommander
Option 2: Using pip
pip install patchcommander
Option 3: Using uv
uv install patchcommander
Option 4: From source
# Clone the repository
git clone https://github.com/jacekjursza/PatchCommander.git
# Navigate to the directory
cd PatchCommander
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .
Dependencies
- rich
- pyperclip
- tree-sitter
- tree-sitter-python
- tree-sitter-javascript
Usage
After installation, you can use PatchCommander with the shorter command:
# Run with input from clipboard (no arguments)
pcmd
# Run with input from a file
pcmd path/to/input_file.txt
# Show help
pcmd --help
# Display LLM instructions and syntax guide
pcmd --prompt
# Display only the tag syntax guide for LLMs
pcmd --syntax
The legacy command patchcommander is also available but pcmd is recommended.
Tag Syntax for LLMs
When prompting your LLM, instruct it to format code changes using the following tags:
FILE
Replace an entire file's content:
<FILE path="path/to/file.py">
# New file content goes here
</FILE>
CLASS
Update or add a class to a file:
<CLASS path="path/to/file.py" class="ClassName">
class ClassName:
# Class content goes here
</CLASS>
FUNCTION
Update or add a standalone function to a file:
<FUNCTION path="path/to/file.py">
def function_name(arg1, arg2):
# Function body goes here
return result
</FUNCTION>
METHOD
Update or add a method to a class:
<METHOD path="path/to/file.py" class="ClassName">
def method_name(self, arg1, arg2):
# Method body goes here
return result
</METHOD>
OPERATION
Perform file operations:
<OPERATION action="move_file" source="old/path.py" target="new/path.py" />
<OPERATION action="delete_file" source="path/to/file.py" />
<OPERATION action="delete_method" source="path/to/file.py" class="ClassName" method="method_name" />
AI-Assisted Development Workflow
- Prompt the LLM: Ask your LLM to implement a feature or fix a bug, instructing it to format changes using PatchCommander's tag syntax
- Copy the output: Save the LLM's response with the tagged code changes to a file or clipboard
- Run PatchCommander: Process the changes using
pcmd [filename]or justpcmdfor clipboard content - Review the changes: Examine the diffs for each proposed change
- Confirm or reject: Choose which changes to apply
- Apply changes: All confirmed changes are applied at once at the end of the process
Example Prompt for LLMs
Please implement a user authentication system for my Flask application.
Format your response using PatchCommander tag syntax:
- Use <FILE> tags for new files or complete file replacements
- Use <CLASS> tags for adding or updating classes
- Use <FUNCTION> tags for adding or updating standalone functions
- Use <METHOD> tags for adding or updating methods
- Use <OPERATION> tags for file operations
Example format:
<FILE path="app/auth.py">
[code here]
</FILE>
<FUNCTION path="app/utils.py">
[function code here]
</FUNCTION>
<METHOD path="app/models.py" class="User">
[method code here]
</METHOD>
Example Implementation
<FILE path="example.py">
class Example:
def __init__(self):
self.value = 42
def get_value(self):
return self.value
</FILE>
<FUNCTION path="example.py">
def utility_function(param):
return param * 2
</FUNCTION>
<METHOD path="example.py" class="Example">
def set_value(self, new_value):
self.value = new_value
</METHOD>
<OPERATION action="move_file" source="old_name.py" target="new_name.py" />
How It Works
- Preprocessing: Tags are parsed and processed (e.g., multiple methods in a METHOD tag are split)
- Processing: Each tag is processed to generate the intended file changes
- Confirmation: Changes are shown as diffs and require confirmation
- Application: All confirmed changes are applied together at the end
License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file patchcommander-1.1.1.tar.gz.
File metadata
- Download URL: patchcommander-1.1.1.tar.gz
- Upload date:
- Size: 38.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7db49e16bb90830ac247c97d0ce57c8ebb765469c26a275803677d19dd45e73e
|
|
| MD5 |
8400c73c2497bfd8066b7f597f41b239
|
|
| BLAKE2b-256 |
eeaf399c8c4269683f06757e724b57390cb9cb435fe54b5d4796522b2faeb9c3
|
File details
Details for the file patchcommander-1.1.1-py3-none-any.whl.
File metadata
- Download URL: patchcommander-1.1.1-py3-none-any.whl
- Upload date:
- Size: 37.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e362d2834a6e12ee0af4c9d6d4cec6751ff62f7d3f0d48aecab2c9b067345ac7
|
|
| MD5 |
c514d01cfb07905a28a6a631cd698333
|
|
| BLAKE2b-256 |
5f1a277b0c1a43fef86d9228dccb9f8c75e7785adc415b0a85f74270e63eae94
|