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

# Tools

> Check, format, test and package RSL with rslc, run the same commands in CI, and read the reference in the terminal.

`rslc` is one program with a command for each job. [Install Relativities](https://docs.canary.effectiveai.app/relativities/setup.md) to get it.
[Commands](https://docs.canary.effectiveai.app/rsl/reference/commands.md) lists every command and option.

| Job | Command | Passes when |
| - | - | - |
| Check a program | `rslc check FILE` | The selected check profile passes |
| Format a file | `rslc fmt FILE` | Always; it writes the one canonical layout |
| Check the format | `rslc fmt --check FILE` | The file has that layout already |
| Run a worked example | `rslc eval SCENARIO` | Each expected value equals the computed one |
| Package a rater | `rslc export FILE --format bundle --out OUT.zip` | The check passes |
| Explain a message | `rslc explain E-CODE` | The code exists |
| Read the reference | `rslc docs`, `rslc examples` | Always |

The examples on this page use RSL 0.4. [Author a rater in either edition](https://docs.canary.effectiveai.app/rsl/tutorial/author-a-rater-in-either-edition.md) shows how to use the RSL 0.5 preview to check and export a rater.

## Project layout

Keep one program in one folder. This page uses the `auto` example:

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc examples get auto
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
WROTE auto/enums/Territory.csv
WROTE auto/rater.rsl
WROTE auto/tables/BaseRate.csv
WROTE auto/tables/DeductibleFactor.csv
WROTE auto/tables/DriverClass.csv
WROTE auto/tables/LimitFactor.csv
WROTE auto/tables/MileageFactor.csv
WROTE auto/tables/TerritoryByZip.csv
WROTE auto/tables/ValueFactor.csv
```

| File | Holds |
| - | - |
| `rater.rsl` | The program and its worked scenario |
| `tables/*.csv` | One file for each rate table, named after the table |
| `enums/*.csv` | One file for each enumeration that the program reads from data |

Commit all of them. The bundle that `rslc export` writes is a build product.

## Check

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc check auto/rater.rsl
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
PASS auto/rater.rsl (strict)
cost premium: 27 + 7*|Policy.drivers| + 25*|Policy.vehicles| (each list of size 1: 59, 3: 123, 10: 347)
```

The `cost` line counts the work of one rating as the lists grow.
A failed check prints `FAIL` and one message for each problem, with its code, its place in the file and a fix.
[Guarantees](https://docs.canary.effectiveai.app/rsl/concepts/guarantees.md) states what a passing check proves.

To read why a check exists, pass the code of its message to `rslc explain`:

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc explain E-PROVENANCE
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
# E-PROVENANCE: A filed number needs a citation
...
```

The entry shows a file that gets the message, then the corrected file.
[Check messages](https://docs.canary.effectiveai.app/rsl/reference/check-messages.md) holds the same entries by topic.

## Format

RSL has one layout, and `rslc fmt` writes it. A team that formats on save sees only real changes in its diffs.

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc fmt --check auto/rater.rsl
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
PASS auto/rater.rsl is formatted
```

`rslc fmt FILE` rewrites a file in place and prints `FORMATTED FILE`. `--check` leaves the file as it is, and prints a diff when the layout differs.

## Test

`rslc eval` runs a scenario: one set of inputs and the values you expect. The `auto` rater holds its scenario in `rater.rsl`:

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc eval auto/rater.rsl
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
PASS auto/rater.rsl (passed)
targets: {"p.premium": {"Num": {"exact": "2240", "value": 2240.0}}, "v1.mileage_factor": {"Num": {"exact": "1.048", "value": 1.048}}, "v1.rated_age": {"Num": {"exact": "19", "value": 19.0}}}
PASS assertion: assert@p
PASS assertion: assert@v1
PASS assertion: assert@p
```

[Test a rater](https://docs.canary.effectiveai.app/rsl/how-to/test-a-rater.md) writes a scenario and adds independent premiums and sampled requests.
For a guideline, `rslc script` plays a submission and checks each step; see [Run a submission](https://docs.canary.effectiveai.app/rsl/how-to/run-a-submission.md#replay-a-submission).

## Packaging

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc export auto/rater.rsl --format bundle --out auto.zip
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
WROTE bundle: auto.zip
```

* Name a new output file. Export fails when the file exists already.
* Export also writes `rater-manifest.json` and `runtime/rslc_wasm.wasm` beside the source.
* Export leaves a scenario out of the bundle.

> [accordion] Bundle contents
>
> | File | Holds |
> | - | - |
> | `rater.rsl` | The source |
> | `tables/*.csv` | The rate tables |
> | `rater-manifest.json` | The engine identity and file hashes |
> | `runtime/rslc_wasm.wasm` | The engine that the bundle rates with |
> | `program-manifest.json` | The program identity and file hashes |
> | `program/input-schema.json` | The input contract |
> | `program/program.py` | A book schema and an identity `prepare` |
>
> A rater that imports other RSL files or reads enumeration members from CSV files carries those files too.
> The book schema follows the inputs of the rater, and the `prepare` function passes the values on unchanged.
> [Package a program](https://docs.canary.effectiveai.app/relativities/how-to/package-a-program.md) writes a `prepare` of your own.

[Rate submissions with a rater](https://docs.canary.effectiveai.app/relativities/how-to/rate-submissions-with-a-rater.md) loads the bundle in Python.

## CI

A job that runs these commands holds a project to its format, its checks and its worked examples:

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc fmt --check auto/rater.rsl
rslc check auto/rater.rsl
rslc eval auto/rater.rsl
```

Each command gives its result as its exit status, so the job stops at the first failure:

| Exit status | Meaning |
| - | - |
| `0` | The command passed |
| `1` | A check failed, the format differs, an expected value differs, or a file is missing |
| `2` | The command line is wrong |

Install the same release of `rslc` in CI as on each author's machine.
[Versions](https://docs.canary.effectiveai.app/rsl/concepts/versions.md) explains which number is which.

## Terminal reference

`rslc docs` prints the reference of the installed version, offline:

```sh theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
rslc docs
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
RSL 0.4.2 reference. Run `rslc docs TOPIC`:

  sections     the sections of a file, in order
  types        the types and type forms
  functions    the functions; `rslc docs round` explains one
  annotations  the annotation keys, such as `cite` and `ask`
  messages     the check messages; `rslc explain E-CODE` explains one

`rslc examples` lists the example raters.
```

The same text builds the reference pages of this site, such as [Names](https://docs.canary.effectiveai.app/rsl/reference/names.md) and [Functions](https://docs.canary.effectiveai.app/rsl/reference/functions.md).
`rslc examples get NAME` saves a complete program that passes the check.

## Editors and agents

* **Format on save.** Run `rslc fmt FILE` when the editor saves an `.rsl` file.
* **Show the messages.** `rslc check --json FILE` prints one JSON object. It holds `ok`, the `cost`, and each diagnostic with its `code`, `message` and `location`.
* **Give an agent the reference.** An agent that writes RSL reads `rslc explain`, `rslc docs` and `rslc examples` in place of a web search. They match the installed compiler.

Each command takes `--json` and then prints one JSON value on standard output.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.