# Add a project rule

Source: https://usecns.dev/soma-guide-add-a-project-rule/

[Start here](https://usecns.dev/manual-soma/)
[CLI commands](https://usecns.dev/commands-soma/)
[Configuration & integration](https://usecns.dev/soma-topics/)

Install the published binary; no source compilation is required.

* **macOS (arm64):** `brew install ivannovak/cns/soma`. The tap is private; downloads need `HOMEBREW_GITHUB_API_TOKEN` set to a token with read access.
* **Ubuntu 20.04 LTS and later LTS releases (x86\_64 and aarch64):** install the release tarball with the CNS Linux installer, which places the binary in `~/.local/bin`. See [installation and access](https://usecns.dev/install/).

With the installed binary, start in a Git repository that does not yet use Soma:

```
soma init --curator '@maintainer'
```

The default layout separates files you maintain from files Soma generates:

* **`docs/soma/`:** reviewed documentation and concern files. Track these in Git.
* **`.soma/`:** generated maps, source pins and derived records. Update their inputs rather than editing generated output.
* **`soma.toml`:** repository configuration, including documentation paths and the default comparison branch.

Create a concern from the template:

```
soma concerns init invoice-idempotency --severity warning
```

Edit the generated file to explain:

1. **The rule:** retries must preserve the original idempotency key.
2. **The consequence:** changing the key could charge a customer twice.
3. **The trigger:** changes to the invoice retry code.
4. **The review question:** "Does retrying an invoice preserve its original idempotency key?"
5. **The source:** the file or symbol implementing retry behavior.

Keep the generated section structure. Make the trigger narrow enough to identify relevant edits, and use explicit `[expect: yes]` or `[expect: no]` markers for questions. See [concern formats and trigger choices](https://usecns.dev/soma-topic-author-triggers-and-questions/) for the details, or [repository configuration](https://usecns.dev/soma-topic-configure-repository-discovery/) to change the default paths.

Validate the edited concern and regenerate its index:

```
soma concerns validate invoice-idempotency
soma concerns lint --polarity
soma concerns index
```

After checking that the explanation and its linked source agree, record the source pins and verify:

```
soma docs reconfirm 'concerns/invoice-idempotency.md'
soma verify
```

Reconfirming records the source you reviewed. It does not establish that the explanation is correct. If a pin later drifts, inspect the source and prose before updating it.