Backed by mandō

Apply changes.
Surgically.

Patchwork is the code transformation platform that takes a diff and applies it to the original with zero guesswork. Hunks, offsets, fuzz factors β€” resolved in milliseconds. The future of controlled code evolution.

0% Hunk application accuracy
0M+ Patches applied daily
0 Diff formats supported
0 Default fuzz factor

Every diff format. Every edge case.
Every hunk applied.

Patchwork ships with the most surgical code transformation engine ever built. Apply changes from any diff source β€” context, unified, normal β€” with intelligent fuzz matching and conflict resolution.

Universal Ingest

patch < DIFF

Feed any diff β€” from stdin, piped email, GitHub PRs, or raw files. Patchwork auto-detects the format, skips leading garbage, handles CRLF, RFC 934 encapsulation, and indented diffs. Just pipe and apply.

Path Strip Engine

-p NUM

Strip the smallest prefix containing NUM leading slashes from each filename. Essential when applying patches across directory structures that don't match the sender's. -p1 is the industry standard.

Dry Run Preview

--dry-run

See exactly what will happen before making a single change. Full simulation of the patch application β€” hunk status, offsets, conflicts β€” without touching a file. The safety net every engineer needs.

Reverse Engineering

-R

Undo any patch by swapping old and new. Because sometimes the future wasn't ready. Patchwork even auto-detects reversed patches: if the first hunk fails, it tries the reverse heuristic before giving up.

Backup Protocol

-b -V STYLE

Never lose the original. Choose simple (.orig), numbered (.~N~), or existing-style backups. Customize prefix, suffix, and basename prefixes for total control over your safety copies.

Fuzz Intelligence

-F NUM

When context doesn't match exactly, Patchwork scans forward and backward with configurable fuzz. Ignore 1, 2, or more lines of context to find where the hunk really belongs. Default: 2. Surgical, not brittle.

Merge Mode

--merge

Conflicts don't have to be fatal. Patchwork merges hunks directly into originals using <<<<<<< / ======= / >>>>>>> markers β€” just like your version control. Choose diff3 or merge format output.

Format Intelligence

-c / -u / -n

Auto-detect context, unified, normal, or ed script formats. Or force the parser with flags. Patchwork speaks every diff dialect β€” from legacy ed scripts to modern unified, and everything in between.

Three steps to transformed code

01

Ingest

Feed Patchwork a diff from any source β€” stdin pipe, file with -i FILE, or positional argument. Works with unified, context, normal, and ed formats. Skips email headers, RFC encapsulation, and comments automatically.

02

Analyze

Each hunk is matched against the target file. Patchwork checks line numbers, applies fuzz (-F), handles offsets, and scans forward/backward for the best insertion point. Conflicts are captured, not ignored.

03

Apply

The patched version replaces the original (or goes to -o FILE). Backups (-b) are created per your versioning policy. Rejected hunks go to .rej files. Empty files get cleaned up with -E.

The Patch Applicator

Paste an original file and a unified diff. Watch Patchwork transform it in real time.

Original File
Unified Diff
Result
Click "Apply Patch" to see the result...

When hunks collide, Patchwork mediates

Our merge engine brackets conflicts with standard markers. Resolve inline, accept theirs, keep yours β€” all from a single interface.

server.conf β€” 1 conflict
1listen_port = 443
2ssl_enabled = true
3<<<<<<< yours
4max_connections = 100
5=======
6max_connections = 500
7>>>>>>> theirs
8timeout = 30s

Preview before you transform

--dry-run simulates every hunk, every offset, every fuzz match β€” without writing a single byte.

~/project
$ patchwork --dry-run -p1 < update.patch
checking file src/config.yml...
Hunk #1 succeeded at 12 (offset 3 lines).
Hunk #2 succeeded at 45.
Hunk #3 succeeded at 78 with fuzz 1.
checking file src/server.js...
Hunk #1 succeeded at 1.
Hunk #2 FAILED at 34.
checking file README.md...
Hunk #1 succeeded at 1.
---
3 files would be patched
5 of 6 hunks would succeed
1 hunk would FAIL β€” saved to src/server.js.rej

Trusted by teams who ship patches

β˜…β˜…β˜…β˜…β˜…
"We apply 400+ patches per deploy cycle. Patchwork's fuzz intelligence means we spend zero time debugging misaligned hunks. The -F 2 default is chef's kiss β€” perfect balance of flexibility and precision."
Ivan Ramirez
Ivan Ramirez Staff Engineer, PlatformGrid
β˜…β˜…β˜…β˜…β˜…
"The --dry-run feature alone justified our entire migration to Patchwork. We preview every patch before applying and catch offset drift before it becomes a production incident. Absolute game changer."
Jenna Lasky
Jenna Lasky VP DevOps, CloudScape
β˜…β˜…β˜…β˜…β˜…
"Patchwork's merge mode with conflict markers saved our team from writing custom merge tooling. We pipe diffs from six upstream repos, resolve inline, and ship. --merge=diff3 is the unsung hero."
Diego Morales
Diego Morales Lead SRE, Infranaut
β˜…β˜…β˜…β˜…β˜…
"I maintain a kernel fork and apply hundreds of patches with -p1 from mailing lists. Patchwork strips email headers, handles CRLF, and just works. I haven't manually resolved a reject file in months."
Saskia Starling
Saskia Starling Kernel Engineer, Independent

Plans that scale with your patches

Start free. Upgrade when your transformation workflows demand more.

Starter
$0/mo
  • βœ“ Unified diff format only
  • βœ“ 100 patches/month
  • βœ“ Basic -p NUM stripping
  • βœ— No dry run
  • βœ— No merge mode
  • βœ— No backup control
Get Started Free
Team
$59/seat/mo
  • βœ“ Everything in Pro
  • βœ“ Merge mode --merge
  • βœ“ Conflict resolution UI
  • βœ“ Custom reject file paths
  • βœ“ SSO & audit logs
  • βœ“ Loose matching -l
Start Team Trial
Enterprise
Custom
  • βœ“ Everything in Team
  • βœ“ On-prem deployment
  • βœ“ Dedicated SLA & support
  • βœ“ Custom fuzz algorithms
  • βœ“ Ed script support
  • βœ“ RCS/ClearCase integration
Contact Sales

See it in the terminal

~/project
$ patchwork -p1 < feature.patch
patching file src/auth.js
Hunk #1 succeeded at 12 (offset 2 lines).
Hunk #2 succeeded at 45.
patching file src/config.yml
Hunk #1 succeeded at 8 with fuzz 1.

$ patchwork -R -b -V numbered -p1 < feature.patch
patching file src/auth.js
Hunk #1 succeeded at 12 (offset 2 lines).
Hunk #2 succeeded at 45.
backup: src/auth.js β†’ src/auth.js.~1~

$ patchwork --dry-run -p1 -i hotfix.patch
checking file server.conf...
Hunk #1 succeeded at 1.
Hunk #2 FAILED at 24.
1 out of 2 hunks FAILED β€” saving rejects to server.conf.rej

$ patchwork -d /usr/src/app --merge -p1 < upstream.patch
patching file api/routes.js
1 conflict in api/routes.js

Frequently asked questions

What diff formats does Patchwork support?

Patchwork handles unified (-u), context (-c), normal (-n), and ed script (-e) formats. It auto-detects the format from the input, or you can force it with flags. Unified is the most common format used by git, GitHub, and modern tooling. Context diffs include surrounding lines for better matching.

What happens when a hunk fails?

When a hunk can't be applied at its target location, Patchwork scans forward and backward using the fuzz factor (-F NUM, default 2). If still no match, the hunk is saved to a .rej reject file (customizable with -r FILE) and the rest of the patch continues applying. You're told exactly which hunk failed and where.

How does the fuzz factor work?

The fuzz factor controls how many lines of context Patchwork ignores when searching for hunk placement. At fuzz 0, all context must match exactly. Fuzz 1 ignores the first and last context lines. Fuzz 2 (default) ignores the first two and last two. Higher fuzz is more flexible but increases risk of misplacing hunks.

Can I apply a patch without modifying the original file?

Yes β€” use -o FILE to write the patched output to a different file, or --dry-run to simulate without writing anything at all. You can also use -b to create automatic backups before any changes are made. The backup style (simple, numbered, or existing) is controlled via -V.

What does -p1 actually do?

The -p flag strips leading path components from filenames in the patch. Given a path like /u/dev/src/app/config.js, -p0 keeps the full path, -p1 removes the leading slash giving u/dev/src/app/config.js, -p4 gives app/config.js. This is essential when directory structures differ between sender and receiver.

Is my source code secure?

Patchwork processes everything locally. No files are uploaded, no telemetry is collected on content, and no cloud services are required. Enterprise customers deploy fully on-prem with SOC 2 compliance. Your code never leaves your infrastructure.

See mandō's portfolio