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

# Add Reikon to CI

> Gate a CI pipeline on health score using rei's exit codes.

# Add Reikon to CI

`rei`'s exit codes — `0` clean, `1` warnings, `2` errors/failing health — are designed
to gate a CI step directly, no wrapper script needed.

## GitHub Actions

```yaml theme={null}
name: Code health check

on: [pull_request]

jobs:
  health:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0   # full history — bus factor and churn need real git log, not a shallow clone

      - uses: actions/setup-node@v4
        with:
          node-version: 20

      - run: npm install -g @reikondev/cli

      - run: rei analyze --format summary --quiet
```

This fails the job (exit code 1 or 2) if the health score drops below your configured
thresholds. A shallow checkout will skew bus factor, churn, and commit-quality numbers
since they're computed from full commit history — `fetch-depth: 0` matters here, it's
not just a safe default.

## Tuning the gate

By default, the job fails (exit 2) only below a health score of 50, and warns (exit 1,
doesn't fail the job unless you check for it) below 70. Adjust both in
`.reikon/config.json`:

```json theme={null}
{
  "cli": { "warnBelow": 80, "failBelow": 60 }
}
```

## Failing the job on warnings too

`rei`'s own exit code already distinguishes warn (1) from fail (2) — if you want
warnings to fail the build as well, just don't special-case exit code 1:

```yaml theme={null}
      - run: rei analyze --format summary --quiet
        # any non-zero exit (1 or 2) fails this step, and the job, by default
```

If you'd rather warnings *not* fail the build (only hard failures should), check the
exit code explicitly:

```yaml theme={null}
      - run: |
          rei analyze --format summary --quiet
          code=$?
          if [ $code -eq 2 ]; then exit 1; fi
          exit 0
```

## Posting results as a JSON artifact

```yaml theme={null}
      - run: rei analyze --format json --output reikon-report.json
      - uses: actions/upload-artifact@v4
        with:
          name: reikon-report
          path: reikon-report.json
```

## Other CI systems

The same pattern applies anywhere that can run a shell command and check its exit
code — GitLab CI, CircleCI, Jenkins, etc. The only GitHub-Actions-specific part above is
the YAML syntax; `rei`'s behavior is identical everywhere.

## Next

[Full CLI reference](../reference/cli) for every flag and the complete config shape.
