Feature request: `--exclusive` flag for `claude --resume` (per-sid lock)

Resolved 💬 2 comments Opened Jun 15, 2026 by dennisgregory-lab Closed Jun 19, 2026

When claude --resume <sid> is invoked while another process is already running with the same sid, both processes operate on the same transcript file and the same working tree, leading to race conditions on transcript appends and branch checkouts.

This is observable today in third-party shells like siteboon/claudecodeui (CloudCLI), which spawn resume wrappers without checking for an existing live process — see https://github.com/siteboon/claudecodeui/issues/883 for the shell-side report. The shell-side fix is appropriate, but the CLI offers no primitive to enforce mutual exclusion, so every shell that wraps Claude Code has to reinvent the lock.

Proposal

Add an --exclusive (or --lock) flag. When set, claude --resume <sid> --exclusive acquires a flock on an internal per-sid lockfile and exits with a non-zero status + clear message if the lock is held.

Why opt-in

Some debugging workflows legitimately want concurrent read-only resumes; opt-in preserves that capability while letting shells (and scripts that spawn agents) request safety.

Bonus

A successful lock acquisition also gives any caller confidence that their session won't be silently raced — useful in CI / automation contexts where this class of bug is currently undetectable from the caller's side.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗