reversible-cleanup-planner
Skill0 starsChanged 2 months agoMITView on GitHub
Plans a safe, reversible filesystem cleanup using inventory staging, dry runs, and rollback commands without permanent deletion.
- Reads credentials
- Deletes or force-pushes
In this repository49 other files it gives its agents.
- bug-reproducerSkill
- claim-checkerSkill
- command-failure-diagnoserSkill
- config-risk-reviewerSkill
- csv-validatorSkill
- deployment-checklist-makerSkill
- diff-reviewerSkill
- factual-summarizerSkill
- field-extractorSkill
- api-contract-testerSkill
- database-migration-helperSkill
- security-vulnerability-fixerSkill
- git-commit-stagerSkill
- git-conflict-resolverSkill
- github-actions-debuggerSkill
- github-issue-triagerSkill
- github-pr-creatorSkill
- github-pr-reviewerSkill
- go-code-qualitySkill
- go-lint-and-vetSkill
- go-testingSkill
- json-schema-converterSkill
- lint-and-typecheckSkill
- meaning-preserving-editorSkill
- meeting-notes-to-actionsSkill
- minimal-bug-fixSkill
- option-comparatorSkill
- py-code-qualitySkill
- py-lint-and-typecheckSkill
- py-testingSkill
- readme-writerSkill
- regression-test-writerSkill
- release-notes-drafterSkill
- repo-inspectorSkill
- research-briefSkill
- rust-clippy-checkSkill
- rust-code-qualitySkill
- rust-testingSkill
- small-refactorSkill
- status-updateSkill
- step-by-step-tutorialSkill
- step-decomposerSkill
- tabular-analyzerSkill
- task-briefSkill
- test-runner-debuggerSkill
- ts-code-qualitySkill
- ts-lint-and-typecheckSkill
- ts-testingSkill
- skill-templateSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Use this skill when:
- Very specific: line 20
Do not use for code refactoring.
- Very specific: line 21
Do not use for database table cleanup.
- Very specific: line 28
If target_directory is missing: stop and ask for the target directory.
- Very specific: line 29
If target_directory is root (/) or home directory (~): halt immediately and refuse.
- Very specific: line 30
Never use rm in the staging phase.
- Distinctive: line 33
Follow these numbered actions:
- Distinctive: line 35
Run companion dry run script:
- Very specific: line 49
If matched files include .git, .env, *.go, *.ts, *.py, *.json: immediately abort cleanup.
- Distinctive: line 97
Stop and ask the user when:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Reversible Cleanup Planner
Plans and stages filesystem cleanups safely. Generates inventory lists, calculates reclaimable space, moves candidates to a reversible staging trash folder, and provides an immediate rollback command. Never runs destructive rm -rf directly.
1. Purpose
Safely reclaim disk space without risk of accidental data loss. "Reversible cleanup" moves candidate files to a staged .trash_staging folder first, giving operators time to verify system stability before final purge.
2. When to Use
Use this skill when:
- Freeing disk space from old logs, temp files, test artifacts, or build caches.
- Preparing a cleanup routine for a cluttered workspace.
- User requests: "Clean up temp files" or "Free disk space in this folder."
3. When Not to Use
- Do not use for code refactoring; use
small-refactor. - Do not use for database table cleanup; use
task-brief.
4. Required Inputs
target_directory: Directory path to clean up.cleanup_criteria: Glob pattern, file age, or file extension (e.g.*.tmp,*.logolder than 14 days).
5. Missing-Input Behavior
- If
target_directoryis missing: stop and ask for the target directory. - If
target_directoryis root (/) or home directory (~): halt immediately and refuse. Target directory must be a specific subfolder. - Never use
rmin the staging phase; always usemvto a staging area.
6. Procedure
Follow these numbered actions:
- Action 1: Execute Dry Run & Inventory
- Run companion dry run script:
python3 skills/reversible-cleanup-planner/scripts/dry_run_cleanup.py <target_dir> --pattern <pattern> --json
- Run companion dry run script:
- Action 2: Verify Matches
- Inspect the file list to confirm no source code or configuration files are matched.
- Action 3: Prepare Staging Command
- Construct move command into
<target_dir>/.trash_staging/.
- Construct move command into
- Action 4: Prepare Rollback Command
- Construct reverse move command to restore files from staging back to original location.
- Action 5: Emit Cleanup Plan
- Format per Section 8.
7. Decision Rules
- If matched files include
.git,.env,*.go,*.ts,*.py,*.json: immediately abort cleanup. Exclude protected extensions. - Require explicit user confirmation before executing any move command.
8. Output Format
Emit the cleanup plan using this template:
### Reversible Cleanup Plan: [Target Directory]
- **Target Directory**: `[Directory]`
- **Filter Pattern**: `[Pattern]`
- **Matched Files**: [Count]
- **Reclaimable Space**: [Bytes / MB]
- **Staging Location**: `[Target]/.trash_staging`
#### Matched File Inventory (Sample)
- `[File 1]` ([Size])
- `[File 2]` ([Size])
#### Stage 1: Safe Reversible Move (Dry Run Verified)
```bash
mkdir -p [Target]/.trash_staging && mv [Target]/[Pattern] [Target]/.trash_staging/Emergency Rollback Command
mv [Target]/.trash_staging/* [Target]/ && rmdir [Target]/.trash_stagingStage 2: Permanent Purge (Only after verification period)
# Execute only after 24h stability verification:
rm -rf [Target]/.trash_staging
## 9. Verification Checklist
- [ ] Dry run was performed using [dry_run_cleanup.py](./scripts/dry_run_cleanup.py) or safe list.
- [ ] No source code or config files are in the inventory.
- [ ] Reversible staging step is provided before permanent deletion.
- [ ] Exact rollback command is included.
## 10. Common Failures and Recovery
| Failure Symptom | Cause | Recovery Action |
| :--- | :--- | :--- |
| Overly broad pattern (`*`) | Matching source files | Restrict pattern to specific extension (e.g. `*.tmp`). |
| Accidental immediate deletion | Running `rm` directly | Mandate two-step move to staging trash directory. |
## 11. Stop or Escalation Conditions
Stop and ask the user when:
- Target path contains system directories (`/etc`, `/usr`, `/var`, `/bin`, `/`).
## 12. Examples
### Example 1: Successful Execution
**Input:**
```text
Target: /app/logs
Pattern: *.log
Dry run: 14 files found, 12.4 MB totalOutput:
### Reversible Cleanup Plan: /app/logs
- **Target Directory**: `/app/logs`
- **Filter Pattern**: `*.log`
- **Matched Files**: 14
- **Reclaimable Space**: 12.4 MB
- **Staging Location**: `/app/logs/.trash_staging`
#### Matched File Inventory (Sample)
- `app-2026-08-01.log` (2.1 MB)
- `app-2026-08-02.log` (1.8 MB)
#### Stage 1: Safe Reversible Move (Dry Run Verified)
```bash
mkdir -p /app/logs/.trash_staging && mv /app/logs/*.log /app/logs/.trash_staging/Emergency Rollback Command
mv /app/logs/.trash_staging/* /app/logs/ && rmdir /app/logs/.trash_stagingStage 2: Permanent Purge
# Run only after confirming application operates normally without logs:
rm -rf /app/logs/.trash_staging
### Example 2: Ambiguous or Missing Input
**Input:**
```text
Target: /
Pattern: *Output:
### Reversible Cleanup Plan: REFUSED - Unsafe Target
- **Status**: Halted / Safety Boundary Triggered
Cleaning the root directory `/` with pattern `*` is destructive and strictly forbidden. Please specify a safe, bounded application cache or temp directory (e.g. `/tmp/cache` or `./build_artifacts`).Example 3: Expected Final Output
Output:
### Reversible Cleanup Plan: /workspace/tmp
- **Target Directory**: `/workspace/tmp`
- **Filter Pattern**: `*.tmp`
- **Matched Files**: 5
- **Reclaimable Space**: 450 KB
- **Staging Location**: `/workspace/tmp/.trash_staging`
#### Stage 1: Safe Reversible Move
```bash
mkdir -p /workspace/tmp/.trash_staging && mv /workspace/tmp/*.tmp /workspace/tmp/.trash_staging/Emergency Rollback Command
mv /workspace/tmp/.trash_staging/* /workspace/tmp/Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

