diff-patch-tool
v1.0.2
Published
A simple CLI tool to apply diffs from your clipboard to your local files.
Readme
diff-patch-tool
diff-patch-tool is a command-line tool that reads a diff from your clipboard and applies it to your local file system. This is particularly useful for quickly applying patches provided by AI assistants like GPT-4 or Claude, which often provide code changes in a diff format.
The tool's binary is named diff-patcher.
Installation
npm install -g diff-patch-toolUsage
Copy a diff: Copy a diff in the standard unified format to your clipboard. It can be a "dirty" diff, surrounded by other text or markdown fences (
```diff) - the parser will find the diff content automatically.Example:
--- a/src/index.js +++ b/src/index.js @@ -1,3 +1,3 @@ function hello() { - console.log("Hello, old world!"); + console.log("Hello, new world!"); }Navigate to your project:
cdinto the root directory of the project you want to patch.Run the tool:
diff-patcherThe tool will read from the clipboard, parse the diff, and apply the changes to the files relative to your current directory.
(Optional) Specify a target directory: If you want to apply the patch to a different directory without
cd-ing into it, you can provide a path as an argument:diff-patcher ./path/to/your/project
