Claude Code Field Notes · Lesson 5 of 6

A registry reports what it was told; a process table reports what is

Lesson 5 of six in Claude Code Field Notes: Running AI Coding Agents in Production, drawn from operating more than twenty live software surfaces with Claude Code.

During a cleanup of finished agent workspaces, the session registry reported several as not running. They had live processes inside them with child processes actively writing files. Acting on the registry would have deleted a running agent's workspace mid-edit.

The check that works asks the operating system, not the bookkeeping:

lsof -d cwd 2>/dev/null | grep "<path>"

Two things make this worse than it sounds. Workspaces go live while you audit them, so a directory that was idle ten minutes ago is not evidence about now; re-check immediately before deleting. And squash-merged branches look unmerged: commit ancestry shows work ahead of main even when the content already landed, because main moved on. Use git cherry or match commit subjects rather than trusting ancestry, or you will keep dead workspaces and, worse, convince yourself that merged work was lost.