How Claude-Video Creates and Manages Temporary Working Directory Cleanup

Claude-video creates a temporary working directory using tempfile.mkdtemp for each execution but does not automatically delete it—users must manually remove the folder after processing completes.

The claude-video repository provides a /watch skill for video analysis that requires substantial disk space for downloaded videos and extracted frames. Understanding how this temporary working directory is created and managed is essential for production deployments where disk usage must be controlled. According to the bradautomates/claude-video source code, the cleanup strategy is intentionally manual.

Temporary Working Directory Creation

The watch script generates a unique temporary folder whenever the --out-dir parameter is omitted. This happens in skills/watch/scripts/watch.py between lines 84–87:

work = Path(tempfile.mkdtemp(prefix="watch-"))

The tempfile.mkdtemp function guarantees a unique directory path with the watch- prefix, typically resolving to something like /tmp/watch-abcdef123456. This path is stored in the variable work and used throughout the execution.

All intermediate data is organized beneath this root:

  • work / "download" — stores the fetched video file
  • work / "frames" — holds extracted frame images
  • Other processing artifacts as needed

Why Automatic Cleanup Is Not Implemented

The claude-video codebase contains no automatic deletion mechanism. Specifically absent are:

  • shutil.rmtree calls
  • os.remove or os.rmdir operations
  • atexit registration hooks
  • Context manager-based cleanup (tempfile.TemporaryDirectory)

This design choice preserves user data for inspection, debugging, or reuse. However, it places cleanup responsibility entirely on the operator.

Manual Cleanup Notification

At the conclusion of execution—line 387 in skills/watch/scripts/watch.py—the script outputs a reminder message:


_Work dir: `{work}` — delete when done._

This notification appears in standard output alongside the analysis results. The printed path must be captured and acted upon externally.

Practical Cleanup Workflows

Basic Manual Removal

After running the watch command:


# Execute the watch skill

watch https://example.com/video.mp4

# Note the printed working directory, then delete it

rm -rf /tmp/watch-abcdef123456

Automated Wrapper Script

For production pipelines, capture the directory path programmatically:

#!/bin/bash
set -euo pipefail

# Run watch and extract the working directory path

output=$(watch "$1" 2>&1)
work_dir=$(echo "$output" | grep "working dir" | awk '{print $4}')

# Process or archive results as needed...

# Clean up temporary files

rm -rf "$work_dir"
echo "Cleaned up: $work_dir"

Scheduled Maintenance

For long-running systems, implement periodic cleanup of stale watch-* directories:


# Remove watch directories older than 7 days

find /tmp -maxdepth 1 -type d -name "watch-*" -mtime +7 -exec rm -rf {} +

Test Infrastructure vs. Production

The repository includes tests/conftest.py, which provides temporary path fixtures for test isolation. These test utilities do not influence production behavior—they exist solely for pytest-based unit and integration testing.

Summary

  • Creation: tempfile.mkdtemp(prefix="watch-") in skills/watch/scripts/watch.py generates unique temporary directories
  • Persistence: No automatic deletion occurs; directories remain after process exit
  • Notification: Users receive the path via console output at line 387
  • Responsibility: Clean up must be performed manually or through external automation
  • Risk: Unattended operation without wrapper scripts leads to unbounded disk consumption

Frequently Asked Questions

How do I find the temporary working directory path after running claude-video?

The working directory path appears in the final console output with the message _Work dir: /tmp/watch-XXXXXX` — delete when done._ Copy this exact path for manual removal or capture it via script parsing.

Does claude-video support automatic cleanup via command-line flags?

No automatic cleanup flags exist in the current implementation. The codebase lacks --clean, --rm, or similar options. You must implement cleanup externally using shell wrappers or scheduled jobs.

What happens if I specify --out-dir instead of using the temporary directory?

When --out-dir is provided, claude-video skips tempfile.mkdtemp entirely and writes all files to your specified persistent location. In this mode, no automatic cleanup occurs either—the directory is treated as permanent output.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →