Skip to main content

Preview worktree branches from your main checkout while safely stashing your working state.

Project description

⚡ flash

Preview worktree branches from your main checkout while seamlessly stashing your working state.

flash cli

Why

Worktrees are great for parallelizing work, but your dev environment — backend servers, locally running frontend, etc — lives in your main checkout. When you need to test changes on a worktree, you're stuck doing a manual stash-checkout-test-restore dance, carefully tracking not to throw away diffs on either branch.

flash does the whole dance in one command and tracks every step so nothing gets lost.

Inspired by Conductor's Spotlight.

Install

uv tool install worktree-flash        # or pipx install worktree-flash

Or from source:

git clone https://github.com/WillTwait/flash.git
uv tool install ./flash

For development (changes reflected immediately):

git clone https://github.com/WillTwait/flash.git
cd flash
uv run flash              # runs from source, no install step

Add a shell alias for convenience: alias flash="uv run --project ~/path/to/flash flash"

Requires Python 3.10+.

Commands

Command Alias Description
flash into [name] flash i Switch to a worktree's branch (or open fzf picker)
flash out flash o End flash, restore original branch + stash
flash out --apply End flash, send changes to worktree first
flash out --discard End flash, throw away changes
flash apply flash a Send changes to worktree without ending flash
flash sync flash s Pull worktree changes into canonical checkout
flash diff flash d Show unapplied and unsynced changes
flash diff -v Show full diff
flash status flash st Show current flash state
flash update flash u Check for a newer version

Typical workflow

flash workflow demo
flash into my-worktree    # stash, checkout worktree branch
# run server, test, poke around, fix things, commit
flash sync                 # pull latest worktree changes into canonical checkout
flash diff                 # see unapplied + unsynced changes
flash apply                # cherry-pick commits + sync files back to worktree
# keep testing
flash diff -v              # full diff of all changes
flash diff --incoming      # only show unsynced worktree changes
flash out                  # restore original branch, pop stash, clean up

Details

flash into — switch your checkout to a worktree's branch

  1. Stash uncommitted changes (tracked by SHA)
  2. Create and checkout a temp branch at the worktree's HEAD
  3. Copy the worktree's uncommitted changes into your checkout
  4. Write .flash/state.json to track everything

Pass a worktree name or branch, or omit for an fzf picker.

flash apply — send your changes back to the worktree

  1. Back up the worktree's state via git stash create
  2. Clean the worktree for a conflict-free cherry-pick
  3. Cherry-pick new commits into the worktree's history
  4. Copy uncommitted file changes to the worktree

Safe to run multiple times. If anything fails, the backup stash SHA is printed for recovery.

flash sync — pull worktree changes into the canonical checkout

  1. Diff uncommitted changes in the worktree against HEAD
  2. Copy changed files into the canonical checkout

Useful when you've made changes directly in the worktree (e.g. from another tool or editor) and want them reflected in your canonical checkout.

flash diff — show unapplied and unsynced changes

  1. Shows both directions: unapplied (what apply would send) and unsynced (what sync would pull)
  2. Defaults to a diffstat summary; use --verbose/-v for the full diff
  3. Use --incoming/-i to show only unsynced worktree changes

flash out — restore your original branch

  1. Prompt [a]pply / [d]iscard if you have unapplied changes (shows diffstat)
  2. Checkout your original branch
  3. Delete the temp branch
  4. Pop your stash by SHA
  5. Remove .flash/ entirely

Usage with Claude Code

Add this to your project's CLAUDE.md so Claude understands how to use flash:

## Flash (worktree previewing)

`flash` is installed and available for previewing worktree branches from the main checkout.

- `flash into <name>` — switch to a worktree branch (stashes current work automatically)
- `flash out --discard` — restore original branch (use `--apply` to send changes back to worktree)
- `flash apply` — send unapplied changes to the worktree without ending the flash
- `flash sync` — pull unsynced worktree changes into the canonical checkout
- `flash diff` — show unapplied and unsynced changes (`-v` for full diff, `--incoming` for worktree only)
- `flash status` — check current flash state (shows unapplied/unsynced summary)

When you need to test or review code from a worktree, use `flash into` instead of manually
checking out branches. Always `flash out` when done.

Safety

Risk Mitigation
Losing stashed changes Tracked by SHA, not index position
Losing worktree state on apply git stash create backup before any destructive op
Double flash Refused if already flashed in
Branch conflict with worktree Uses flash/<branch> temp branch
Interrupted mid-operation State file has everything needed for manual recovery
Non-interactive (CI/agents) Defaults to --discard with a warning

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

worktree_flash-0.2.1.tar.gz (305.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

worktree_flash-0.2.1-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file worktree_flash-0.2.1.tar.gz.

File metadata

  • Download URL: worktree_flash-0.2.1.tar.gz
  • Upload date:
  • Size: 305.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for worktree_flash-0.2.1.tar.gz
Algorithm Hash digest
SHA256 80046ba374e8a99e10f05dd5b014ce32ab8b4e20695ee0f80e789d95a31e6e26
MD5 4371532d9a8f6d00beda38f5e44f0aed
BLAKE2b-256 0f0cd33efdf00a4c8df84b947b9f676569ec2e11c2b80cc0c2f114342c5628cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for worktree_flash-0.2.1.tar.gz:

Publisher: publish.yml on WillTwait/flash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file worktree_flash-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: worktree_flash-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for worktree_flash-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 547c66c68cf213fe4564a868e4bb70b6eb46167ab45329ed0f715310db2b8ed1
MD5 3e780a1fd8900da02b1b632ec9d1f281
BLAKE2b-256 5e337327248adf590c5a13824d5fe424f95628ef858bc695436ea1cc88cb048e

See more details on using hashes here.

Provenance

The following attestation bundles were made for worktree_flash-0.2.1-py3-none-any.whl:

Publisher: publish.yml on WillTwait/flash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page