Chaffbroom
Sections

Install Chaffbroom

Each product installs on its own, in a few minutes, from your repository. Do the part under Before you start once, then the chapter for each product you want.

Or let your coding agent do it: copy the setup prompt, paste it into the agent, and it asks before it changes anything.

Onboard your agent to Chaffbroom
1Add a workflowcopy the example YAML2Add secretsprovider tokens3Run report-onlyplan, no budget yet4Turn it ondeletion, budget gate
Set it up once: workflow, secrets, a report-only run to check the output, then switch on deletion or the budget gate.

Before you start

  • A GitHub repository where you can add workflows and repository secrets.
  • Node 20+ for npx chaffbroom or the library. The Actions run on node24, which is what GitHub runners provide.
  • For Chaffbroom Winnow: an API token for each provider you want swept, passed in as environment variables or Action inputs.
  • For Chaffbroom Tollbook: the job needs actions: read and pull-requests: write; the weekly issue needs issues: write.
  • Pin third-party actions to full commit SHAs, as the example workflows do.
  • What you pay, to GitHub and not to us: the Actions minutes these jobs use. They are free on public repositories and billed by GitHub on private ones. Provider and GitHub API calls use your own tokens and cost nothing.

Chaffbroom Winnow Free & source available

Deletes preview environments whose pull request is merged, closed or gone, or that are past their TTL.

Works withGitHubGitHubGitHub ActionsGitHub ActionsNeonNeonSupabaseSupabaseVercelVercelFly.ioFly.ioRailwayRailwayCloudflare PagesCloudflare PagesCloudflare WorkersCloudflare Workers

  1. GitHub Actions workflow (nightly sweep, plus reap on PR close)
    on:
      schedule:
        - cron: "17 3 * * *"
      pull_request:
        types: [closed]
      workflow_dispatch:
        inputs:
          mode:
            description: plan or apply
            default: plan
    
    permissions:
      contents: read
      pull-requests: read
    
    jobs:
      reap:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
          - name: Sweep
            if: github.event_name != 'pull_request'
            uses: chaffbroom/winnow@v0
            with:
              mode: ${{ github.event_name == 'schedule' && 'apply' || inputs.mode }}
              yes: ${{ github.event_name == 'schedule' || inputs.mode == 'apply' }}
              max-deletes: "50"
              neon-api-key: ${{ secrets.NEON_API_KEY }}
              supabase-access-token: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
              vercel-token: ${{ secrets.VERCEL_TOKEN }}
              fly-api-token: ${{ secrets.FLY_API_TOKEN }}
              railway-token: ${{ secrets.RAILWAY_TOKEN }}
              cloudflare-api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          - name: Reap this PR
            if: github.event_name == 'pull_request'
            uses: chaffbroom/winnow@v0
            with:
              mode: apply
              yes: "true"
              pr: ${{ github.event.pull_request.number }}
              # same provider tokens as above
  2. Install
    npx chaffbroom init        # shows the files it would write, writes nothing
    npx chaffbroom init --yes  # writes the config and the workflows
  3. CLI
    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
  4. Library
    // 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 });

It needs

  • 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.
  • NeonNeon: NEON_API_KEY (Action input neon-api-key).
  • SupabaseSupabase: SUPABASE_ACCESS_TOKEN (Action input supabase-access-token).
  • VercelVercel: VERCEL_TOKEN (Action input vercel-token).
  • Fly.ioFly.io: FLY_API_TOKEN (Action input fly-api-token).
  • RailwayRailway: RAILWAY_TOKEN (Action input railway-token). Project tokens use the Project-Access-Token header (token_kind: project).
  • CloudflareCloudflare: CLOUDFLARE_API_TOKEN (Action input cloudflare-api-token).
  • 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.

Chaffbroom Tollbook Free & source available

What GitHub Actions costs per pull request, reruns and cancelled runs included, as a sticky comment.

Works withGitHub ActionsGitHub ActionsGitHubGitHub

  1. GitHub Actions: cost job in the PR workflow
    on:
      pull_request:
    
    concurrency:
      group: ci-${{ github.ref }}
      cancel-in-progress: true
    
    jobs:
      cost:
        needs: [test]
        if: always()
        runs-on: ubuntu-slim
        permissions:
          actions: read
          pull-requests: write
        steps:
          - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
          - uses: chaffbroom/tollbook@v0
            with:
              mode: pr
              budget: "5.00"            # omit to report without gating
  2. GitHub Actions: weekly summary
    on:
      schedule:
        - cron: "0 7 * * 1"
      workflow_dispatch:
    
    permissions:
      actions: read
      contents: read
      issues: write
    
    jobs:
      summary:
        runs-on: ubuntu-slim
        steps:
          - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
          - uses: chaffbroom/tollbook@v0
            with:
              mode: weekly
              days: "7"
              top: "5"
              issue: "true"
  3. Install
    npx chaffbroom init        # shows the files it would write, writes nothing
    npx chaffbroom init --yes  # writes the config and the workflows
  4. CLI
    npx chaffbroom tollbook pr --pr 123             # text summary
    npx chaffbroom tollbook pr --pr 123 --comment   # create or update the sticky comment
    npx chaffbroom tollbook pr --pr 123 --budget 5  # exit 1 if over $5
    npx chaffbroom tollbook weekly --top 5 --issue  # weekly summary, also as an issue
    npx chaffbroom tollbook billing --org my-org    # GitHub's per-repo Actions spend this month
    npx chaffbroom tollbook prices                  # the price table, with its source and date

It needs

  • PR comment and budget gate: the cost job needs actions: read and pull-requests: write.
  • Weekly summary: actions: read and contents: read; posting the optional issue needs issues: write.
  • Net estimate (net: true): an org owner or billing manager token. GITHUB_TOKEN cannot read billing.
  • The billing command (per-repo spend) needs an org admin or billing token.
  • Without billing access the comment says Net cost unavailable and carries on with list price.
  • On fork PRs the token is read-only: posting the comment becomes a warning, and the budget gate still decides the exit code.

Use it from your coding agent

Copy-paste prompts that turn each CLI into a skill or command for any coding agent: it runs the tool, reads the JSON and sums it up for you. Nothing is deleted or posted unless you say so.