agentsclimarketplace

Safety deletion

Skill knokmki612/skills/skills/safety-deletion

A collection of Agent Skills

Install
npx -y skills add knokmki612/skills --skill safety-deletion

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Safely delete files or directories in a git working tree by routing deletions through `git rm` or `git clean` instead of `rm`, `rmdir`, `shred`, `unlink`, `find -delete`, or `truncate`, keeping removals recoverable via git. Use before any non-git deletion command, and when the user asks to delete, remove, drop, wipe, purge, or clean up files.

The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

3.9 KB, as published. Nobody here has run it

Safe Deletion via Git

Why

Plain rm / rmdir / shred bypass git entirely and are unrecoverable. Routing deletions through git keeps them reversible:

  • Tracked paths land in history — git reflog and git checkout can restore them.
  • Untracked / ignored paths still pass through git clean's explicit-intent flags (-f, -d, -x, -X), which fails closed instead of silently nuking unrelated state.

Workflow

  1. Confirm a git working tree. Run git rev-parse --is-inside-work-tree. If it prints anything other than true, jump to Outside a git repository.
  2. Classify each target. Use the table below to decide which bucket every path belongs to.
  3. Dry-run before any git clean. Replace -f with -n first and inspect output.
  4. Execute the matching command.
  5. Verify with git status afterwards. No leftover surprises.

Classifying a path

ProbeMeaning
git ls-files --error-unmatch -- <path> exits 0Tracked (committed or staged)
git status --short -- <path> shows ??Untracked
git check-ignore -v -- <path> matchesIgnored

A path can span multiple buckets across its subtree (e.g. directory contains tracked + ignored). Treat each subset with its matching command.

Commands

Always place -- before paths so they aren't parsed as flags.

Target stateCommand
Tracked filegit rm -- <path>
Tracked directory (recursive)git rm -r -- <path>
Tracked and locally modified — loss of edits is intentionalgit rm -f -- <path>
Newly git add-ed, want to undo and delete on diskgit rm -f -- <path>
Newly git add-ed, want to unstage but keep on diskgit rm --cached -- <path>
Untracked filegit clean -f -- <path>
Untracked directorygit clean -fd -- <path>
Ignored onlygit clean -fX -- <path>
Untracked + ignored togethergit clean -fdx -- <path>

For any git clean invocation, run it once with -n substituted for -f first:

git clean -ndx -- <path>...   # preview
git clean -fdx -- <path>...   # execute

After git rm, finish the deletion with a commit (or instruct the user to). Until commit, the removal lives only in the index, but git restore --staged --worktree -- <path> still recovers it.

Outside a git repository

When git rev-parse --is-inside-work-tree does not print true:

  1. Do not silently fall back to rm. There is no recovery net.
  2. Surface the situation and offer one of:
    • git init the directory and commit a baseline first, then proceed normally.
    • Use a trash CLI when available: trash-put, gio trash, trash (macOS Homebrew).
    • Proceed with rm only after the user explicitly confirms with full awareness.

Prohibited commands

Never issue these against the working tree as a substitute for the above:

  • rm, rm -rf
  • rmdir
  • shred
  • unlink
  • find ... -delete, find ... -exec rm ...
  • truncate -s 0 against existing files to "blank them out"

If a build script, generator, or tool insists on calling one of these, raise it with the user rather than running it silently.

Edge cases

See references/edge-cases.md when the target involves:

  • Submodules
  • Nested git repositories or worktrees
  • Bare repositories
  • .git/ itself or files under it
  • Files matched by .gitignore that the user wants to keep on disk
  • Symlinks, sparse-checkout cones, LFS-tracked blobs

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.