How watch.skill Cleans Up Working Directories After Processing: Complete Guide

The watch.skill does not automatically delete temporary working directories; instead, it prints a reminder message containing the directory path and leaves manual deletion to the user.

When processing video content, the watch skill in the bradautomates/claude-video repository creates a dedicated workspace to hold downloaded videos, extracted frames, and audio chunks. Understanding how it handles cleanup is essential for disk space management, as the tool intentionally preserves these directories post-processing to allow for result verification and debugging.

How the Working Directory Is Created

The watch.skill generates its temporary workspace using Python's standard library to ensure cross-platform compatibility.

Temporary Directory Generation

In skills/watch/scripts/watch.py, lines 85-88 instantiate the working directory:

import tempfile
from pathlib import Path

work = Path(tempfile.mkdtemp(prefix="watch-"))
work.mkdir(parents=True, exist_ok=True)

The tempfile.mkdtemp call with the "watch-" prefix creates a uniquely named directory in the system's default temporary location (typically /tmp on Linux or C:\Users\<username>\AppData\Local\Temp on Windows). The exist_ok=True parameter ensures the operation succeeds even if the directory already exists.

The Cleanup Mechanism

Unlike automation tools that automatically purge temporary files, watch.skill implements a manual cleanup strategy that prioritizes data inspection over automatic deletion.

No Automatic Deletion

The source code contains no shutil.rmtree(), os.rmdir(), or atexit handlers to remove the working directory. After processing completes—whether successfully or with errors—the directory remains on disk indefinitely.

User Notification System

At line 387 of skills/watch/scripts/watch.py, the script emits a final status message:

print(f"_Work dir: `{work}` — delete when done._")

This outputs the full path to the console, explicitly informing users that manual intervention is required to reclaim disk space.

Manual Cleanup Procedures

Since watch.skill leaves the cleanup decision to you, there are two approaches to managing these working directories.

Immediate Manual Removal

After verifying your processed results, delete the directory using standard shell commands:

rm -rf /tmp/watch-xxxxxxxx

Or on Windows:

rmdir /s /q C:\Users\%USERNAME%\AppData\Local\Temp\watch-xxxxxxxx

Implementing Automatic Cleanup

If you prefer automatic deletion, wrap the watch.skill execution in a Python script that handles cleanup:

import tempfile
import shutil
from pathlib import Path

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

try:
    # Run watch.skill processing here

    process_video(work)
finally:
    # Always clean up, even if processing fails

    shutil.rmtree(work, ignore_errors=True)
    print(f"Cleaned up {work}")

This pattern uses a try … finally block to ensure the directory is removed regardless of whether the processing succeeds or raises an exception.

Why Manual Cleanup?

The manual approach in bradautomates/claude-video serves specific debugging and operational purposes.

  • Result Verification: Users can inspect extracted frames, transcriptions, and intermediate audio files before committing storage changes.
  • Error Debugging: Failed processing runs leave artifacts available for troubleshooting.
  • OS-Level Management: The directories reside in system temp folders, which operating systems typically purge during reboots or scheduled maintenance anyway.

Summary

  • watch.skill creates temporary directories using tempfile.mkdtemp(prefix="watch-") in skills/watch/scripts/watch.py (lines 85-88)
  • No automatic deletion occurs after processing; the tool relies on user-initiated cleanup
  • Notification provided: Line 387 prints the working directory path with instructions to "delete when done"
  • Manual removal required via rm -rf or shutil.rmtree() after results verification
  • Automatic cleanup can be implemented by wrapping the skill execution in exception-handling code

Frequently Asked Questions

Does watch.skill delete temporary files automatically?

No. According to the source code in bradautomates/claude-video, watch.skill does not implement automatic deletion of its working directories. It creates the directory at lines 85-88 of skills/watch/scripts/watch.py and only prints a reminder message at line 387 indicating the path for manual removal.

Where does watch.skill create its working directory?

The skill creates working directories in the system's default temporary location using tempfile.mkdtemp(prefix="watch-"). On Linux systems, this typically appears as /tmp/watch-xxxxxxxx where xxxxxxxx is a random string. On Windows, it appears in the user's Temp folder.

How can I enable automatic cleanup for watch.skill?

The repository does not provide a built-in automatic cleanup flag. To enable automatic cleanup, you must wrap the watch.skill call in a custom Python script that stores the working directory path and calls shutil.rmtree(work) in a finally block after processing completes.

Is it safe to delete the working directory immediately after processing?

Yes, once you have verified that the processing completed successfully and you have extracted any necessary results. The working directory contains only intermediate files—downloaded videos, extracted frames, and temporary audio chunks—so deleting it after confirming output integrity is safe and recommended for disk space management.

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 →