scratch-cleanup

A cleanup routine for moving ad-hoc debug and test files into a temporary, ignored folder named .tmp/.

In plain words
What is it for?
It helps find leaked check, debug, run, test, and probe files, confirm they are not real work, move them to .tmp/, and check that .gitignore will hide future leaks.
Why use it?
It keeps accidental scratch files out of git status and reduces clutter when starting or ending a coding session.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/loopdive/js2/scratch-cleanup
Any agent
npx skills add loopdive/js2 --skill scratch-cleanup
Clone the repo
git clone --depth 1 https://github.com/loopdive/js2

Made for: Claude Code, Codex.

Per session 57 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,376 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00057 $0.01376
Opus 5 $0.00028 $0.00688
Sonnet 5 $0.00011 $0.00275
Haiku 4.5 $0.00006 $0.00138

Measured 2d ago against content hash 317f61ae1ad3, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

scratch-cleanup scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/scratch-cleanup/SKILL.md · 159 lines

How it starts

The opening of the file, as written. The whole thing — 159 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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 status in /workspace shows 20+ untracked check-*, 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 /compact or /session-wrapup to keep the committed state clean

Step 1: Verify /workspace/main

pwd && git branch --show-current

Must be /workspace on main.

Step 2: Survey untracked non-plan files

git status --short | grep '^??' | grep -vE '(plan/|\.claude/|test262$|components/)' | head -60

Patterns to sweep (all represent ad-hoc debug/probe scripts):

Root level:

  • check-*.ts, check-*.mts
  • debug-*.ts, debug-*.mts
  • run-*.ts, run*.mjs, 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

Under tests/:

  • 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.ts

Preserve (do NOT move):

  • tests/issue-NNNN*.test.ts — likely real WIP from a dev; check PR queue before moving
  • plan/** — 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
done

Read the full file on GitHub · 159 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 159 lines · 57 tokens per session scan A 317f61ae1ad3

Subscribe to this mod's changes

scratch-cleanup is a skill published in the GitHub repository loopdive/js2 (59 stars, last pushed 2d ago), licensed Apache-2.0. It adds 57 tokens to every session and 1,376 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.