Delete-Recovery: Adding a Retrievable Backup and Recovery Layer for Agent Deletion Operations

Introduction

In environments like Cursor and Claude Code, it’s common to let Agents help delete files or clear caches. Once a file or directory is mistakenly deleted or cleared, there’s often no recycle bin to rely on — you can only count on Git or manual backups and hope for the best. This article introduces the SkillHub community skill delete-recovery (v0.8.0): it snapshots files into timestamped backups before deletion, uses a manifest for retrieval, and performs SHA256 and path safety checks during restoration. v0.8.0 also bundles workspace_cleaner, which runs the same backup logic before scheduled cleanup of temporary or expired files.

What Is This

delete-recovery is an Agent Skill for IT operations and security scenarios (category it-ops-security), with coordinates @user_55263055/delete-recovery. The current version is 0.8.0, sourced from the community, and published by user_55263055. The Skill metadata indicates requires_api_key=false, so it does not depend on any external API key.

It addresses two problems: first, “back up before deleting, and recover by keyword if you delete the wrong thing”; second, when doing scheduled cleanup within a controlled workspace, back up as much as possible before deletion while protecting core Markdown files and the skills directory.

Core Features

All capabilities below come from the official SKILL.md and the SkillHub page description. You can use them in tandem with the relevant versions (v0.1.0 through v0.6.0 are deprecated — use v0.7.0 / v0.8.0 instead).

Backup & Recovery (delete_recovery.py)

  1. Pre-deletion backup: The backup directory is {workspace}/.delete_recovery/delete_backup/YYYYMMDDHHMM/ (the delete_backup/YYYYMMDDHHMM/ shown in the page summary refers to the same timestamp structure; the actual root path is .delete_recovery under the workspace).
  2. Manifest retrieval: search looks up entries in manifest.jsonl by filename, description, or path keyword. Since v0.7.0, the path field in the manifest is HMAC-SHA256 encrypted, and the plaintext path is stored in a .path file in the same directory for recovery positioning.
  3. Recovery & validation: restore performs SHA256 integrity checks, PATH cross-validation, and path traversal detection before restoring; verify only validates without restoring. --force can only skip the “SHA256 record exists” check (for legacy backups from before v0.3.0); PATH and traversal detection cannot be bypassed.
  4. Scope limits: Since v0.7.0, allowed_roots defaults to restricting operations within the workspace root; to restore outside the workspace, the documentation states you can set allowed_roots to None.
  5. Automatic cleanup: Backup folders are retained for about 7 days and logs for about 30 days (time-triggered, with a default interval of approximately 24 hours); you can also use cleanup for a manual full cleanup.

Scheduled Workspace Cleanup (workspace_cleaner.py, v0.8.0)

  • By default, it scans the workspace at intervals of approximately 24 hours, cleaning up temporary items (such as __pycache__, .pyc, Thumbs.db) and expired files not modified for a default of 7 days.
  • Before cleanup, it first calls delete_recovery.py backup; if the subprocess backup fails, it falls back to copying into delete_backup/. If that still fails, the file is skipped and not deleted.
  • The whitelist and configuration are stored under {workspace}/.delete_recovery/workspace_cleaner/; core paths such as AGENTS.md, SOUL.md, and skills are hardcoded as protected.

Agent-Side Constraints

SKILL.md requires that the Agent handle all deletion and recovery operations exclusively through the backup / restore / list / search / verify / cleanup management commands and the workspace_cleaner command provided by this skill; tampering with content, path redirection, and bypassing validation are prohibited. All deletions (including user instructions and workspace_cleaner) must be backed up first.

Installation & Activation

Environment

  • Python 3.8+ (the scripts are written in Python).
  • When installing via SkillHub, the skillhub CLI must already be installed on your machine (see the SkillHub installation docs for how to install it).

SKILL.md also mentions an installation path via ClawHub (npm i -g clawhub, clawhub install delete-recovery), which coexists with the SkillHub coordinate installation; in SkillHub scenarios, coordinate-based installation takes precedence.

SkillHub Installation

The AI installation prompt provided on the official page is:

Please install `@user_55263055/delete-recovery` according to https://skillhub.cn/install/skillhub.md.

Command-line installation (you must use --dir to point to the current Agent’s skills directory; otherwise the default ./skills/ may not be recognized):

skillhub install delete-recovery --namespace user_55263055 --dir <your skills directory>

Common skills directory examples (from the SkillHub installation docs):

  • Cursor: ~/.cursor/skills/
  • Claude Code: ~/.claude/skills/
  • Codex: ~/.codex/skills/ or .agents/skills/ under the project

After successful installation, the script paths look like:

<skills directory>/@user_55263055/delete-recovery/scripts/delete_recovery.py
<skills directory>/@user_55263055/delete-recovery/scripts/workspace_cleaner.py

After installation, restart or refresh the Agent as required by your client so that SKILL.md is loaded.

Typical Usage

The following steps can be run from the scripts directory after installation; replace the paths with your actual workspace and file locations.

Back Up Before Deletion, Recover After Mistaken Deletion

cd <skills directory>/@user_55263055/delete-recovery/scripts

# 1. Back up (optional third argument is a ≤6-character description, useful for search)
python delete_recovery.py backup "/path/to/report.docx" "/path/to/report.docx" "工作报告"

# 2. The user or Agent executes the actual deletion after confirmation

# 3. Search the manifest by keyword
python delete_recovery.py search "报告"

# 4. Restore using the folder and safe_name returned by search
python delete_recovery.py restore 202603281030 "C__Users__user__Desktop__report.docx"

# 5. Optional: only verify the backup hasn't been tampered with
python delete_recovery.py verify 202603281030 "C__Users__user__Desktop__report.docx"

list, delete_backup <folder>, cleanup, and log [lines] are used to view backups, delete a specific backup, immediately clean up expired items, and read operation logs, respectively.

workspace_cleaner Preview & Triggering

python workspace_cleaner.py status
python workspace_cleaner.py dry-run
python workspace_cleaner.py run
python workspace_cleaner.py add-whitelist ".xlsx" --type ext
python workspace_cleaner.py set-interval 12
python workspace_cleaner.py set-expire-days 3

The documentation states that workspace_cleaner needs to be triggered via cron or periodic calls to run; it does not run as a standalone daemon.

Use Cases & Notes

Who It’s For

  • Developers who frequently delete configurations, logs, or generated files in an Agent workspace and want a “searchable deletion record.”
  • Teams that need the Agent to follow the “backup before delete” discipline (the constraint can be written into AGENTS.md).
  • Scenarios where you want to automatically clear caches/expired files within the workspace while keeping backups before cleanup as much as possible.

Limitations & Gotchas

  1. Backups are stored under {workspace}/.delete_recovery/, separated from the skills directory (deleting the skill still leaves backups), but this is not equivalent to encryption or permission isolation. The documentation requires deployment only in trusted environments, and there is no integrity verification at installation time.
  2. The filename and description in the manifest remain in plaintext; although sensitive paths are encrypted, you still need to pay attention to access control on the disk and the backup directory.
  3. Recovery is restricted to the workspace by default; cross-workspace recovery requires understanding the implications and risks of allowed_roots=None.
  4. When workspace_cleaner’s backup fails, it may fall back to a plain copy, which is not equivalent to the full SHA256 chain; the file will not be deleted if backup fails.
  5. SkillHub page statistics (as of data retrieval): rating 100000, downloads 813, installs 5; these numbers may differ from those in some summaries due to different snapshot times — refer to the SkillHub page for the latest figures.

Conclusion

delete-recovery bundles “backup before deletion, manifest retrieval, validated recovery” and optional scheduled workspace cleanup into a single Skill, making it suitable for handing off file lifecycle operations to an Agent within a controlled workspace. The official SkillHub page and API coordinates:

  • https://www.skillhub.cn/skills/user_55263055/delete-recovery
  • https://api.skillhub.cn/user_55263055/delete-recovery
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye