> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stably.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Run History (stably runs)

> Browse and inspect test run history from the command line

`stably runs` lets you browse test run history directly from the terminal — filter by branch, status, source, and more. Use it to investigate failures, check CI results, or pipe structured JSON into scripts and AI agents.

```bash theme={null}
# List recent runs
stably runs list

# Filter by branch and status
stably runs list --branch main --status failed

# View details for a specific run
stably runs view <runId>
```

## List Runs

`stably runs list` displays a table of recent test runs, sorted by most recent first.

```bash theme={null}
stably runs list [options]
```

### Options

| Option                 | Description                                                                                       |
| ---------------------- | ------------------------------------------------------------------------------------------------- |
| `-b, --branch <name>`  | Filter by branch name                                                                             |
| `-s, --status <type>`  | Filter by status: `queued`, `running`, `passed`, `failed`, `timedout`, `cancelled`, `interrupted` |
| `--source <type>`      | Filter by source: `local`, `ci`, `web`                                                            |
| `--trigger <type>`     | Filter by trigger: `manual`, `scheduled`, `ui`, `api`, `github_action`, `suite_run`               |
| `--suite <name>`       | Filter by suite name                                                                              |
| `-n, --limit <number>` | Number of runs to show (default: 20, max: 100)                                                    |
| `--after <runId>`      | Show runs newer than this run ID                                                                  |
| `--before <runId>`     | Show runs older than this run ID                                                                  |
| `--json`               | Output as JSON                                                                                    |

### Example Output

```
Run ID          Status       Branch                  Started              Tests
abc123def456    FAILED       feature/checkout        2025-06-15 10:30     50
789xyz012345    PASSED       feature/checkout        2025-06-15 09:15     50
fedcba987654    PASSED       main                    2025-06-14 22:00     48

Next page: stably runs list --before fedcba987654
```

### Filtering

Combine filters to narrow results:

```bash theme={null}
# Failed runs on a specific branch
stably runs list --branch main --status failed

# CI runs only
stably runs list --source ci

# Runs triggered by GitHub Actions
stably runs list --trigger github_action

# Failed runs from a specific suite, limited to 5
stably runs list --suite chromium --status failed --limit 5
```

### Pagination

Results are sorted newest-first. When more results exist, a pagination hint is displayed:

```bash theme={null}
# First page
stably runs list --limit 10

# Next page (use the run ID from the hint)
stably runs list --limit 10 --before <lastRunId>
```

Use `--after <runId>` to see runs newer than a given run, or `--before <runId>` to see older runs.

## View Run Details

`stably runs view` shows detailed information for a specific run, including test results and error messages.

```bash theme={null}
stably runs view <runId> [options]
```

| Option   | Description    |
| -------- | -------------- |
| `--json` | Output as JSON |

### Example Output

```
Run abc123def456
  Status:    FAILED
  Branch:    feature/checkout
  Commit:    a1b2c3d
  Started:   2025-06-15 10:30
  Duration:  2m 45s
  Source:    ci
  URL:       https://app.stably.ai/project/proj_xxx/playwright/history/abc123def456

Test Results: 47 passed, 2 failed, 1 flaky

Failed/Flaky Tests:
  FAILED  tests/checkout.spec.ts:42 - should complete purchase
          AssertionError: expected "Cart" to equal "Checkout"
  FAILED  tests/payment.spec.ts:15 - should process payment (3 attempts)
          TimeoutError: page.waitForURL timeout 30000ms exceeded
  FLAKY   tests/login.spec.ts:10 - should login successfully (2 attempts)
          TimeoutError: page.waitForSelector timeout 5000ms exceeded
```

The output includes:

* **Run metadata** — status, branch, commit SHA, timing, source, and a clickable URL to the web dashboard
* **Test results summary** — counts for passed, failed, flaky, timedout, skipped, and interrupted tests
* **Failed/flaky test details** — file location, test name, attempt count (for retried tests), and error message from the last attempt

<Tip>
  Click the **URL** in the output to open the run in the Stably dashboard, where you can view traces, screenshots, and step-by-step execution for each test.
</Tip>

## JSON Output

Use `--json` for structured output suitable for scripting, piping, or AI agent consumption:

```bash theme={null}
# List runs as JSON
stably runs list --branch main --status failed --json

# View run details as JSON
stably runs view <runId> --json

# Pipe to jq for processing
stably runs list --json | jq '.runs[] | select(.status == "FAILED") | .runId'
```

The JSON output passes the API response directly — date fields are ISO 8601 strings and null values are preserved as `null`.

<Accordion title="Example JSON: stably runs list --json">
  ```json theme={null}
  {
    "runs": [
      {
        "runId": "abc123def456",
        "suiteName": "chromium",
        "status": "FAILED",
        "startedAt": "2025-06-15T14:30:00Z",
        "finishedAt": "2025-06-15T14:32:45Z",
        "durationMs": 165000,
        "branchName": "feature/checkout",
        "commitSha": "a1b2c3d4e5f6",
        "totalCount": 50,
        "trigger": "GITHUB_ACTION",
        "source": "CI",
        "autoHealStatus": "COMPLETED"
      }
    ],
    "hasMore": true
  }
  ```
</Accordion>

<Accordion title="Example JSON: stably runs view --json">
  ```json theme={null}
  {
    "runId": "abc123def456",
    "projectId": "proj_xxx",
    "suiteName": "chromium",
    "status": "FAILED",
    "startedAt": "2025-06-15T14:30:00Z",
    "finishedAt": "2025-06-15T14:32:45Z",
    "durationMs": 165000,
    "branchName": "feature/checkout",
    "commitSha": "a1b2c3d4e5f6",
    "trigger": "GITHUB_ACTION",
    "source": "CI",
    "passedCount": 47,
    "failedCount": 2,
    "flakyCount": 1,
    "timedoutCount": 0,
    "skippedCount": 0,
    "interruptedCount": 0,
    "totalCount": 50,
    "autoHealStatus": "COMPLETED",
    "autoHealReport": {
      "summary": "Fixed 1 of 2 failing tests",
      "issues": [
        {
          "result": "fixed",
          "issueType": "test",
          "rootCause": "Selector changed after UI update",
          "fixApplied": "Updated selector to data-testid",
          "relatedTestCaseIds": ["tc-1"]
        }
      ]
    },
    "testCases": [
      {
        "testIdentifier": "tc-1",
        "title": "should complete purchase",
        "location": "tests/checkout.spec.ts:42",
        "status": "FAILED",
        "durationMs": 12000,
        "attemptCount": 1,
        "attempts": [
          {
            "attemptNumber": 1,
            "status": "FAILED",
            "errorMessage": "AssertionError: expected \"Cart\" to equal \"Checkout\"",
            "errorType": "AssertionError"
          }
        ]
      }
    ]
  }
  ```
</Accordion>

## Use with `stably fix`

`stably runs` pairs naturally with `stably fix` for investigating and repairing test failures:

```bash theme={null}
# Find the failing run
stably runs list --branch feature/checkout --status failed

# Inspect it
stably runs view <runId>

# Fix it
stably fix <runId>
```

The `stably fix` agent also uses run history internally to classify failures as regressions, pre-existing issues, or already-fixed problems — improving fix accuracy by understanding the broader context of each failure.

## Next Steps

<CardGroup cols={2}>
  <Card title="Fix Tests (stably fix)" icon="wrench" href="/stably-cli/fix">
    Automatically diagnose and fix failing tests
  </Card>

  <Card title="Run Tests" icon="play" href="/stably-cli/run-tests">
    Run tests locally or in CI with `stably test`
  </Card>
</CardGroup>
