Your AI Coding Agents Are Filling Up Your Disk. Here’s How to Clean Up Safely

●1 ●4
calendar_today • schedule2 min read
— Originally published at dev.to

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.

1 Comment

0 votes
🔥 Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

More Posts

A Textile Mill's Dyehouse Ramp Curve: Get One Step Wrong and the Sheet Belongs to the Master

aiomniu - Oct 18

The Sovereign Vault — A Comprehensive Guide to Protocol-Driven AI

Ken W. Algerverified - Jun 4

AAIF Hits 10 Projects. Its CTO on What to Adopt Now and the Security Gaps Left Open

Tom Smithverified - Oct 23

Dozens of email accounts: learning AI coding tools as a student

rahuldk1105 - Oct 27

How AI Is Changing Web Development, and What Developers Still Need to Understand

Daniel Decker - Nov 10
chevron_left
141 Points • 5 Badges
1Posts
0Comments
Software Engineering and Data Science student with hands-on experience in backend development, AI-po... Show more

Commenters (This Week)

3 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!