agent-janitor scans agent data across tools, shows what it finds, and archives eligible files before removing them.
If you use AI coding agents regularly, they leave more behind than code.
Session transcripts, debug logs, caches, and old worktrees can quietly accumulate across your machine. After months of use, it can be hard to tell what’s taking up space—and harder to know what’s safe to remove.
A generic disk cleaner doesn’t understand the difference between a disposable cache and a session you may want to resume. A tool built for one coding agent won’t necessarily help with the others.
That’s why I built agent-janitor: a CLI for inspecting, classifying, and safely reclaiming data left behind by AI coding agents.
Start with a read-only scan
You can run a scan without installing the package globally:
npx agent-janitor scan
The scan reports what it finds, how large it is, when it was last touched, and how it is classified. For example, it can distinguish between regenerable cache data and transcripts that may contain session state.
It can also scan transcript content for known credential patterns. That’s an exposure warning—not automatic secret removal or redaction.
Clean up with a way back
When you choose to clean up, agent-janitor is designed to archive eligible items before removing them. By default, it applies a 30-day retention gate, so recent or active data is skipped.
npx agent-janitor clean
You can restore archived data later:
agent-janitor restore --list
agent-janitor restore latest
Or find archived sessions using a session ID or project name:
agent-janitor restore <session-id>
agent-janitor restore <project-name>
The goal is to make cleanup less of a gamble: review what the tool found, archive what it acts on, and restore items when you need them again.
One tool for several agent data stores
agent-janitor currently includes drivers for Claude Code, Codex, Cursor, Gemini CLI, OpenCode, and agent-created Git worktrees. It brings those into one scan and cleanup workflow rather than requiring a different cleanup process for each tool.
It also has optional ways to make checks part of your routine:
- A weekly scheduled summary
- A shell prompt segment
- A pre-push check for orphaned worktree registrations, staged agent artifacts, and likely secrets in changed files
These are opt-in; you can start with a one-time scan and decide whether to install them.
Try it
The package requires Node.js 20 or newer. To inspect your machine:
npx agent-janitor scan
For the full command list and safety details, visit the GitHub repository or the npm package page.
If you use multiple AI coding agents, I’d like to hear what kinds of files and workflows you’d want agent-janitor to support next. Share feedback or report an issue on GitHub.
Top comments (0)