OpenParable
Skip to content
← Back to skills

Remote Diff

Testing & Quality
remote-diff

Remote Diff is an Agent Skill for testing & quality published in the ryanb/dotfiles repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Compare local branch changes against the remote branch to detect rebase/merge mistakes.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/ryanb/dotfiles/blob/HEAD/claude/skills/remote-diff/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/remote-diff, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Remote Diff

Compare local branch changes against the remote branch to detect rebase/merge mistakes.

Step 1: Determine base branch

Determine the base branch in this order:

  1. Use $ARGUMENTS if the user specifies a branch
  2. Use the tracked parent from git config branch.$(git branch --show-current).parent, if set and it still resolves to a commit
  3. Use bin/base-branch if the script exists and is executable
  4. Fall back to develop

Step 2: Check prerequisites

Verify the upstream tracking branch exists:

git rev-parse --verify @{u}

If this fails, report that there's no remote branch to compare against and stop. The user needs to push their branch first.

Ensure the tmp directory exists:

mkdir -p tmp

Step 3: Generate and compare diffs

Fetch the latest remote refs, generate both diffs with zero context lines and ignoring whitespace changes, strip metadata lines, then compare:

git fetch origin

git diff -b --unified=0 <base-branch>...HEAD > tmp/local_branch_diff.patch
git diff -b --unified=0 origin/<base-branch>...@{u} > tmp/remote_branch_diff.patch

grep -v -E '^(index |@@ |diff --git)' tmp/local_branch_diff.patch > tmp/local_stripped.patch
grep -v -E '^(index |@@ |diff --git)' tmp/remote_branch_diff.patch > tmp/remote_stripped.patch

diff tmp/local_stripped.patch tmp/remote_stripped.patch > tmp/diff_comparison.patch || true

Step 4: Analyze results

Read tmp/diff_comparison.patch.

If it's empty, report: Clean rebase — no issues detected. The local and remote branches make identical code changes relative to the base branch.

If there are differences, read the relevant source files for context and report:

Interpreting differences

Any difference warrants review. Read the source files to assess each one.

Signs of trouble:

  • A + line present in the remote diff but missing from local → an addition was lost during rebase
  • A - line present in the remote diff but missing from local → a deletion was lost, meaning removed code came back
  • Lines present only in the local diff could be conflict resolution or accidental — verify by reading the code

Report format

For each difference:

  • What changed — which file and what code differs
  • Remote version — what the remote branch had
  • Local version — what the local branch has
  • Assessment — whether this looks intentional (e.g., correct conflict resolution adapting to renamed code) or suspicious (e.g., lost code, accidental reversion, duplicated changes)

Summary

  • Overall assessment: clean rebase or needs attention
  • Any lost or accidentally reverted changes
  • Any suspicious conflict resolutions

Step 5: Clean up

rm -f tmp/local_branch_diff.patch tmp/remote_branch_diff.patch tmp/local_stripped.patch tmp/remote_stripped.patch tmp/diff_comparison.patch