# Git diff 2dot vs 3dot merge safety

> Git diff 2dot vs 3dot merge safety is an open-source agent skill for developer tools. Checks whether a branch really deletes files before merge, using three-dot git diffs. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/wan-huiyan/agent-traffic-control/tree/main/plugins/agent-traffic-control/skills/git-diff-2dot-vs-3dot-merge-safety
- **Repository:** https://github.com/wan-huiyan/agent-traffic-control
- **GitHub stars:** 5
- **License:** MIT
- **Skill name:** git-diff-2dot-vs-3dot-merge-safety
- **Collection:** https://github.com/wan-huiyan/agent-traffic-control
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

This skill helps an agent judge merge risk when a pull request looks like it deletes files on main. It explains that a two-dot diff compares two trees directly, so files added to main after the branch point show up as removals, while a three-dot diff compares against the merge base and reports only what the branch itself changed.

The workflow gives the agent concrete git commands: a three-dot stat, a filter limited to deleted or renamed paths, and a check of the GitHub mergeable status as a cross-reference. It also covers divergent local branches, where the agent probes whether a local commit is already on main by cherry-picking it onto a fresh branch off origin/main and interpreting the outcome, then grepping the touched files to confirm.

It expects a git repository with an origin remote, and the GitHub CLI for the mergeable check. The notes warn that a stale local main ref can over-report, so the agent should fetch and diff against origin/main, and that an empty deletion filter does not rule out reverted content.

## When your agent uses it

> Two-dot `git diff origin/main..branch` reports files `main` gained after you branched as your deletions; three-dot uses the merge base and shows only real ones.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/wan-huiyan/agent-traffic-control/tree/HEAD/plugins/agent-traffic-control/skills/git-diff-2dot-vs-3dot-merge-safety)
- [License: MIT](https://github.com/wan-huiyan/agent-traffic-control/tree/HEAD/plugins/agent-traffic-control/skills/git-diff-2dot-vs-3dot-merge-safety)

## Features

- **Two-dot versus three-dot diff:** Explains why a two-dot comparison reports files added to main after branching as deletions.
- **Deletion check command:** Provides a three-dot diff filtered to deleted and renamed paths to confirm what a branch removes.
- **Divergent commit probe:** Walks through cherry-picking a local commit onto a fresh branch to see if its content already exists on main.
- **Empty cherry-pick interpretation:** Describes how to read git output to tell redundant commits from real conflicts or missing content.
- **Stale ref pitfalls:** Warns that an outdated local main ref can inflate three-dot results and recommends fetching first.

## Good for

- Check whether a pull request will delete files already on main
- Find out if a local commit is already present on origin/main under a different hash
- Safely reset a local main branch to origin/main after verifying content
- Confirm a squash-merged change is on main before discarding a local branch

## Install

### Claude Code

This skill ships in the `agent-traffic-control` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add wan-huiyan/agent-traffic-control
/plugin install agent-traffic-control@wan-huiyan-agent-traffic-control
```

Or copy only this skill to `~/.claude/skills/git-diff-2dot-vs-3dot-merge-safety`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/git-diff-2dot-vs-3dot-merge-safety &&
cp -R "$tmp/plugins/agent-traffic-control/skills/git-diff-2dot-vs-3dot-merge-safety" ~/.claude/skills/git-diff-2dot-vs-3dot-merge-safety &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/git-diff-2dot-vs-3dot-merge-safety` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/git-diff-2dot-vs-3dot-merge-safety` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/git-diff-2dot-vs-3dot-merge-safety &&
cp -R "$tmp/plugins/agent-traffic-control/skills/git-diff-2dot-vs-3dot-merge-safety" ~/.agents/skills/git-diff-2dot-vs-3dot-merge-safety &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/git-diff-2dot-vs-3dot-merge-safety` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/git-diff-2dot-vs-3dot-merge-safety` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/git-diff-2dot-vs-3dot-merge-safety &&
cp -R "$tmp/plugins/agent-traffic-control/skills/git-diff-2dot-vs-3dot-merge-safety" ~/.cursor/skills/git-diff-2dot-vs-3dot-merge-safety &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/git-diff-2dot-vs-3dot-merge-safety` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/wan-huiyan/agent-traffic-control.git --path plugins/agent-traffic-control/skills/git-diff-2dot-vs-3dot-merge-safety
```

Or copy the folder to `~/.gemini/skills/git-diff-2dot-vs-3dot-merge-safety` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/git-diff-2dot-vs-3dot-merge-safety`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/git-diff-2dot-vs-3dot-merge-safety &&
cp -R "$tmp/plugins/agent-traffic-control/skills/git-diff-2dot-vs-3dot-merge-safety" ~/.copilot/skills/git-diff-2dot-vs-3dot-merge-safety &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/git-diff-2dot-vs-3dot-merge-safety` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control.git
```

Then copy `agent-traffic-control/plugins/agent-traffic-control/skills/git-diff-2dot-vs-3dot-merge-safety` into your agent's skills folder as `git-diff-2dot-vs-3dot-merge-safety`. Agents that support SKILL.md read one folder per skill.

## FAQ

### Why does a two-dot diff show files as deleted?

A two-dot diff compares the tips of two trees, so files added to main after the branch point appear as removals because the branch's tree does not contain them yet.

### Which command shows only what a branch actually deletes?

A three-dot diff filtered with --diff-filter=DR and --name-only lists deleted and renamed files relative to the merge base.

### Does an empty deletion list mean no content was lost?

No. The filter only catches removed files, so reverted content can still appear as line removals in the full three-dot diff and should be read directly.

### How do I tell an empty cherry-pick from a real conflict?

An empty pick reports that the working tree is clean with nothing to commit after conflicts are marked fixed, meaning the content already exists on main.

### How do I install Git diff 2dot vs 3dot merge safety in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/git-diff-2dot-vs-3dot-merge-safety to use it in all your projects, or to .claude/skills/git-diff-2dot-vs-3dot-merge-safety in one project. Or install the agent-traffic-control plugin, which includes it: /plugin marketplace add wan-huiyan/agent-traffic-control, then /plugin install agent-traffic-control@wan-huiyan-agent-traffic-control.

### Does Git diff 2dot vs 3dot merge safety run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Git diff 2dot vs 3dot merge safety?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Git diff 2dot vs 3dot merge safety?

The closest alternatives to Git diff 2dot vs 3dot merge safety are Check a stale branch is not undoing newer main work, Git post merge cleanup, Gha PR merge ref shows upstream changes, Code review and Fix merge conflicts.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Check a stale branch is not undoing newer main work](https://ai-powered.com/skills/check-a-stale-branch-is-not-undoing-newer-main-work): Check a stale branch is not undoing newer main work is an open-source agent skill for developer tools.
- [Git post merge cleanup](https://ai-powered.com/skills/git-post-merge-cleanup): Git post merge cleanup is an open-source agent skill for developer tools.
- [Gha PR merge ref shows upstream changes](https://ai-powered.com/skills/gha-pr-merge-ref-shows-upstream-changes): Gha PR merge ref shows upstream changes is an open-source agent skill for developer tools.
- [Code review](https://ai-powered.com/skills/code-review-mattpocock): Code review is an open-source agent skill for developer tools.
- [Fix merge conflicts](https://ai-powered.com/skills/fix-merge-conflicts): Fix merge conflicts is an open-source agent skill for developer tools.
- [Git branch cleanup](https://ai-powered.com/skills/git-branch-cleanup): Git branch cleanup is an open-source agent skill for developer tools.
- [Resolve merge conflicts](https://ai-powered.com/skills/resolve-merge-conflicts): Resolve merge conflicts is an open-source agent skill for developer tools.
- [Git merge](https://ai-powered.com/skills/git-merge): Git merge is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/git-diff-2dot-vs-3dot-merge-safety
