storage-orphan-cleaner

Detects and quarantines orphaned Supabase Storage files without hard-deleting roofing CRM evidence.

Updated Sep 24, 2025
One-click install
npx skills add https://github.com/chriso789/pitch-1 --skill storage-orphan-cleaner-chriso789
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: storage-orphan-cleaner
Source: https://github.com/chriso789/pitch-1/tree/main/.agents/skills/storage-orphan-cleaner
Command: npx skills add https://github.com/chriso789/pitch-1 --skill storage-orphan-cleaner-chriso789

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Supabase Storage buckets in a roofing CRM accumulate orphaned, duplicate, misplaced, and improperly public files that are legal and claim evidence, so they cannot be safely hard-deleted without audit trails and retention controls. ## Core Features & Use Cases - Orphan Detection: Cross-references storage.objects against photos, documents, signed_documents, measurement_reports, permits, estimates, and other DB tables to find unlinked, duplicate, temp, and unreferenced mobile files. - Safe Quarantine Workflow: Moves flagged files to a quarantine bucket with checksum verification and a storage_quarantine audit row, never hard-deleting in the scanner. - Compliance Enforcement: Detects improperly public files containing signed docs, contracts, or PII and remediates them to private buckets with per-tenant scoping and legal-hold protection. - Use Case: A nightly pg_cron job scans each tenant's buckets in dry-run mode, writes findings to storage_orphan_scans, and a master-role admin reviews and restores or purges files from the /admin/storage-orphans UI after the retention window. ## Quick Start Ask the AI to run a dry-run storage orphan scan for one tenant and show which unlinked files would be quarantined.

Frequently Asked Questions about storage-orphan-cleaner

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find orphaned files in Supabase Storage?▼

Scan storage.objects and cross-reference each path against DB tables like photos.storage_path, documents.storage_path, and signed_documents. Files not referenced by any table are classified as unlinked and quarantined rather than deleted.

How to safely delete duplicate uploads in Supabase Storage?▼

Group files by md5 content hash and tenant_id prefix, keep the newest by created_at, and move the rest to a quarantine bucket with an audit row. Hard deletion only happens after the retention window expires via a separate master-only purge function.

Can Supabase Storage files be recovered after cleanup?▼

Yes, quarantined files can be restored through the storage_quarantine.restore() path, which moves the object back to its original bucket and path after verifying no conflict. Restore is master-only and clears the quarantine row.

Why should public buckets not store signed documents or invoices?▼

Signed docs, contracts, PII, and financial PDFs in public buckets are exposed to anyone with the URL. The improperly_public detector moves these files to the matching private bucket and updates the referencing DB row's URL in the same transaction.

What are the limitations of automated storage cleanup?▼

The scanner never hard-deletes, refuses files with legal_hold or signed/accepted/paid references, and requires one clean dry-run cycle before any new category goes live. Batches are limited to 10000 scanned and 2000 quarantined objects per run per tenant.