unified-diff-generation

Generate patch-compatible unified diffs with a/ and b/ prefixes.

4|2|Updated Jan 11, 2026
One-click install
npx skills add https://github.com/nick-orton/vybz --skill unified-diff-generation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unified-diff-generation
Source: https://github.com/nick-orton/vybz/tree/main/src/vybz/library/skills/unified-diff-generation
Command: npx skills add https://github.com/nick-orton/vybz --skill unified-diff-generation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill enables the precise generation of patch-compatible unified diffs (diff -u), ensuring proper headers, context, and formatting to keep patches portable and applyable with standard tools.

Core Features & Use Cases

  • Produce unified diffs with mandatory a/ and b/ prefixes
  • Enforce 3-line context per hunk
  • Handle new/deleted files with /dev/null representations
  • Validate headers, whitespace, and line counts for patch compatibility

Quick Start

Generate a patch by producing a unified diff (diff -u) with proper a/ and b/ prefixes, three-context hunks, and correct header counts, then validate it by applying with patch -p1.

Frequently Asked Questions about unified-diff-generation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate a unified diff that applies cleanly with patch -p1?

To generate a unified diff compatible with patch -p1, you need mandatory a/ and b/ file path prefixes, exact 3-line context per hunk, and accurate header line counts. This ensures the patch remains portable and applyable across source trees.

What is the correct format for a unified diff when creating a patch?

A correct unified diff format requires a/ and b/ path prefixes, three lines of surrounding context for each hunk, and proper /dev/null representations for new or deleted files. It must also preserve original indentation and final newline semantics.

How do I handle new or deleted files in a unified diff?

When handling new or deleted files in a unified diff, the absent file side should be represented using /dev/null. This maintains patch compatibility and ensures the file creation or removal applies correctly to the source tree.

Why does my generated patch fail to apply due to context mismatch?

Patch application failures often occur when a unified diff lacks the exact 3-line context rule, contains inaccurate header line counts, or alters original indentation. Enforcing proper formatting and whitespace validation resolves these compatibility issues.

Can I generate a unified diff for both small and large code changes?

Yes, you can generate patch-compatible unified diffs for both small and large changes. The process enforces correct headers, file path prefixes, and context rules across the entire diff regardless of the change size.

Does a unified diff need to preserve final newline semantics?

Yes, preserving final newline semantics is required when generating a unified diff. Maintaining exact whitespace, indentation, and newline characters ensures the patch validates correctly and applies without conflicts.