Skip to main content
Agent skill

Scratch Cleanup

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.

Get started

Get the complete skill folder, including its scripts and reference files.

When to use this skill

Use Scratch Cleanup when an AI agent needs a reusable SKILL.md workflow for this job: 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.

When not to use it

Skip Scratch Cleanup when the task is outside the coding category, or when a more specific skill in this directory already covers the same workflow with clearer triggers.

How to install

Where will you use it?

Install scope
Claude Code folder setup
mkdir -p ~/.claude/skills/scratch-cleanup
# Save SKILL.md to ~/.claude/skills/scratch-cleanup/SKILL.md
  1. Claude Code personal install: place the skill and its bundled files at ~/.claude/skills/scratch-cleanup/SKILL.md. For a shared project, commit the folder at .claude/skills/scratch-cleanup/ instead.
  2. Current Claude Code detects SKILL.md changes in watched directories during the session. If you just created a top-level skills directory, run /reload-skills. Check that the skill is listed before testing its trigger.
  3. For Claude chat or Cowork in the Desktop app, manage uploaded skills in Customize > Skills; copying files into a local Claude Code folder is not a Desktop install. Other agents may use different install locations.

Full install guide for Claude, Cursor, and Codex →

Try a starter prompt

After installing the skill, paste this starter prompt into your agent to verify it triggers on a small task.

Starter prompt
Use the Scratch Cleanup skill for this task: git status in /workspace shows 20+ untracked check-, debug-, test-, probe-, run- files. Confirm any required inputs or files before making changes.

What supports this recommendation?

82/100 provisional content score. This measures documentation, practical detail and source signals. It is not a measured task success rate or a security certification.

Documentation
92/100
Practical detail
92/100
Source evidence
58/100
Source signals
72/100
Model compatibility evidence
  • claudeinferred

    The skill text mentions Claude or a closely associated term. This is keyword-derived compatibility; no hands-on model test is recorded.

  • chatgptuntested

    No model-specific signal or recorded compatibility test was found.

  • geminiuntested

    No model-specific signal or recorded compatibility test was found.

  • copilotuntested

    No model-specific signal or recorded compatibility test was found.

  • llamauntested

    No model-specific signal or recorded compatibility test was found.

  • perplexityuntested

    No model-specific signal or recorded compatibility test was found.

  • mistraluntested

    No model-specific signal or recorded compatibility test was found.

  • grokuntested

    No model-specific signal or recorded compatibility test was found.

Inferred compatibility is based on content signals. Check the app, its available tools and setup requirements before running a skill.

What this skill does

# 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

```bash pwd && git branch --show-current ```

Must be `/workspace` on `main`.

## Step 2: Survey untracked non-plan files

```bash 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:

```bash 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 ```

For `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

```bash mkdir -p .tmp ```

## Step 5: Move

```bash mv <FILES...> .tmp/ ls .tmp/ | wc -l ```

## Step 6: Verify gitignore covers the patterns

```bash grep -qE '^\.tmp/' .gitignore || echo ".tmp/" >> .gitignore ```

Also verify the root-level and tests/ patterns are in `.gitignore` as a safety net:

```bash grep -E '^/check-\*\.ts|^/debug-\*|tests/probe-\*' .gitignore ```

If 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.ts ```

## Step 7: Verify clean state

```bash git status --short | head -20 ```

Should show only the modified `.gitignore` (if you updated it) and any legitimate planning/memory edits.

## Step 8: Commit

```bash 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) <[email protected]>" ```

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.ts` blindly** — these are often legitimate per-issue test files. Only move if they are clearly `*-debug` or `*-probe` variants. - **Root cause prevention:** ensure CLAUDE.md tells dev agents to write scratch in `.tmp/` directly. Pattern-based `.gitignore` is a safety net, not a substitute for the convention.

Intended uses

  • 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

Implementation notes

  • Review the source instructions and adapt inputs before running the workflow.

Try it, then tell us how it went

A copied prompt does not tell us whether the task worked. Report your result after checking the output. We collect your tool and outcome, never your files or prompt.