Task tool creates tmpclaude-* temp files in working directory that aren't cleaned up
Resolved 💬 2 comments Opened Jan 13, 2026 by nikhilchowdhury-nixet Closed Feb 26, 2026
Problem
When using the Task tool to spawn subagents, Claude Code creates temporary files named tmpclaude-XXXX-cwd in the current working directory. These files:
- Are created in the repo directory (pollutes the codebase)
- Are NOT automatically cleaned up after task completion
- Accumulate over time (I had 250+ files)
Expected Behavior
- Temp files should be created in system temp directory (
/tmp,%TEMP%, etc.) - Temp files should be automatically deleted after task completes
- Or at minimum, provide a config option for temp file location
Current Workaround
Added a PostToolUse hook to clean up:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Task",
"hooks": [
{
"type": "command",
"command": "find . -name 'tmpclaude*' -type f -delete 2>/dev/null || true"
}
]
}
]
}
}
Environment
- OS: Windows (MINGW64)
- Claude Code version: Latest
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗