Back to list
pe200012

mpatch

by pe200012

0🍴 0📅 Jan 19, 2026

SKILL.md


name: mpatch version: 1.0.0 description: Use when applying unified diff patches via CLI with fuzzy matching for out-of-date patches author: pe200012 license: BSD-3-Clause tags: [git, patch, diff, cli, tool]

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

Score

Total Score

50/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon