Foreword

During the use of DeepSeek Harness (DSH), system caches and temporary files occupy disk space, which may affect system performance. Manually cleaning these files carries the risk of accidental deletion. The dsh-system-cleanup plugin provides a reusable skill for conservatively and automatically cleaning system caches and junk files on macOS / Linux / Windows.

Plugin Positioning

This is a reusable skill for DSH, maintained by Paul090515. It addresses the issue of insufficient disk space caused by the accumulation of system junk files while ensuring that the cleanup process does not affect normal user work.

Core Features

The plugin provides the following capabilities:
1. Dry-run by default: By default, it only reports what will be cleaned and does not perform actual deletion; you can apply the cleanup after confirming correctness.
2. Recoverable deletion: Deletion operations move files to the Trash or Recycle Bin by default and support restoration at any time.
3. Allowlist-based: Only cleans known safe directories listed in references/safety-and-scope.md.
4. Age filtering: By default, it only processes entries that have not been modified for 7 days, avoiding files currently in use.
5. In-use detection: Uses lsof to detect whether a file is opened by a process and skips files that are currently in use.
6. Full platform support: Supports macOS, Linux, and Windows, and automatically dispatches the corresponding cleanup script.
7. Optional scheduling: Provides a scheduled task installation script and supports configuring periodic automatic cleanup.

Installation

Install it through the DSH plugin manager:

dsh plugin --profile web add github:Paul090515/dsh-system-cleanup

After installation, you need to restart dsh web.

Usage

After installation, you can invoke the scripts from the command line.

Manual Cleanup

# macOS / Linux: check only (dry-run)
bash ~/.dsh/skills/system-cleanup/scripts/cleanup.sh

# macOS / Linux: apply cleanup
bash ~/.dsh/skills/system-cleanup/scripts/cleanup.sh --apply

# macOS / Linux: more conservative cleanup (specify minimum age)
bash ~/.dsh/skills/system-cleanup/scripts/cleanup.sh --apply --min-age-days 14

# Windows: check only (dry-run)
powershell -ExecutionPolicy Bypass -File ~/.dsh/skills/system-cleanup/scripts/cleanup.ps1

Scheduled Cleanup

# Install scheduled task (weekly dry-run)
bash ~/.dsh/skills/system-cleanup/scripts/schedule.sh --install

Safety Mechanisms

The plugin includes multiple mechanisms to ensure system safety:
1. Dry-run by default: No deletion without explicit confirmation.
2. Recoverable: Moves files to the Trash/Recycle Bin and does not use rm -rf.
3. Allowlist: Does not touch directories such as Documents, Downloads, Desktop, projects, or the home directory root.
4. No deletion without a safe fallback: If a “move to trash” tool is not found on the system, actual deletion is skipped.
5. No automatic privilege escalation: Directories that require administrator permissions are always skipped.

Summary

dsh-system-cleanup provides a safe and controllable system cleanup solution. The default dry-run behavior and allowlist mechanism reduce the risk of accidental deletion. It is suitable for DSH users who need to maintain system disk space regularly. See the GitHub repository for the full source code and documentation.