Repository avatar
Version Control
v0.2.0
active

gh-repro

io.github.dev-shiki/gh-repro

Extract minimal 1-line local repro commands and context from failing GitHub Actions runs.

Documentation

gh-repro

gh-repro MCP server

Extract deterministic 1-line local reproduction commands from failing GitHub Actions runs without spinning up Docker.

gh-repro reads failing GitHub Actions logs (gh run view --log-failed) alongside .github/workflows/*.yml, strips UTC timestamps, ANSI sequences, and group noise, redacts leaked credentials, and outputs the minimal local test or lint command with the step's working-directory and env.

Supported runners and linters

  • Python: pytest, ruff, mypy
  • Go: go test, golangci-lint
  • JavaScript / TypeScript: vitest, jest (including multi-line suite output with npx, pnpm, yarn, or bunx), bun test
  • Rust: cargo test
  • Generic fallback: reconstructs the failing workflow step's run: command when no specialized parser matches

Install

gh extension install dev-shiki/gh-repro

From source (Go 1.24+):

go install github.com/dev-shiki/gh-repro@latest

Or run via GHCR Docker image:

docker run -i --rm -e GH_TOKEN ghcr.io/dev-shiki/gh-repro:latest

CLI usage

# Inspect the latest failed workflow run in the current repository
gh repro

# Inspect failing checks on PR #123
gh repro --pr 123

# Inspect a specific run ID and emit JSON
gh repro --run-id 123456789 --json

# Offline analysis from a saved `gh run view --log-failed` file
gh repro --log-file failed.log

# Execute the first extracted reproduction command locally (opt-in only)
gh repro --pr 123 --run

# Print version
gh repro --version

Example output:

[1] test-python / Run pytest (pytest)
    cwd: backend
    env: map[APP_ENV:test DATABASE_URL:sqlite:///:memory:]
    cmd: pytest tests/test_auth.py::TestToken::test_refresh
    err: FAILED tests/test_auth.py::TestToken::test_refresh - AssertionError: expired token [REDACTED]

MCP server mode

gh-repro --mcp runs a read-only stdio MCP server (protocol 2025-06-18, compatible with 2024-11-05 through 2025-11-25) exposing three tools:

  • list_failed_runs: list recent failed GitHub Actions workflow runs (run_id, workflow_name, title, branch, event, created_at, url) for a repository or branch.
  • reproduce_ci_failure: synthesize a 1-line local test or lint command, working_dir, env, and redacted 20-line error_tail from a run_id, pr, latest failed run, or offline log_file.
  • get_failed_run_log: fetch ANSI-stripped, secret-redacted failed step log lines grouped by job and step when the 20-line tail is not enough.

Local gh extension config:

{
  "mcpServers": {
    "gh-repro": {
      "command": "gh",
      "args": ["repro", "--mcp"]
    }
  }
}

Container config:

{
  "mcpServers": {
    "gh-repro": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "-e", "GH_TOKEN", "ghcr.io/dev-shiki/gh-repro:latest"]
    }
  }
}

Security notes

  • Never executes extracted commands in MCP mode, or in CLI mode unless --run is explicitly passed.
  • Invokes exec.Command(bin, args...) directly without sh -c shell interpolation when --run is used.
  • Redacts ghp_, github_pat_, AKIA, sk-, and Bearer tokens from logs and error tails.
  • Parses .github/workflows/*.yml with structured gopkg.in/yaml.v3 decoding.