# Validate in CI

> Run alta lint on every push and pull request, fail the build on a problem, and keep the report as JSON.

You add one workflow file to your content repository: every push and every pull request runs `alta lint`, the build fails on the first problem, and the full report is kept as JSON for your tools. It is the same check as on your machine, so what passes there passes here.

**Before you begin (10 minutes)**

- A repository with content that passes `alta lint`, for example the pack of the [quickstart](https://docs.altasystem.ai/quickstart).
- GitHub Actions on that repository. Any other CI works the same way: it runs the same commands.

### Check the repository as the CI will

Run the check from the root of your repository. `.` checks every content file below it: each `.json` with a `"schema"`, and each universe folder. `--strict` makes a warning fail too, so nothing slips into the main branch half done.

```sh [Terminal]
alta lint . --strict
```

```text [Output]
ok   my-pack/quests.json (quests)
1 checked, 0 errors, 0 warnings
```

### Read the JSON report

`--json` prints the report in the `alta.check/1` format: `ok`, then each file with its `problems` and `warnings`. A problem gives the `field`, the `rule` (its section on the [errors page](https://docs.altasystem.ai/reference/errors)), the `message`, and where it is in `context`. The exit code says the verdict: `0` ok, `1` problems found, `2` bad usage.

```sh [Terminal]
alta lint . --json
```

```text [Output (shape)]
{
  "schema": "alta.check/1",
  "ok": false,
  "files": [
    {
      "path": "my-pack/quests.json",
      "kind": "quests",
      "ok": false,
      "problems": [
        {
          "level": "error",
          "field": "quests[0].steps[0].kind",
          "rule": "step.kind",
          "message": "…",
          "docs": "https://docs.altasystem.ai/reference/errors#step-kind",
          "context": { "where": "quest core.my-pack.welcome, step read" }
        }
      ],
      "warnings": []
    }
  ],
  "skipped": []
}
```

### Add the workflow

Save this file as `.github/workflows/alta-check.yml`. It installs the `alta` command as on your machine, runs the strict check (the step that fails the build), then keeps the JSON report as a build artifact, even when the check failed.

```yaml [.github/workflows/alta-check.yml]
# A GitHub Actions workflow for a content repository: every push and pull request runs `alta lint`.
# Save it as .github/workflows/alta-check.yml in your repository.
name: alta lint

on: [push, pull_request]

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

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

      - name: Install the alta command
        working-directory: ${{ runner.temp }}
        run: |
          git clone --depth 1 https://github.com/altasystem-ai/alta.git
          cd alta-os
          npm install
          npm install --global ./tools/cli

      - name: Check the content
        run: alta lint . --strict

      - name: Keep the report as JSON
        if: always()
        run: alta lint . --json > "${{ runner.temp }}/alta-check.json" || true

      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: alta-check
          path: ${{ runner.temp }}/alta-check.json
```

### Push, and read the result

Push the workflow. On every push and pull request, the job runs; a red job prints each problem with its file, its field, how to fix it and the link to its rule. The `alta-check` artifact holds the JSON report.

```sh [Terminal]
git add .github/workflows/alta-check.yml
git commit -m "Check the content on every push"
git push
```

## Pitfalls

| Do | Avoid |
|---|---|
| Write the JSON report outside the folder you check | `alta lint . --json > report.json`: the next check reads `report.json` as content |
| `--strict` in CI, so a warning blocks the merge | Letting warnings pile up until they matter |
| One `alta lint .` at the root | A list of files to keep up to date by hand |
| The same Node version as on your machine (20 or later) | An older Node: the command needs 20 |

Known limits, said plainly: `alta` is not on npm yet, so the workflow installs it from the repository, as on your machine. Files without a `"schema"` are skipped and listed under `skipped`: that is how a `package.json` stays out of the check.

## Go further

- [alta lint](https://docs.altasystem.ai/reference/cli/lint): every option and the exit codes.
- [Errors](https://docs.altasystem.ai/reference/errors): each rule the report can name.
- [Standards and versions](https://docs.altasystem.ai/concepts/standards-and-versions): what changes when a standard moves.

**Next:**

- [Connect the author MCP](https://docs.altasystem.ai/guides/tools/connect-mcp)
- [Publish a chart](https://docs.altasystem.ai/marketplace/publish)
- [alta lint](https://docs.altasystem.ai/reference/cli/lint)
