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-Label Issues and PRs

This is the exact workflow used live in the Mux repo (see .github/workflows/auto-label.yml). It automatically labels new issues and pull requests by having mux analyze the content and select appropriate labels from your repository’s label set.
# Auto-labels new issues and PRs using mux.
# SETUP: Add ANTHROPIC_API_KEY to repository secrets.
# Fork PRs are skipped (no secret access).

name: Auto-Label

on:
  issues:
    types: [opened]
  pull_request:
    types: [opened]

permissions:
  issues: write
  pull-requests: write

jobs:
  label:
    runs-on: ubuntu-latest
    if: github.actor != 'dependabot[bot]'
    steps:
      - uses: actions/checkout@v4
      - uses: oven-sh/setup-bun@v2

      - name: Label with mux
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          TYPE: ${{ github.event_name == 'pull_request' && 'pr' || 'issue' }}
          NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }}
        run: |
          [ -z "$ANTHROPIC_API_KEY" ] && echo "Skipping (no API key)" && exit 0

          bunx mux@next run --budget 0.50 "
            Label this GitHub $TYPE using ONLY existing labels. Steps:
            1. gh label list --json name,description
            2. gh $TYPE view $NUMBER
            3. gh $TYPE edit $NUMBER --add-label <labels>
            Pick 1-3 labels from the list in step 1. Do NOT create new labels.
            If no existing labels fit well, skip step 3.
          "