Chaffbroom Winnow finds and deletes orphaned preview environments on Neon, Supabase, Vercel, Fly.io, Railway and Cloudflare. It decides by the state of each preview's pull request and by its age. It is a library, a CLI and a GitHub Action. It plans by default and deletes only when you pass --yes.
Works withGitHubGitHub ActionsNeonSupabaseVercelFly.ioRailwayCloudflare PagesCloudflare Workers
Chaffbroom Winnow checks each preview's pull request and deletes only the ones whose PR is merged or closed. Open PRs and protected branches stay.
What it catches
Previews whose mapped PR is merged or closed without merge, after a grace period (grace_after_close).
Previews whose PR number gives a 404 on GitHub, but only after repo access with your token was verified in the same run.
Previews older than the provider TTL. A TTL never deletes an open PR's preview unless reap_open is true.
Previews with no PR mapping, reported as no-pr-mapping. They are deleted with reap_unmapped: true, or by the TTL when no PR number or branch was found at all.
npx chaffbroom init # shows the files it would write, writes nothing
npx chaffbroom init --yes # writes the config and the workflows
CLIsh
npx chaffbroom winnow plan # list orphans, change nothing
npx chaffbroom winnow plan --show-kept -f json # everything, machine-readable
npx chaffbroom winnow apply --yes # delete what plan marked "delete"
npx chaffbroom winnow apply --yes --pr 123 # only this PR's previews (skips the close grace)
npx chaffbroom winnow plan --fail-on-orphans # exit 1 if anything is deletable
Libraryts
// not on npm: build it from a clone of the repository
// git clone --depth 1 https://github.com/chaffbroom/chaffbroom .chaffbroom
// cd .chaffbroom && npm ci && npm run build:lib -w winnow
import { loadConfig, plan, apply, render } from './.chaffbroom/winnow/lib/index.js';
const p = await plan({ config: await loadConfig('.winnow.yml'), fetch });
console.log(render(p, 'markdown'));
await apply(p, { yes: true });
GitHubGitHub: GITHUB_TOKEN with contents: read and pull-requests: read, to look up each preview's PR. Secrets are not passed to pull_request runs from forks.
Only the tokens for providers you enable are needed. A missing token skips that provider, the others still run, and the exit code is 1.
Privacy
Runs on your own runner with your own tokens and sends nothing anywhere else.
Tokens come from the environment; the optional .winnow.yml holds settings, not secrets.
Resource names, branches and provider error text are escaped in the job summary: no HTML, no Markdown, no @mentions.
Log lines stay on one line, so a hostile name cannot start a workflow command.
Limits
Deletes use the id the provider's list API returned, never a name.
Protected resources are never listed as deletable: default and primary branches, production deployments and environments, the latest Worker version, and anything listed under protect in the config.
Fail closed: if your token cannot read the repo, no preview is classed merged, closed or missing and all mapped previews are kept.
Any other PR lookup error (5xx, 429, network) keeps the preview with the note PR lookup failed.
Railway PR environment naming is unverified: no real payload was checked. Run plan and check the pr column before the first apply, and set pr_pattern if needed.
Cloudflare documents no API to delete a Worker version, so Workers versions are report-only.
Fork PR previews can only be found by explicit PR number, or by branch where the provider names the head owner (Vercel); a miss is kept.
Fly apps have no created_at, so age is the oldest machine's; app_pattern is required so production apps are never in scope.
Set up Chaffbroom (https://github.com/chaffbroom/chaffbroom) in this repository and try it. Chaffbroom is two free tools, source available under FSL-1.1-ALv2, that run with my own tokens and send nothing anywhere: Winnow finds stale preview environments, Tollbook shows what GitHub Actions costs per pull request.
Rules:
- Before you add or edit any file, list the files and the change, and wait for my yes.
- Never ask me to paste a token or secret into this chat, and never print one. Use tokens already in the environment, or `gh auth token`. I add repository secrets myself.
- Read only: never run winnow apply, never post a comment, never open an issue.
- No key, account or payment is needed. Support and the org-wide report are Enterprise: chaffbroom@sivakoza.ai. Do not try to set those up.
Steps:
1. Use the npm package chaffbroom: `npx chaffbroom ...`. It is one bundled file with no dependencies and needs Node 20+; npx fetches it on first use (add --yes after npx if the shell cannot answer npx's question).
2. Tollbook: run npx chaffbroom tollbook weekly --repo <owner/name> --days 7 --top 5 --format json with GITHUB_TOKEN from `gh auth token` (it needs actions: read). Sum up the total cost, the top workflows and the rerun waste. Money is in micro-dollars, at list price.
3. Run npx chaffbroom init --dry-run and show me what it would write: .winnow.yml with the preview providers it found, and the workflows (Winnow starts in plan mode). If it found the wrong providers, run it again with --provider <id>. After my yes, run the same command with --yes instead of --dry-run, and show me the `gh secret set` lines it prints; I run those myself. Say that the jobs use GitHub Actions minutes, which GitHub bills on private repositories.
4. Once I have filled in the ids in .winnow.yml, run npx chaffbroom winnow plan --format json and report what would be deleted, and which providers were skipped for a missing token.