Feature Request: Option to disable auto-stash on session crash/teleport
Summary
Claude Code automatically runs git stash when a session crashes or during Teleport branch switches. This silently destroys uncommitted work in multi-agent environments where multiple Claude instances share a git worktree.
Problem
In our setup, we run a supervisor agent that periodically restarts. Each restart triggers Claude Code's auto-stash mechanism, which:
- Runs
git addon all untracked files - Runs
git stash push --message "..."on the entire working tree - Silently removes all uncommitted changes from the working tree
In a single session this is fine. In a multi-agent team where agents share a worktree, this is catastrophic:
- Today alone, 5 supervisor crashes created 5 auto-stash entries that wiped 4 research documents, 969 lines of evolution framework code, and 104 files of changes
- The stash entries are invisible to other agents — they see a clean working tree and assume the work was never done
- The
auto-stashmessage template (auto-stash: agent {role} ({sessionId}) crashed at {ts}) is injected by the CC SDK session teardown, not by our code
Evidence
stash@{0}: On Human-ui: auto-stash: agent supervisor (...) crashed at 2026-06-07T14:24:31.472Z
stash@{1}: On Human-ui: auto-stash: agent supervisor (...) crashed at 2026-06-07T14:13:17.359Z
stash@{2}: On Human-ui: auto-stash: agent supervisor (...) crashed at 2026-06-07T13:46:46.883Z
...24 total entries across 6 branches spanning 5/15-6/07
The stash function gr8 in cli.js:
gr8 = async (q) => {
let K = q || `Claude Code auto-stash - ${new Date().toISOString()}`;
let {untracked: _} = await Q38();
if (_.length > 0) await a8(h7(), ["add", ..._]); // stages ALL untracked files
let {code: Y} = await a8(h7(), ["stash", "push", "--message", K]);
return Y === 0;
}
Requested Solution
Add a configuration option to disable or replace auto-stash behavior:
// ~/.claude/settings.json
{
"git": {
"autoStash": false // or "log-only"
}
}
false: On crash, log dirty state but do NOT stash. Leave working tree dirty (visible, not hidden)."log-only" (default for safety): Same as false but also write a .claude/crash-dirty-state.log with git status output.
This follows the principle that visible dirty state is better than invisible stash — other agents and users can see the uncommitted changes and decide what to do.
Workaround
We're adding a heartbeat-based cleanup in our daemon that detects auto-stash entries and pops them, but this is reactive and allows a window where the stash exists and other agents see a clean tree.
Environment
- Claude Code CLI (latest, via npx)
- macOS, multi-agent team via Aha SDK
- Git worktree-based setup with shared working directory
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗