Sweep leaked ad-hoc dev scratch files (check-*.ts, debug-*.ts, test-*-debug.ts, tests/probe-*.test.ts, etc.) into .tmp/ so git status stays clean and token cost per tool call stays low.
Install
npx skillscat add loopdive/js2/scratch-cleanup Install via the SkillsCat registry.
Scratch Cleanup
Find all leaked ad-hoc dev scratch files in /workspace, verify they are not legitimate WIP, move them into the gitignored .tmp/ folder, and verify .gitignore patterns cover future leaks.
When to use
git statusin /workspace shows 20+ untrackedcheck-*,debug-*,test-*,probe-*,run-*files- Starting a new session and inheriting leaked scratch from prior dev agents
- After an OOM or crash where dev worktrees may have spilled files into the main workspace
- Before running
/compactor/session-wrapupto keep the committed state clean
Step 1: Verify /workspace/main
pwd && git branch --show-currentMust be /workspace on main.
Step 2: Survey untracked non-plan files
git status --short | grep '^??' | grep -vE '(plan/|\.claude/|test262$|components/)' | head -60Patterns to sweep (all represent ad-hoc debug/probe scripts):
Root level:
check-*.ts,check-*.mtsdebug-*.ts,debug-*.mtsrun-*.ts,run*.mjs,run-test*.mjstest-*-debug.ts,test-*-main.ts,test-on-main*.tstest-src*.ts,test-wat*.tstest-throws-*.ts,test-full-wat-*.ts,test-disposable-*.ts,test-pr-*.ts
Under tests/:
tests/probe-*.test.tstests/test-*-debug.test.ts,tests/test-*-probe.test.tstests/scope-close-*-debug.test.tstests/regression-check.test.tstests/test-type-mismatch.test.tstests/test-pr*-regressions.test.tstests/*-debug*.test.ts
Preserve (do NOT move):
tests/issue-NNNN*.test.ts— likely real WIP from a dev; check PR queue before movingplan/**— planning docs.claude/memory/**— team memory
Step 3: Check for false positives
Before moving anything, verify the file is NOT referenced by an open PR:
for f in <SUSPECT_FILES>; do
if gh pr list --limit 20 --json files --jq ".[] | select(.files[]?.path==\"$f\") | .number"; then
echo " KEEP: $f referenced by open PR"
else
echo " MOVE: $f"
fi
doneFor tests/issue-NNNN*.test.ts files: additionally check if the issue is currently in-progress and the test file is the dev's WIP (if so, leave it).
Step 4: Ensure .tmp/ exists
mkdir -p .tmpStep 5: Move
mv <FILES...> .tmp/
ls .tmp/ | wc -lStep 6: Verify gitignore covers the patterns
grep -qE '^\.tmp/' .gitignore || echo ".tmp/" >> .gitignoreAlso verify the root-level and tests/ patterns are in .gitignore as a safety net:
grep -E '^/check-\*\.ts|^/debug-\*|tests/probe-\*' .gitignoreIf missing, add them. Reference the current working .gitignore block:
# Dev scratch — ad-hoc probe/debug/repro scripts
.tmp/
/check-*.ts
/check-*.mts
/debug-*.ts
/debug-*.mts
/run-*.ts
/run-*.mts
/run[0-9]*.ts
/run-test*.mjs
/test-*-debug.ts
/test-*-main.ts
/test-on-main*.ts
/test-src*.ts
/test-wat*.ts
/test-throws-*.ts
/test-full-wat-*.ts
/test-disposable-*.ts
/test-pr-*.ts
tests/probe-*.test.ts
tests/test-*-debug.test.ts
tests/test-*-probe.test.ts
tests/scope-close-*-debug.test.ts
tests/regression-check.test.ts
tests/test-type-mismatch.test.ts
tests/test-pr*-regressions.test.ts
tests/*-debug*.test.tsStep 7: Verify clean state
git status --short | head -20Should show only the modified .gitignore (if you updated it) and any legitimate planning/memory edits.
Step 8: Commit
git add .gitignore
git commit -m "chore: scratch cleanup — move leaked dev files to .tmp/
✓
Moved N leaked scratch files from /workspace root and tests/ into the
gitignored .tmp/ folder. Updated .gitignore patterns to catch future
leaks automatically.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>"Only .gitignore needs staging — the moved files are already gitignored and the move itself is invisible to git.
Notes
- Never delete without moving first — the files might contain diagnostic state a dev can recover. Moving to
.tmp/preserves them while getting them out of git's way. - Deleting
.tmp/is OK between sessions — nothing committed depends on it. - Don't move
tests/issue-NNNN*.test.tsblindly — these are often legitimate per-issue test files. Only move if they are clearly*-debugor*-probevariants. - Root cause prevention: ensure CLAUDE.md tells dev agents to write scratch in
.tmp/directly. Pattern-based.gitignoreis a safety net, not a substitute for the convention.