Clean up after your agents.

zap deletes the git worktrees your coding agents leave behind once you’ve merged their work.

Get zap on GitHub
brew install thecloudranger/tap/zap

zap asks before it deletes anything, and only in repos you opt in.
zap runs on macOS and Linux. You can also use go install or a download.

your worktrees fix-login.claude/worktrees auth.claude/worktrees a1f3/my-app~/.codex/worktrees k2p9~/.cursor/worktrees search.worktrees zap scanning… 5 worktrees 3 to zap zappedmerged zappedsquash-merged zappedno commits of its own kept.env inside keptuncommitted changes 1.2 GB freedzap undo restores branches and worktrees

zap in 55 seconds

Agents fill a disk with worktrees, and zap finds and deletes the merged ones.

See what’s stale and why

List every worktree with its status and reason, and dry-run a clean before actually zapping.

$ zap scan --allEvery worktree in every repo under your scan roots, with its status.
~/dev/api  ·  1 linked worktree  ·  target main

  WORKTREE                      BRANCH             AGENT   STATUS  SIZE    DEPS    AGE  ACTIVE  NOTES
  ~/.cursor/worktrees/api/k2p9  cursor-rate-limit  cursor  merged  176 MB  176 MB  4d   4d      -

1 merged  ·  176 MB, 176 MB merged or empty

~/dev/my-app  ·  4 linked worktrees  ·  target main

  WORKTREE                        BRANCH              AGENT   STATUS  SIZE    DEPS    AGE  ACTIVE  NOTES
  ~/.codex/worktrees/a1f3/my-app  d0e8a85             codex   empty   256 MB  256 MB  2d   2d      detached
  .claude/worktrees/auth          worktree-auth       claude  merged  512 MB  512 MB  8d   8d      -
  .claude/worktrees/fix-login     worktree-fix-login  claude  merged  384 MB  384 MB  3d   3d      -
  .worktrees/search               search              -       active  208 MB  208 MB  now  now     dirty(1)

2 merged · 1 empty · 1 active  ·  1.4 GB, 1.2 GB merged or empty

Scanned 2 repositories in 500ms; 2 with linked worktrees. Roots: zap roots
Linked worktrees use about 1.5 GB; 1.3 GB of that is in merged or empty ones.
Agent temp files and transcripts use 251 MB more; see zap map.
The disk has 8.3 GB free of 494 GB.
$ zap explain .claude/worktrees/authEvery check behind one worktree’s status, pass or fail.
~/dev/my-app/.claude/worktrees/auth
  repo     ~/dev/my-app
  branch   worktree-auth @ 957aee3
  target   main (refs/heads/main)

  status   MERGED — merging 957aee3 into main would change nothing

  checks (first ✓ decides)
    ✗ missing      folder exists
    ✗ empty        worktree-auth moved 2 time(s) since creation
    ✗ ancestor     tip 957aee3 is not in main
    ✗ empty-diff   957aee3 has changes not in main
    ✗ cherry       957aee3 has commits whose patches are not in main
    ✓ squash       merging 957aee3 into main would change nothing
    - pr           not asked (use --gh)
    ✗ gone         no upstream branch

  facts
    dirty          no
    locked         no
    size           512 MB freed if removed (512 MB of it dependencies and build output)
    created        8d ago (2026-11-05 15:33)
    last commit    9d ago (2026-11-04 15:32)
    last activity  8d ago (2026-11-05 15:33)
$ zap clean --all --dry-runWhat a clean would delete and what it keeps, before anything changes.
~/dev/api  ·  target main  ·  opted in (.zap)

     WORKTREE                      BRANCH             STATUS  SIZE    WHAT
  ·  ~/.cursor/worktrees/api/k2p9  cursor-rate-limit  merged  176 MB  keep: holds ignored .env, which would be lost

0 to zap · 1 kept · 0 active

~/dev/my-app  ·  target main  ·  opted in (.zap)

     WORKTREE                        BRANCH              STATUS  SIZE    WHAT
  ✓  ~/.codex/worktrees/a1f3/my-app  -                   empty   256 MB  remove worktree
  ✓  .claude/worktrees/auth          worktree-auth       merged  512 MB  remove worktree, delete branch
  ✓  .claude/worktrees/fix-login     worktree-fix-login  merged  384 MB  remove worktree, delete branch

3 to zap · 0 kept · 1 active  ·  frees about 1.2 GB

3 to zap in 1 opted-in repository.

Dry run: nothing was changed. Zapping would free about 1.2 GB.

zap deletes only finished work

Add a .zap file to opt a repo in; zap asks before it deletes.

zap deletes a worktree when it’s

merged
Fast-forward, merge, squash or rebase.
empty
No commits of its own.
missing
Its folder is gone.

zap keeps a worktree when

  • it has uncommitted or hidden changes
  • it holds an ignored .env or key
  • an editor, shell or agent has it open
  • it’s locked or on a protected branch
  • you touched it in the last day

zap undo

zap saves each branch tip under refs/zap/backup/ first. You lose ignored files like node_modules.

$ zap undoBrings back the branches and worktrees from the last clean.
Restoring run 20261113T123401Z

  ↺ ~/.codex/worktrees/a1f3/my-app
      re-added worktree
  ↺ ~/dev/my-app/.claude/worktrees/auth
      recreated branch worktree-auth
      re-added worktree
  ↺ ~/dev/my-app/.claude/worktrees/fix-login
      recreated branch worktree-fix-login
      re-added worktree

Files git ignores (node_modules, build output, caches) were not restored.

Watch your disk

zap map shows what agents keep on disk, including transcripts and temp sessions. zap check exits 3 when you pass your limits, and zap schedule on runs that check every day and notifies you.

$ zap mapWhat coding agents keep on disk, drawn to scale.
Coding agents keep 1.8 GB on this disk. It has 4.4 GB free of 494 GB.

  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████████▓▓▓▓▓░░░░░
  ▒ merged or empty worktrees 1.3 GB   █ worktrees in use 208 MB   ▓ temp sessions 115 MB   ░ transcripts 136 MB

  Worktrees                    1.5 GB  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████  1.3 GB merged or empty
    Claude Code                896 MB  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒               2 worktrees, 896 MB merged or empty
    Codex                      256 MB  ▒▒▒▒▒                           1 worktree, 256 MB merged or empty
    other                      208 MB  ████                            1 worktree
    Cursor                     176 MB  ▒▒▒                             1 worktree, 176 MB merged or empty

  Claude Code temp sessions    115 MB  ▓▓                              10 sessions in ~/tmp/claude-501
    ~/dev/my-app                60 MB  ▓                               5 sessions
    ~/dev/api                   40 MB  ▓                               3 sessions
    ~/dev/web                   15 MB  ▓                               2 sessions

  Codex transcripts             90 MB  ░░                              1 session, needed to resume them

  Claude Code transcripts       46 MB  ░                               10 sessions, needed to resume them
    ~/dev/my-app                24 MB  ░                               5 sessions
    ~/dev/api                   16 MB  ░                               3 sessions
    ~/dev/web                  6.0 MB  ░                               2 sessions

Run zap to see which merged and empty worktrees it can delete.
zap leaves temp sessions and transcripts on disk.
$ zap checkOne line on merged or empty worktrees and free space. Exits 3 past your limits.
4 merged or empty worktrees use 1.3 GB. The disk has 4.4 GB free of 494 GB.
Agent temp files and transcripts use 251 MB more; see zap map.
Run zap to see which ones it can delete.

Agent folders zap knows

zap tells you which agent made each worktree from where it lives.

Agents can use zap too, through its skill file.

AgentWorktrees in
Claude Code.claude/worktrees
Codex~/.codex/worktrees
Cursor~/.cursor/worktrees
Conductor~/conductor/workspaces
T3 Code.t3/worktrees

Install

zap is one binary for macOS and Linux.

brew install thecloudranger/tap/zap
go install github.com/thecloudranger/zap/cmd/zap@latest

You can also download it from the latest release.