# How Claude-Video Handles Temporary Working Directory Cleanup

> Discover how Claude-video handles temporary directory cleanup. Learn why it requires manual removal and the path is printed upon completion.

- Repository: [bradautomates/claude-video](https://github.com/bradautomates/claude-video)
- Tags: internals
- Published: 2026-07-10

---

**Claude-video does not automatically delete its temporary working directory; instead, it prints the path at the end of execution and expects users to remove it manually.**

When you run the `watch` command in the bradautomates/claude-video repository without specifying an output directory, the script creates a temporary workspace to store downloaded videos and extracted frames. Understanding this manual cleanup requirement is essential for preventing disk space issues, as the directory persists after the process exits.

## How the Temporary Directory Is Created

### Directory Generation with tempfile.mkdtemp

In [`skills/watch/scripts/watch.py`](https://github.com/bradautomates/claude-video/blob/main/skills/watch/scripts/watch.py), the script generates a unique temporary folder when no `--out-dir` argument is provided. The code uses Python's `tempfile.mkdtemp` function to create a directory prefixed with `watch-`:

```python

# Lines 84-87 in skills/watch/scripts/watch.py

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

```

This path is stored in the variable `work` and serves as the root for all intermediate files. The script then creates subdirectories under this path for specific purposes:

- `work / "download"` – stores downloaded video files
- `work / "frames"` – stores extracted frame images

## Why Claude-Video Does Not Auto-Clean

### Absence of Cleanup Hooks

Unlike many CLI tools that use context managers or `atexit` handlers, the Claude-video codebase contains no automated deletion logic. There are no calls to `shutil.rmtree`, `os.remove`, or any cleanup hooks that would trigger when the process terminates.

At line 387, the script explicitly acknowledges this behavior by printing a reminder message:

```python

# Line 387-388 in skills/watch/scripts/watch.py

print(f"Work dir: {work} — delete when done.")

```

This design choice places the cleanup responsibility on the caller rather than the script itself, allowing users to inspect intermediate files before deletion.

## Manual Cleanup Instructions

Since the directory persists after execution, you must delete it manually or wrap the command in automation that handles cleanup.

### Basic Manual Removal

After the script completes, note the printed path and run:

```bash

# Example: remove the specific temporary directory shown in output

rm -rf /tmp/watch-abc123

```

### Automated Wrapper Script

For automated workflows, capture the working directory path and delete it after processing:

```bash

# Run watch and extract the directory path from output

WORK_DIR=$(watch https://example.com/video.mp4 2>&1 | grep "Work dir:" | awk '{print $3}')

# Perform additional processing here...

# Clean up the temporary directory

rm -rf "$WORK_DIR"

```

Alternatively, use a deterministic approach with explicit output directory control:

```bash

# Create your own managed temp directory

OUT_DIR=$(mktemp -d)
watch https://example.com/video.mp4 --out-dir "$OUT_DIR"

# Process files...

rm -rf "$OUT_DIR"

```

## Summary

- **Claude-video** creates temporary directories using `tempfile.mkdtemp` with a `watch-` prefix when no output directory is specified
- The working directory path is stored in the `work` variable in [`skills/watch/scripts/watch.py`](https://github.com/bradautomates/claude-video/blob/main/skills/watch/scripts/watch.py)
- **No automatic cleanup** occurs; the script lacks `shutil.rmtree`, `os.remove`, or `atexit` hooks
- The script prints the directory path at line 387 with instructions to delete it manually
- Users must run `rm -rf` on the printed path or wrap the command in a script that handles deletion

## Frequently Asked Questions

### How do I find the temporary working directory created by Claude-video?

The script prints the absolute path at the end of execution with the message format `Work dir: /path/to/watch-XXXXXX — delete when done`. Check the final lines of your terminal output to locate the specific directory.

### Does Claude-video ever delete the temporary files automatically?

No. According to the source code in [`skills/watch/scripts/watch.py`](https://github.com/bradautomates/claude-video/blob/main/skills/watch/scripts/watch.py), the repository contains no automatic deletion mechanisms. The temporary directory persists after the script exits until you manually remove it or an external process cleans it up.

### Can I specify a custom directory instead of using the temporary one?

Yes. Use the `--out-dir` argument to specify a persistent location. When you provide this flag, the script skips the `tempfile.mkdtemp` call and uses your specified path, allowing you to manage the files without relying on the temporary cleanup pattern.

### What happens if I run multiple watch commands without cleaning up?

Each execution creates a new unique directory via `tempfile.mkdtemp`, so old directories accumulate on your disk. You should periodically clean up `/tmp/watch-*` directories or implement a wrapper script that deletes the folder immediately after processing the video analysis.