/agent-workflows:host-tidyfrom agent-workflows
Use when a dev host is overloaded, out of memory, or hitting fork/resource limits and stale localnets, orphaned dev daemons, or leftover containers need to be found and cleared safely
Ships in agent-workflows. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Reclaim an overloaded dev host by finding processes and stacks whose owner is gone, then clearing them without touching live work.
The whole skill is one discrimination: orphan vs. active. Getting it wrong in one direction wastes a core for two weeks; getting it wrong in the other destroys someone's running environment. Age alone never decides it — attribution does.
Capture the baseline so the effect is provable afterward:
# macOS
uptime; sysctl -n hw.ncpu hw.memsize
vm_stat | awk '/Pages free/{gsub(/\./,"",$3); printf "free: %.0f MB\n", $3*16384/1048576}'
echo "procs: $(ps -A | wc -l) limit: $(sysctl -n kern.maxprocperuid)"
# Linux
uptime; nproc; free -h
echo "procs: $(ps -e --no-headers | wc -l)"
ps -eo state --no-headers | sort | uniq -c # D-state and Z counts
Then the shape of the load — a name histogram beats a top-N list, because leaks show up as counts, not as one hot process:
ps -Ao comm | sed 's|.*/||' | sort | uniq -c | sort -rn | head -20 # macOS
ps -eo comm --no-headers | sort | uniq -c | sort -rn | head -20 # Linux
Hundreds of postgres, nginx, or runtime processes means a runaway stack,
not a stray process — go to step 2's container half first.
Under severe load the container daemon itself starves. Put explicit
timeouts on every docker/kubectl call, run long sweeps detached, and
never re-issue a hung command — that is piling on, not retrying.
Dev stacks leak in two halves and clearing one leaves the other running:
Host processes — anything reparented to init (PPID 1) after its
launcher died ungracefully:
ps -Ao pid,ppid,etime,%cpu,rss,command | awk '$2==1' \
| grep -iE '\b(bun|node|deno|python[0-9.]*|tilt|vite|esbuild|java|cargo)\b' \
| grep -vE '/Applications/|Cellar|/System/|/nix/store'
Containers and clusters — grouped by project, never by individual name:
timeout 30 docker ps -a --format '{{.Label "com.docker.compose.project"}}|{{.Names}}|{{.Status}}'
timeout 20 docker system df
timeout 20 k3d cluster list # or: kubectl config get-contexts
A supervisor-driven localnet typically owns a compose project and a
cluster + registry. Also check the session multiplexer's own view (e.g.
sox ls) — it records shells and their labels the process table cannot
explain.
For each candidate, find the strongest available evidence. Higher on this list wins; a single hit is enough to classify.
| Evidence | How to read it |
|---|---|
| The stack's own status command | Ask the tool that owns the stack (<project> status, silo status, tilt get). A stack reporting stopped while its containers or cluster still run is an orphan by its own account; one reporting running is live. Cheapest and most authoritative — check it first |
| Owning directory deleted | lsof -a -p <pid> -d cwd (macOS) / readlink /proc/<pid>/cwd (Linux); compose: docker inspect -f '{{index .Config.Labels "com.docker.compose.project.working_dir"}}'. Gone directory → orphan |
| Supervisor recorded an exit | The multiplexer/supervisor lists the session as ended with an exit code while the process still runs → orphan (the directory may still exist — this outranks it) |
| Waiting on a dead endpoint | A poll loop against a port with no listener (lsof -nP -iTCP:<port> -sTCP:LISTEN) → orphan |
| Scratch state already deleted | Temp dir / socket / lock the process was built around is gone → orphan |
| Recent commits in the owning worktree | git -C <dir> log -1 --format='%h %s (%cr)' → active, leave it |
| Live inbound connections | Established sockets on the stack's service ports → active, leave it |
| No owner found | → ambiguous, batch for confirmation. Never promote to orphan by age |
Elapsed time only ranks orphans by cost. A 24-minute stack with a live worktree is active work; a 13-day process with a deleted worktree is waste.
Present the tiers with cost per item before acting. Name explicitly what you are not touching and why — that list is as useful as the kill list.
Prefer the project's sanctioned teardown over hand-killing PIDs and containers:
a stack's own down command knows about halves you have not found yet.
Discover it before improvising (package.json scripts, Makefile, the
project's README):
# example shape: supervisor down -> compose down -> generated runtime cleanup
<pkg-runner> run localnet:down
Read what each teardown level actually does before picking one. Projects
routinely ship a graduated pair — a down that stops the workload but
keeps the cluster, and a clean/purge that adds --delete-cluster. On
a host you are reclaiming, down leaves the multi-GB half you came for
still running. Check the script's own definition rather than guessing from
the verb. Also inspect whether a wrapper expands to compose down -v, volume
removal, database deletion, or reset. Process-cleanup authority does not cover
those effects: use a non-data-deleting level or stop at the data boundary.
Use the project's own package runner, not a habitual one — a repo whose lockfile belongs to a different package manager will refuse to run, and the wrapper's error is about the lockfile, not about your command being wrong.
Stop the supervisor first so it reaps its own children gracefully, then run the teardown. Verify the child daemons and connections actually dropped before moving on. Afterwards sweep for stragglers by project prefix — side-stacks defined in a second compose file are routinely missed:
docker ps -a --format '{{.Names}}' | grep '<project-prefix>'
When no sanctioned teardown wrapper exists, first recover the Compose working directory and config-file labels and invoke Compose against that exact project. If those inputs no longer exist, build and print a project-scoped manifest of every container and network, verify their labels immediately before acting, and remove the group—not a fresh query result and not selected members. This fallback still excludes volumes:
docker inspect -f '{{json .Config.Labels}}' <reviewed-container-id>
docker rm -f <reviewed-project-container-ids>
docker network rm <reviewed-project-network-ids>
Omit -v on docker rm when a container has anonymous volumes you did
not prove disposable — the process dies, the data survives on disk. A local
cluster may carry databases or persistent volumes; delete it only when inventory
proves it disposable or separate authorization names that data-bearing target.
Data reclaim is always opt-in and separate: never fold volume/image pruning, database deletion, or a factory reset into process cleanup. After compute cleanup, inventory retained data without deleting it:
docker volume ls --filter "label=com.docker.compose.project=<project>"
docker volume inspect <volume-name>
docker system df -v
For each exact volume, image set, database, or reset target, report ownership, attachments, size, and what recovery source exists. Ask for one authorization that names those targets and the data loss. Immediately before deletion, re-check identity and attachments; changed evidence voids the authorization. Delete only the approved names—never a fresh query result, wildcard, or global prune—and verify what remains afterward.
A candidate list may come from a process listing (step 2), but each signal goes to one individually verified PID, never to the listing's selector. PIDs get reused: re-confirm identity immediately before signalling, in the same command that signals:
cmd=$(ps -p "$PID" -o command= 2>/dev/null || true)
case "$cmd" in
*<expected-substring>*) kill "$PID" && echo "TERM $PID" ;;
*) echo "SKIP $PID (identity changed: '$cmd')" ;;
esac
Then SIGTERM → verify → SIGKILL only the survivors. A wedged process ignoring SIGTERM is expected, not a surprise.
Before reaping duplicates of a daemon that backs live sessions, prove which instance holds the live socket and exclude it:
lsof -nP <state-dir>/<name>.sock | awk 'NR>1{print $2}' | sort -u
Build the kill manifest by exclusion (dev/build paths in, installed path out), print it, then execute — and re-check the socket afterward.
Re-measure load, free memory, and per-class counts against step 1. State
each count as now (was N).
Load average lags — it is a decaying 1/5/15-minute mean, so a freed core shows up immediately in CPU but slowly in load. Cite the 1-minute number as decaying, not as the result, and never claim a recovery the process counts do not corroborate.
A sweep that does not identify why the host filled up guarantees a repeat. Report the mechanism when the evidence supports one, and file it or point at the existing issue:
etime units before calling a collisionWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub alleneubank/agent-profile --plugin agent-workflows22 skills in this plugin
/chief-of-staffUse when taking, holding, or onboarding a workspace's chief of staff (the human's intake and router above that workspace's repository coordinators), or when deciding whether a finding goes to the human, a coordinator, or an issue./contentUse when authoring or changing a work whose reader is outside the current conversation — product text (labels, messages, errors, notifications, emails, command output), documentation, announcements, a change description, or a brief, prompt, or handoff for another agent. Not for replies in the conversation or incidental one-line messages./coordinatorUse when coordinating agent lanes across hosts or workspaces, starting or resuming a campaign from a tee-up agreement, preparing unattended work, rotating coordinators, or planning a workspace's backlog by theme. Bounded attended implementation needs no coordinator./designUse when deciding how something people or agents use should look, read, or behave before it is built — a new or changed screen, flow, command output, error, tool or skill text, or a piece in another medium — or when a change reaches an established product surface that has no design record./dissolve-docsUse when the user calls a docs cleanup, a campaign has shipped, or the repo has accumulated narrative, planning, status, handoff, or loop docs whose authoritative content belongs in the standing docs (VISION, BRIEF, SPEC, README)./doneUse when claiming a change done, asking for acceptance or a merge, inviting someone to try a build (a bug bash, dogfood run, or visual or design review), requesting a plan or specialist review, or landing reviewed work.