Getting it into your agent
This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.
/plugin marketplace add sdsrss/claudemd/plugin install claudemdWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/commands/sdsrss/claudemd/claudemd-clean-residue)<a href="https://agentmods.dev/commands/sdsrss/claudemd/claudemd-clean-residue"><img src="https://agentmods.dev/badge/commands/sdsrss/claudemd/claudemd-clean-residue/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/commands/sdsrss/claudemd/claudemd-clean-residue"><img src="https://agentmods.dev/badge/commands/sdsrss/claudemd/claudemd-clean-residue.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00134 | $0.01317 |
| Opus 5 | $0.00067 | $0.00659 |
| Sonnet 5 | $0.00027 | $0.00263 |
| Haiku 4.5 | $0.00013 | $0.00132 |
Grade A, and why
claudemd-clean-residue 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 3d 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.
How it starts
The opening of the file, as written. The whole thing — 21 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Default is dry-run — the user must opt into deletion explicitly. Flags:
--apply— do delete.--age-days=N— $TMPDIR staleness threshold (default 1). Applies only to the claudemd-* patterns.--retention-days=N— ~/.claude/tmp and ~/.claude/.claudemd-state retention window, at least 1. Resolution: this flag >TMP_RETENTION_DAYS:in the project's CLAUDE.md > 7 (spec §EXT §7-EXT). Below 1 the flag is rejected (exit 1) and a CLAUDE.md value warns and falls back to 7:~/.claude/tmp/claude-<uid>holds every live session's scratchpad, so a zero-day window would delete running sessions' working directories (it did, on 2026-09-02).
Run: node ${CLAUDE_PLUGIN_ROOT}/scripts/clean-residue.js $ARGS
The ~/.claude/tmp pass purges depth-1 entries older than the retention window; for per-UID dirs (claude-<uid>) it purges their depth-1 children instead of the shell. Dirs carrying a .keep marker are exempt (§8.V4 deliberately-retained fixtures). An entry that contains the command's own working directory or $TMPDIR is never deleted, whatever its age — it is listed under protected and noted on stderr. Under the Claude Code sandbox $TMPDIR is itself a child of claude-<uid>, which is how the cleaner came to delete the tree it was running in.
The ~/.claude/.claudemd-state pass (v0.65.0) reaps eight ephemeral classes past the retention window — ext-read-* and vocab-scan-* (per-session sentinels that leak when a session never reaches SessionEnd), failopen-* (60s rate-limit markers), mem-coverage-* (written by a hook removed in v0.23.12), and the three per-session window refs: session-start-<sid>.ref (sandbox-disposal) and tmp-baseline-<sid>.txt (residue-audit), both from v0.67.0, plus session-summary-<sid>.lastrun (session-summary), and the two legacy last-shown-* banner sentinels by name (last-session-summary.json.last-shown, bootstrap-failed.json.last-shown — renamed rather than deleted up to v0.75.0, nothing reaped them). Deletion is allowlist-by-pattern: live singleton state in the same directory — including the sid-less legacy session-start.ref and tmp-baseline.txt, plus l2-task-counter and friends — is never touched however old it is.
The unowned count (v0.72.0) covers what a bare mktemp / mktemp -d produces — tmp.XXXXXXXXXX, which matches none of the claudemd- prefixes above and so never appeared in this command's report: on 2026-09-02 the maintainer's $TMPDIR held 2.6 GB of it across 524 directories (audit R11-38). Nothing can prove those entries were created by claudemd, so they are counted and sized on every run and never deleted — the report is for a human to act on. The name shape is matched exactly, so tmp.backup / tmp.lock and anything else a person named that way are out of scope. tests/lib/mktemp-template.sh keeps this repo from producing more.
Format the JSON output: report sentinels/sandboxes counts, the unowned block (scanned, bytes) and the tmpDir scanned, then the claudeTmp section (dir, retentionDays, candidates, deleted, worst per-path ages), the protected list if non-empty, then the stateDir section (dir, candidates, deleted, byKind), and dry-run vs apply mode. Under --apply, remaining is the number of targets still on disk and the command exits 3 when it is non-zero — say so plainly rather than reporting a clean sweep. unreapable (v0.74.0) is the list that says which ones and why: each entry is { path, code }, where the code is the errno that stopped the delete. Report it verbatim and translate the errno into the next action — EACCES is usually a child directory with no write bit (a chmod away), EPERM an entry owned by another user (sudo, or leave it), ENOTEMPTY something still writing into it. Do NOT point the reader at the per-path lists for this: those enumerate every target, not the ones that failed, which is the exact confusion this field was added to end. None of these conditions ages out, so an unreapable entry will be reported again on every future run until someone acts on it. If invoked without --apply and any scope shows >0 candidates, suggest /claudemd-clean-residue --apply as the next step. Note for the user: an active session older than the retention window could have its scratchpad purged — scratchpads are disposable tool-exhaust by definition, but mention it if candidates includes a path under a project dir modified today.
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.
- 3d ago Changed cffb9d729bac
- 4d ago Changed · +2 lines 28b7fed632c4
- 10d ago First seen · 19 lines · 134 tokens per session scan A 29f7ea26646d
claudemd-clean-residue is a command published in the GitHub repository sdsrss/claudemd (2 stars, last pushed yesterday), licensed MIT. It adds 134 tokens to every session and 1,317 once invoked, about $0.0007 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-31.
Other commands, from other repositories
plan
Turn an approved spec into an implementation plan an engineer with zero context could execute — with a quality controller that blocks placeholders and hollow tasks.
simplify
The over-engineering review: five tags (delete, stdlib, native, yagni, shrink), a mandatory replacement per finding, and a real null result when there is nothing to cut.
git
The pre-finish status: branch, hygiene findings, message checks, workflow lint, template state.
test
Run the repository's actual test suite: every ecosystem's canonical runner — NOT run is never green.
init
Install the formatters this repository needs, with every command visible before it runs.
edit
An interview-style command for editing the trigger words used by existing personas. Personas are predefined viewpoints, such as a developer, designer, or lawyer, that guide how work is approached.