SafeDisk AI

AI agent storage incident

AI Agent Inotify Watch ENOSPC On Linux

If an AI coding extension makes VS Code or a remote Linux session report ENOSPC, No space left on device, or OS file watch limit reached, first prove whether the limit is inotify watches, not disk bytes. Large generated trees like node_modules, .next, cdk.out, logs, data folders, and agent worktrees can exhaust watcher budgets even when df -h looks fine.

AI storage deletion judgment

Find what the AI tool can delete.

Copy the read-only check first. If the output still needs judgment, leave your email and we send the free SafeDisk AI deletion trial step only when the agent cache or session state needs review.

Add command output optional

Free trial step. We reply first with a delete / confirm / protect judgment or one read-only detail we still need.

See sample result Ask AI about one file

Confirm It Is Watch Exhaustion

Classic disk-full cleanup starts with byte usage. Inotify exhaustion starts with process ownership: which process owns the watches, how many watches it has, and whether excluded generated directories are still being watched.

Read-only first pass

Count watches and attribute them to processes.

These checks read Linux proc metadata only. They do not print source files, prompts, or private file contents.

echo "inotify limits"
sysctl fs.inotify.max_user_watches fs.inotify.max_user_instances 2>/dev/null

echo "total watches"
sudo bash -c 'total=0; for f in /proc/[0-9]*/fdinfo/*; do n=$(grep -c "inotify wd:" "$f" 2>/dev/null || true); total=$((total+n)); done; echo "$total"'

echo "top watcher owners"
for pid in $(find /proc/*/fd -lname anon_inode:inotify 2>/dev/null | sed 's#/proc/##; s#/fd/.*##' | sort -u); do
  watches=$(grep -h "inotify wd:" /proc/$pid/fdinfo/* 2>/dev/null | wc -l)
  comm=$(cat /proc/$pid/comm 2>/dev/null)
  cmdline=$(tr "\0" " " < /proc/$pid/cmdline 2>/dev/null | cut -c1-220)
  printf '%8s %7s %-20s %s\n' "$watches" "$pid" "$comm" "$cmdline"
done | sort -nr | head -20

Separate Watch Budget From Disk Cleanup

Raising fs.inotify.max_user_watches can be a temporary workaround, but it does not fix an extension that recursively watches generated output. Safe triage separates four buckets:

  1. Generated trees: node_modules, .next, dist, build, cdk.out, coverage output, mobile build folders, and test artifacts.
  2. Agent runtime state: .claude/worktrees, .sandcastle/worktrees, hidden agent session folders, transcripts, and logs.
  3. Git internals: .git/objects, packed refs, worktrees, and nested repositories.
  4. User work: source files, active branches, local data, credentials, and anything not clearly rebuildable.
Workspace histogram

Find huge generated trees without reading file contents.

Run this from the workspace root. It helps decide which paths should be excluded before a watcher is allocated.

echo "top immediate directories by apparent size"
du -xhd1 . 2>/dev/null | sort -h | tail -30

echo "top known generated directories by file count"
for dir in node_modules .next dist build cdk.out logs data coverage .claude .sandcastle .git; do
  [ -e "$dir" ] || continue
  count=$(find "$dir" -xdev -type f 2>/dev/null | wc -l)
  size=$(du -xsh "$dir" 2>/dev/null | awk '{print $1}')
  printf '%10s files  %8s  %s\n' "$count" "$size" "$dir"
done | sort -nr

Fix Criteria For The Extension Or Tool

Do Not Delete First

Free AI deletion trial

Need a delete / confirm / protect answer for AI tool files?

Submit the form first; the command output or one-line agent storage symptom can follow. We check whether free guidance is enough before asking for the free SafeDisk AI deletion trial.

Add output optional

Start with email. Output can follow after the first reply.