We ran
git stashandgit stash popunder a running headless Claude Code session. When the stash removed the whole.claudefolder, Claude Code 2.1.319 still answered "Unknown skill" for our probe skills and commands 29 seconds after the pop, in both runs. 2.1.322 had them back by the 15-second check in both runs. When only the new skill folders went away and.claude/skillsitself stayed, both versions recovered by the 15-second check. Our custom agent never went missing on either version, even while its file was gone.
Why a stash happens under a running session
Several Claude Code sessions and their subagents share one git checkout in our agent repo, and we do not use worktrees. That means one session can be in the middle of a turn while another one runs git commands in the same folder.
The case that worried us is conflict resolution. Our repo's rule says that when a rebase conflict has to be resolved by hand while other sessions have uncommitted changes in the tree, those changes are moved aside first with git stash push -- <their paths> and brought back with git stash pop once the conflict is resolved. If one of those uncommitted changes is a new skill that another session is still writing, the stash deletes its folder from disk for a minute or two, and the session that owns it is still running.
The skills page of the Claude Code docs says the project .claude/skills/ folder is watched, and that Claude Code "picks up the change within the current session, without a restart". The 2.1.321 changelog then has a line for exactly our worry: project skills, commands and agents "staying missing after their folder was removed and came back mid-session", with git stash given as the example. A changelog line tells you a bug existed. It does not tell you how long the gap is, which folder has to vanish, or whether agents behave like skills. So we measured it.
How we measured
Each run used a fresh git repository in a scratch folder with nothing in it but a README and the probe files. The probe files were:
- five skills,
probe-atoprobe-e, each aSKILL.mdthat only asks for a fixed reply - five commands,
cmd-atocmd-e, as files in.claude/commands/ - one agent,
stash-agent, in.claude/agents/, whose whole prompt is a fixed reply
Every skill and command is called exactly once in a run. That matters: if the same skill were checked twice, the second check could be answered from what the session had already loaded, and we would be measuring the session's memory instead of the folder.
We used two layouts. In the whole layout, nothing under .claude was committed. All probe files were staged but not committed, so git stash push -- .claude removed the .claude folder completely, and git stash pop recreated it. In the leaf layout, .claude/skills, .claude/commands and .claude/agents each already held one committed file. Only the probe files were new, so the stash removed the probe skills' own folders and the probe files, while the parent folders stayed on disk.
Each run was one headless claude -p session on Sonnet 5.5, reading only the project's own settings, with the tools limited to Skill, Bash and Agent. The prompt listed 20 steps in a fixed order:
- check
probe-a,cmd-aand the agent -
git stash push -- .claude, then wait 10 seconds - check
probe-b,cmd-band the agent -
git stash pop, then immediately checkprobe-c,cmd-cand the agent - wait 10 seconds, check
probe-d,cmd-dand the agent - wait 10 seconds, check
probe-e,cmd-eand the agent
A skill or command check is one Skill tool call: it either returns "Launching skill" or fails with "Unknown skill". An agent check is one Agent tool call, and we read the subagent's own transcript afterwards to see whether it ran with our agent's prompt. All times below come from the timestamps in the session transcript, measured from the moment the pop's Bash call returned.
We compared 2.1.319 and 2.1.322. The fix is listed under 2.1.321, and 2.1.320 was never published to npm, so 2.1.319 is the last release before the fix. Both versions were run from binaries already on the machine. We did two runs of the whole layout and one run of the leaf layout on each version: six runs in total.
Two snags from our first attempt are worth knowing if you repeat this. The machine's global gitignore lists .claude, so a plain git add .claude skipped every probe file without an error, and the stash then had nothing to remove. We had to stage them with git add -f. And the Bash tool refused a standalone sleep 30 in a 2.1.322 session, with a message suggesting a polling loop instead. sleep 10; git status --short went through, so our waits are 10 seconds each.
What we saw
| Layout | Version | Runs | During the stash | About 1 s after pop | About 15 s after pop | About 30 s after pop |
|---|---|---|---|---|---|---|
| whole | 2.1.319 | 2 | skills and commands unknown | unknown | unknown | unknown |
| whole | 2.1.322 | 2 | skills and commands unknown | unknown | loaded | loaded |
| leaf | 2.1.319 | 1 | skills and commands unknown | unknown | loaded | loaded |
| leaf | 2.1.322 | 1 | skills and commands unknown | unknown | loaded | loaded |
Commands behaved exactly like skills in every cell: a command file in .claude/commands/ disappeared and came back at the same check as the skill next to it.
On 2.1.319 with the whole layout, the skills and commands never came back while we watched. The last skill check came 29 seconds after the pop in both runs, and it still failed with "Unknown skill" although ls and git status in the steps before had listed every file. On 2.1.322 the same layout recovered between the 1-second check and the 15-second check, in both runs.
The check right after the pop failed on every run, on both versions and in both layouts. Even on the fixed version, the session needs a moment to notice that the files are back. Our checks were about 14 seconds apart, so all we can say is that the gap on 2.1.322 was more than 1 second and less than 15.
The agent was the surprise. All 30 Agent calls across the six runs launched stash-agent, and every one of those subagents answered with the fixed reply from our agent file. That includes the six calls made during the stash, when .claude/agents/stash-agent.md was not on disk at all. In these headless sessions, on both versions, the agent definition that was loaded at the start stayed usable after its file was deleted.
What this means for a shared checkout
The difference between the two versions only showed up in the whole layout, when the parent folder itself disappeared. When only a skill's own folder went away and came back, 2.1.319 already picked it up again by the 15-second check. So the risk on older versions is narrower than the changelog line first sounds: it is the case where the whole .claude folder, or the whole .claude/skills folder, leaves the disk.
In our own repo, .claude/skills holds committed skills, so a stash there removes only the new skill's own folder. That is the leaf layout, which recovered on both versions. The whole layout is what a repository hits when nothing under .claude is committed: for example, a repo where .claude is new and not yet committed and is stashed with git stash --include-untracked, or a branch switch to a branch that has no .claude folder and back again. We measured only the stash, not the branch switch.
Three practical points came out of the runs:
- After a
git stash pop, do not call a skill in the same breath. Every check made a second after the pop failed, on both versions. A script that pops and then runs a skill immediately can get "Unknown skill" even on 2.1.322. - On a version before 2.1.321, if the whole folder went away, waiting does not help. In our runs nothing came back within 30 seconds. The docs describe
/reload-skillsfor a skills folder that did not exist when the session started. That is the first thing we would try in an interactive session, but we did not test it, because our runs were headless. - A deleted agent can still be launched. For a stash this is convenient, since the agent keeps working while its file is away. It also means that deleting an agent file mid-session does not stop a running headless session from using it. The changelog line names agents too, so the interactive menu may behave differently; we only tested the Agent tool in
claude -psessions.
What we did not measure
Each version got three runs, which is enough to see a consistent pattern but not to rule out timing differences between machines. All runs used Sonnet 5.5 as the main model and a small scratch repository. We did not test sessions started inside a worktree, which the changelog line also mentions, because our repo does not use worktrees. We did not test skills under ~/.claude/skills or in a folder added with --add-dir. And our probe checks were 14 seconds apart, so the recovery time on 2.1.322 is a bracket, not a number.
Have you seen Claude Code lose a skill or command in the middle of a session, after a stash, a branch switch or something else? Tell us in the comments below what removed the folder and which version you were on, and we will compare it with the six runs here.


Top comments (0)