Skip to main content
skill CX Codex

comparing-branches-visually — Claude Code skill: visual branch diff

Checks out two branches in separate worktrees, runs both dev servers on different ports, screenshots the same pages and reports before/after.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add spencerpauly/awesome-cursor-skills --skill comparing-branches-visually -a claude-code
Open on GitHub

What comparing-branches-visually does

Reach for this skill when a UI change needs a before-and-after. It adds a git worktree for the base branch and starts that branch's dev server on a second port, while your current branch keeps its own. The agent then lists changed files with git diff main --name-only, filters components and styles, and maps files to routes: app/dashboard/page.tsx becomes /dashboard.

For every affected page it navigates to the base branch URL, saves a screenshot as "before", switches to the current branch port and saves "after". The report puts both images side by side with a note on what moved — a shorter header, repositioned nav links. Cleanup is one command: git worktree remove.

Keep the viewport identical across shots. The skill suggests starting at 1280×800 and adding 375px for mobile-first work. If the app sits behind auth, log in on both ports first, or every screenshot will show the login page. Port 3001 for the base branch is set by hand, so a busy port breaks the server step.

What it helps with

  • show a UI change before and after
  • compare two branches' layouts without switching back and forth
  • collect screenshots of changed pages for a PR description
  • check whether the layout breaks at mobile width
  • find which pages a component change touched

Example prompts for the agent

  • Visually compare feature/redesign-header against main and show before/after screenshots
  • Run both branches in worktrees and screenshot /dashboard and /settings
  • Produce a visual diff of my changes and add it to the PR description

How to install comparing-branches-visually

1Skills CLI (Vercel)

npx skills add spencerpauly/awesome-cursor-skills --skill comparing-branches-visually -a claude-code

2Manually: put the files in place

~/.claude/skills/comparing-branches-visually/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/comparing-branches-visually/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about comparing-branches-visually

How do I install comparing-branches-visually in Claude?

Run npx skills add spencerpauly/awesome-cursor-skills --skill comparing-branches-visually -a claude-code. The skill file lands at ~/.claude/skills/comparing-branches-visually/SKILL.md.

What does comparing-branches-visually do?

It runs the base and current branches at the same time, starts their dev servers on different ports, screenshots the same pages and returns a report with before and after pairs.

What does the skill need to work?

A free port for the base branch dev server, and a login on both ports if the app requires auth. Screenshots come from browser_navigate and browser_take_screenshot.

Source text

SKILL.md · CC0-1.0
---
name: comparing-branches-visually
description: Check out two branches in separate worktrees, start both dev servers on different ports, screenshot the same pages, and produce a visual diff.
user-invocable: true
---

# Comparing Branches Visually

Create a visual before/after comparison of UI changes between two branches.

## Workflow

### 1. Set Up Two Worktrees

Use `best-of-n-runner` subagents or git worktrees to run both branches simultaneously:

```bash
# Create a worktree for the base branch
git worktree add /tmp/branch-compare-base main

# The current working directory has the feature branch
```

### 2. Start Both Servers

Start the base branch server on a different port:

```bash
# In the base worktree
cd /tmp/branch-compare-base && PORT=3001 npm run dev

# Current branch is already on the default port (3000)
```

### 3. Identify Pages to Compare

Determine which pages are affected by the changes:

```bash
git diff main --name-only | grep -E '\.(tsx?|jsx?|vue|svelte|css)'
```

Map changed files to their routes (e.g. `app/dashboard/page.tsx` → `/dashboard`).

### 4. Screenshot Both Versions

For each affected page:

1. `browser_navigate` to `http://localhost:3001/<page>` (base branch)
2. `browser_take_screenshot` → save as "before"
3. `browser_navigate` to `http://localhost:3000/<page>` (feature branch)
4. `browser_take_screenshot` → save as "after"

### 5. Report

Present the comparison:

```
Visual Diff: feature/redesign-header vs main

/dashboard:
  Before: [screenshot from main]
  After:  [screenshot from feature branch]
  Changes: Header height reduced, nav links repositioned, new avatar dropdown

/settings:
  Before: [screenshot]
  After:  [screenshot]
  Changes: No visual differences detected
```

### 6. Clean Up

```bash
# Stop the base branch server
# Remove the worktree
git worktree remove /tmp/branch-compare-base
```

## Tips

- Test at a consistent viewport size (1280×800 is a good default)
- For mobile-first changes, also compare at 375px width
- If the app requires auth, log in on both ports first
- This pairs well with `screenshotting-changelog` for PR descriptions

© spencerpauly · CC0-1.0 · spencerpauly/awesome-cursor-skills

Similar skills

All skills for Git and GitHub →

From the same set59

converting-css-modules-to-tailwind Moves one component off CSS Modules and onto Tailwind utility classes, then removes the module file and its import. CX Codex +1 392installs generating-images This skill generates and edits images through the OpenAI Image API on gpt-image-2. Handy when you need an OG banner, an icon or a mockup without leaving the agent chat. CX Codex +1 388installs adding-error-tracking This skill wires Sentry into a web app: error tracking, performance traces and source maps. Useful when you want crash reporting without hand-rolling the config. CX Codex +1 386installs tailing-build-output Monitors build output in real time, catches errors as they stream, and patches source files before Webpack, Turbo, or Docker finishes. CX Codex +1 384installs incident-response Systematic playbook for handling production outages: triage severity levels, execute quick mitigations, coordinate updates, and generate blameless postmortems. CX Codex +1 378installs adding-auth A skill that walks the agent through adding authentication to a web app with NextAuth.js: OAuth providers, sessions and protected routes. CX Codex +1 379installs switching-projects Switches the active workspace directory in Cursor to another repo during a session. Useful when you need to jump between projects without opening a new window. CX Codex +1 376installs adding-analytics Guides the AI agent in setting up PostHog analytics, page view tracking, feature flags, and session replay across web apps. CX Codex +1 371installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor