Skip to main content
mux run is designed for automation scenarios like CI/CD pipelines. This guide shows how to integrate mux into your GitHub Actions workflows.

Prerequisites

  1. API Key: Add your ANTHROPIC_API_KEY (or other provider key) to your repository’s secrets. See Providers for details on configuring API keys.
  2. npm/bun: The workflow will install Mux via bunx or npx

Basic Usage

Here’s a minimal example that runs Mux in a GitHub Action:
- name: Mux Review
  env:
    ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
    GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  run: bunx mux run "Review this PR for critical issues. If any are found, exit with 1 to block merge."
mux run supports agent-controlled exit codes, so the workflow step can fail when issues are found.

Key Options for CI

OptionPurpose
--quietOnly output final result (cleaner logs)
--jsonMachine-readable NDJSON output for parsing
--budget <usd>Limit spending per run (e.g., --budget 1.00)

Example: Auto-Cleanup Workflow

This is the exact workflow used live in the Mux repo (see .github/workflows/auto-cleanup.yml). It runs periodically to identify low-risk cleanup opportunities and maintains a refactor PR with improvements. The prompt is stored in a separate file (.github/prompts/auto-cleanup.md) and piped via stdin, keeping the workflow file clean and the prompt easy to iterate on.
# Periodically cleans up the codebase and maintains a refactor PR.
# SETUP: Add ANTHROPIC_API_KEY to repository secrets.

name: Auto-Cleanup

on:
  schedule:
    - cron: "0 */4 * * *" # Every 4 hours
  workflow_dispatch:

permissions:
  contents: write
  pull-requests: write

jobs:
  cleanup:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
        with:
          fetch-depth: 0
      - uses: oven-sh/setup-bun@b7a1c7ccf290d58743029c4f6903da283811b979 # v2.1.0

      - name: Cleanup with mux
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          [ -z "$ANTHROPIC_API_KEY" ] && echo "Skipping (no API key)" && exit 0

          bunx mux@next run \
            --model anthropic:claude-opus-4-6 \
            --thinking xhigh \
            < .github/prompts/auto-cleanup.md