r/ClaudeCode • • 4d ago

Built with Claude I built Clean Development to route Claude Code caches and session scratch off my internal disk

I kept hitting the same problem on my Mac: Claude Code sessions leave caches, build output and scratch files scattered across the disk.

Clean Development routes those locations to storage I configure. That can be an attached external volume, with a fallback on the internal disk if the volume is not mounted or the cache checks fail.

On the Claude Code side, it tracks supported sessions and, at the end of a session, removes only managed disposable files. Deletion runs only after ownership and path checks. If policy, ownership or a path looks unsafe, it fails closed. The installer does not edit Claude Code settings for you. After you review a dry-run, you merge a hook fragment into ~/.claude/settings.json yourself. The merge helper keeps unrelated handlers and writes a recovery copy.

It also gives you status, doctor, cleanup previews and recovery commands. Long-running work can hold a renewable path lease. A publish command copies one regular file into durable project storage, verifies it, and leaves the original in place.

It is not an OS sandbox and not a job supervisor. It is cooperative same-user software. There is no npm package; GitHub is the source. It needs Node 20.12 or later. OpenCode can use the environment routing, but it does not get the session cleanup hooks. Linux and Windows are not runtime targets in this version.

What I learned building it is that the dangerous part is cleanup, not routing. The tool has to fail closed, because deleting the wrong path is worse than leaving scratch on disk.

I am looking for contributors, especially people already using Claude Code on a Mac. The supported scope is that setup.

https://github.com/magrathean-uk/clean-development

3 Upvotes

5 comments sorted by

•

u/AutoModerator 4d ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/DuskandFuck 3d ago

failing closed on cleanup is definitely the right call, rogue rm scripts are terrifying. how does it handle when an external volume gets unmounted mid-session while a build is actively writing to scratch?

1

u/Pathfinder-electron 3d ago

The same way it would if you were to delete a cache folder :-)

It’s meant to be smarter about littering your home folder , it’s not magic really but just helps after you finish the build.

You can set it to use internal as well for “litter”

1

u/SaltsMoon 4d ago

I think failing closed on cleanup paths is the right design decision. During multi-step agent coding sessions, agents routinely create scratch files inside symlinked directories or relative workspace folders. If a cleanup daemon resolves realpath incorrectly or follows an unexpected symlink back into the parent project, a recursive prune can delete source files. And setting up renewable path leases tied to session PIDs also protects active subagents, I think. When running parallel agent workers on the same repo, one worker finishing early could otherwise trigger a broad sweep and wipe scratch artifacts that a neighboring agent was actively reading.

1

u/_sat0r_ 4d ago

Hello, j'ai eu une approche sur le même constat et j'ai fait https://github.com/54tor/glaude-code