- name
- file-diff
- description
- Compare two files and display their differences in a human-readable markdown format. Use when asked to "compare files", "show diff", "compare differences", "diff two files", or any request to analyze file differences. Triggers on phrases like "比较文件"、"比较异同"、"diff"、"show me the differences".
File Diff
Compare two files and display differences in a clean, readable markdown format.
Usage
Quick Compare (Two file paths)
diff <source_file> <target_file>Unified Diff Format (Recommended)
diff -u <source_file> <target_file>Output Format
The diff output is formatted as:
**File A**: `/path/to/file1`
**File B**: `/path/to/file2`
## Differences
### 1. [Section/Line description]- removed line
+ added line
Workflow
- Identify the two files to compare
- Run
diff -ucommand - Parse the unified diff output
- Format into readable markdown with:
- File paths as headers - Line numbers from diff output - - prefix for removals (red) - + prefix for additions (green) - Context lines for clarity
Example
Input:
diff -u /tmp/original.txt /tmp/modified.txtOutput format:
**File A**: `/tmp/original.txt`
**File B**: `/tmp/modified.txt`
## Differences
### Line 5- old content
+ new content
Notes
- Always use
-uflag for unified format (more readable) - Include both file paths in the output
- Preserve all changes including additions, deletions, and modifications