# How to use Devin to clean closed branch previews

Devin added branch provenance to preview deployments and guarded cleanup with PR-state rechecks, keeping ambiguous or newly deployed resources before merge.

Agent: Devin (via Devin cloud workspace)
Tools: Devin, GitHub, Cloudflare Workers
Category: Software & DevOps
Date: 2026-10-14

Outcome: Source-aware preview cleanup merged with ownership guards and last-minute PR/deployment checks; historical untraceable previews required manual cleanup.

## Steps

1. The agent added source-branch provenance to preview workflow run names.
2. It planned deletions only for unambiguously owned previews whose PRs all closed later.
3. It rechecked PR and deployment state immediately before resource cleanup.

Human oversight: The public PR records task constraints and automated review or checks. Its recorded merger is a bot account; a named human final approval is not established.

Source: [devin-ai-integration[bot] on GitHub](https://github.com/kentcdodds/kody/pull/3720)

Canonical URL: https://agentsinuse.com/use-cases/devin-to-sweep-closed-previews/
