artifact-retention-and-cleanup
Artifact Retention and Cleanup
Use this skill when artifacts need a retention decision or a bounded cleanup. It is a JIT procedure, not a daemon, background purge, new storage service or permission to clean the host. Respect the task's roots and existing authorization; planning or inspecting candidates does not authorize destructive changes. Do not add a cleaner executable unless the task separately requires one.
Establish scope and capacity
Identify the owner, allowed roots/resource IDs, purpose and capacity problem: full filesystem, growing task output, expired preview, completed worktree, or redundant recovery copy. Read existing retention/rollback/privacy requirements. Record filesystem or service capacity before work, using comparable units and the actual affected mount/quota; distinguish allocated disk, apparent file sizes and service-reported storage.
A near-full disk justifies prioritization, not broader deletion. Prefer verified task-owned regenerable material. Do not scan arbitrary private/home/server locations or prune whole providers merely because a scoped candidate lives there. If authorized scope cannot recover enough capacity, report the measured shortfall and safe remaining options.
Classify by recoverability
| Class | Required evidence before retirement |
|---|---|
| Cache or dependency download | Exact owner/tool and root, no active writer/consumer, and a usable refill source. Offline needs, local patches and unavailable versions may make it valuable. Prefer the tool's bounded cleanup interface. |
| Regenerable build/test output | Retained source, manifests/lockfiles, generation command and required tool/input availability. Check that it contains no unique uploads, local configuration or unresolved failure evidence. |
| Task evidence, preview or worktree | Task/worker is finished and inactive; no open failure, reviewer, issue, handoff or active reference needs it. Preserve the minimal useful receipt/reproduction. A clean checkout or old timestamp alone proves none of this. |
| Backup, snapshot or rollback artifact | Explicit retention/expiry policy, retained recovery coverage and dependencies, rollback window closed, and relevant restore/integrity evidence. Keep the last verified recovery path; an untested replacement or a newer filename is insufficient. |
| Private/business data, credentials, databases or unknown content | Preserve by default. Follow the data owner's explicit retention/privacy/deletion authorization and domain procedures. Git sync or successful build does not make this data regenerable. |