feat(plugin): add tmp-cleanup plugin for /tmp/claude-*-cwd file accumulation#30721
Open
niceysam wants to merge 1 commit intoanthropics:mainfrom
Open
feat(plugin): add tmp-cleanup plugin for /tmp/claude-*-cwd file accumulation#30721niceysam wants to merge 1 commit intoanthropics:mainfrom
niceysam wants to merge 1 commit intoanthropics:mainfrom
Conversation
…-cwd files The Bash tool creates /tmp/claude-*-cwd temp files to track working directory state across commands but never deletes them. This causes hundreds to thousands of orphaned files to accumulate over time (issue anthropics#8856). Add a new tmp-cleanup plugin with a Stop hook that removes these files when a session ends cleanly. Files from crashed/interrupted sessions are collected on the next normal exit.
This was referenced Mar 5, 2026
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #8856.
Every Bash tool invocation creates a
/tmp/claude-{hex}-cwdfile to track the working directory, but these are never cleaned up. Heavy users end up with hundreds or thousands of orphaned files in/tmp.This adds a small
tmp-cleanupplugin that hooks into theStopevent to delete all/tmp/claude-*-cwdfiles when a session ends normally. Files left behind by crashed sessions get picked up on the next clean exit.The plugin is minimal — one Python script, one hook config — and never blocks the stop event even if cleanup fails.