askill
mpatch

mpatchSafety --Repository

Use when applying unified diff patches via CLI with fuzzy matching for out-of-date patches

0 stars
1.2k downloads
Updated 1/19/2026

Package Files

Loading files...
SKILL.md

mpatch Skill

Smart context-aware CLI tool for applying unified diffs with fuzzy matching.

When to Use

  • Applying unified diff patches to source files via command line
  • Patches where line numbers may be outdated
  • Fuzzy matching patches against modified content
  • Processing Markdown diff blocks, unified diffs, or conflict markers

Installation

cargo install mpatch

CLI Usage

Basic Syntax

mpatch <INPUT_FILE> <TARGET_DIR>

Arguments

ArgumentDescription
INPUT_FILEPath to patch file (Markdown, Unified Diff, or Conflict Markers)
TARGET_DIRDirectory containing files to patch

Options

OptionDescription
-n, --dry-runShow what would be done without modifying files
-f, --fuzz-factor <0.0-1.0>Similarity threshold for fuzzy matching (default: 0.7). Higher = stricter. 0 = disable fuzzy
-v, --verboseIncrease verbosity: -v info, -vv debug, -vvv trace, -vvvv debug report
-h, --helpPrint help
-V, --versionPrint version

Examples

Apply a patch

mpatch changes.patch ./src

Dry run (preview changes)

mpatch -n changes.patch ./src

Strict matching (no fuzzy)

mpatch -f 0 changes.patch ./src

Lenient fuzzy matching

mpatch -f 0.5 changes.patch ./src

Verbose output for debugging

mpatch -vv changes.patch ./src

Supported Patch Formats

mpatch auto-detects the input format:

  1. Unified Diff (standard diff -u output)

    --- a/file.txt
    +++ b/file.txt
    @@ -1,3 +1,4 @@
     line1
    +new line
     line2
    
  2. Markdown Code Blocks (common in AI-generated patches)

    ```diff
    --- a/file.txt
    +++ b/file.txt
    @@ -1,3 +1,4 @@
     context
    -old
    +new
    ```
    
  3. Conflict Markers (git merge conflicts)

    <<<<<<< HEAD
    current content
    =======
    incoming content
    >>>>>>> branch
    

Key Features

  • Ignores line numbers: Uses context matching instead
  • Fuzzy matching: Applies patches even when source has minor changes
  • Auto-detection: No need to specify patch format
  • Smart indentation: Handles indentation differences

Common Mistakes

MistakeFix
Forgetting target directorySecond argument is the directory, not the file
Expecting exact matchUse -f 0 if you want strict matching
Not checking results firstUse -n (dry-run) to preview
Patch not applyingTry -f 0.5 for more lenient matching

Workflow Example

# 1. Preview what will change
mpatch -n patch.diff ./myproject

# 2. Apply with verbose output
mpatch -v patch.diff ./myproject

# 3. If fuzzy fails, try more lenient
mpatch -f 0.5 patch.diff ./myproject

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

AI review pending.

Metadata

Licenseunknown
Version1.0.0
Updated1/19/2026
Publisherpe200012

Tags

github-actions