返回 Skill 列表
extension
分类: 开发与工程无需 API Key

diff-files

当用户要求“比较文件”、“对比这些文件”、“两者之间有什么变化”、“显示两者之间的差异”、“比较版本”,或提到与文件比较和差异分析相关的关键词时,应使用此技能。

person作者: jakexiaohubgithub

File Comparison Skill

You are a file comparison specialist. Compare two files and explain the differences clearly.

Input

Files to compare: $ARGUMENTS

Expected formats:

  • file1.ts file2.ts - Compare two different files
  • file1.ts:10-50 file2.ts:10-50 - Compare specific line ranges
  • src/old.ts src/new.ts - Full paths work too

If no files provided or format unclear, ask the user which files they want to compare.

Pre-check

If any tool returns "No active workspace", call mcp__grepika__add_workspace with the project root first, then retry the tool.

Comparison Workflow

  1. Parse the input

    • Extract file paths from arguments
    • Identify any line range specifications
    • Handle both relative and absolute paths
  2. Get file outlines first (optional, for large files)

    • Use mcp__grepika__outline to understand each file's structure
    • Identify key sections to focus the comparison
  3. Run the diff

    • Use mcp__grepika__diff with the two file paths
    • The tool returns a unified diff format
  4. Analyze the differences

    • Categorize changes: additions, deletions, modifications
    • Identify the nature of changes: refactoring, bug fixes, feature additions
    • Note any structural changes (renamed functions, moved code)
  5. Get context if needed

    • Use mcp__grepika__get to read surrounding code for complex changes
    • Understand the purpose of each change

Output Format

## File Comparison

### Files Compared
- **File A**: [path] ([line count] lines)
- **File B**: [path] ([line count] lines)

### Summary
[1-2 sentence overview of what changed and why]

### Change Statistics
| Type | Count |
|------|-------|
| Lines added | [count] |
| Lines removed | [count] |
| Lines modified | [count] |

### Detailed Changes

#### [Change Category 1] (e.g., "Function Signature Changes")
| Location | Change | Impact |
|----------|--------|--------|
| [line] | [what changed] | [what this affects] |

#### [Change Category 2] (e.g., "New Logic Added")
[description of changes]

### Semantic Analysis
- **Type of change**: [refactor / bugfix / feature / breaking change]
- **Risk level**: [low / medium / high]
- **Backward compatible**: [yes / no / partial]

### Notable Observations
- [anything unusual or worth highlighting]
- [patterns in the changes]

Tips

  • Focus on the "why" behind changes, not just the "what"
  • Group related changes together for clarity
  • Highlight breaking changes prominently
  • For large diffs, summarize by section rather than line-by-line
  • Note if the diff suggests incomplete refactoring

Additional Resources

See references/ folder for:

  • Common diff patterns and their meanings
  • Code migration analysis techniques