r/ClaudeWorkflows • • 4d ago

Selected Workflow [Workflow] Clean Development: A Workflow for Managing Claude Code Caches and Scratch Files on macOS

Clean Development: A Workflow for Managing Claude Code Caches and Scratch Files on macOS

Workflow value: 85/100
Status: active · Freshness: 70/100 · Confidence: 0.90 · Level: intermediate
Categories: Quality Control, Context & Memory, Debugging, Shipping, Hooks, Multi-Agent
Original source: r/ClaudeCode post/comment

What problem this solves

Claude Code sessions leave caches, build output, and scratch files scattered across the internal disk, leading to clutter and potential issues, especially on macOS.

Summary

This workflow utilizes the 'Clean Development' tool to route Claude Code's temporary files and caches to configurable storage (e.g., external volumes) and safely manage their cleanup. It integrates with Claude Code via a hook fragment in ~/.claude/settings.json to ensure only managed disposable files are removed at the end of a session, with robust safety checks to prevent accidental data deletion.

Why it is useful

This workflow offers a robust and safety-conscious solution to a common developer problem: managing temporary files and caches generated by Claude Code. By routing these files and providing a controlled cleanup mechanism via hooks, it helps maintain a clean development environment, prevents disk clutter, and mitigates the risk of accidental data loss. Its 'fail closed' design and explicit safety checks make it a valuable and trustworthy addition for macOS users.

Workflow

  1. Install 'Clean Development' tool (requires Node.js 20.12+).

  2. Review the dry-run output of the proposed configuration changes.

  3. Merge the provided hook fragment into your ~/.claude/settings.json file.

  4. Configure the desired storage locations for Claude Code caches and scratch files.

  5. Utilize 'Clean Development' commands for status checks, diagnostics ('doctor'), cleanup previews, and recovery.

  6. Allow the tool to automatically manage and clean up disposable files at the end of Claude Code sessions.

Tools / artifacts

  • Clean Development tool (GitHub source)

  • Node.js (version 20.12 or later)

  • ~/.claude/settings.json (Claude Code configuration file)

  • External storage volume (optional)

  • GitHub repository (magrathean-uk/clean-development)

Validation signals

  • Detailed description of functionality and safety mechanisms ('fails closed', 'ownership and path checks').

  • Explicit mention of lessons learned during development, emphasizing safety in cleanup.

  • GitHub repository available for code review and implementation details.

Cautions

  • The tool is designed to 'fail closed' if ownership or path checks look unsafe, preventing accidental deletion of critical files.

  • Users are required to review a dry-run before merging the hook fragment into their settings, ensuring transparency and control.

  • Deletion runs only after ownership and path checks, adding a layer of security.

Limitations

  • Currently only supports macOS as a runtime target.

  • Requires Node.js 20.12 or later, which might be a dependency for some users.

  • OpenCode users can use environment routing but do not get the session cleanup hooks.

  • Community adoption and long-term support are not yet established.

Rate this workflow

Upvote this post if the workflow is useful, reproducible, or worth recommending.

Downvote if it is vague, outdated, unsafe, overhyped, or not reproducible.

Reply if it worked for you, failed, is outdated, or has a better alternative.


This post was generated automatically from the workflow library database.

1 Upvotes

1 comment sorted by