# 3. A rule that comes back

Source: https://usecns.dev/your-repo-rules/

[On your repository](https://usecns.dev/your-repo/) · [1. Find](https://usecns.dev/your-repo-find/) → [2. Before you push](https://usecns.dev/your-repo-before-push/) → **3. A rule that comes back** → [4. Memory that earns trust](https://usecns.dev/your-repo-memory/) → [5. Two weeks later](https://usecns.dev/your-repo-later/)

**You want to:** stop writing the same review comment by hand.

**You leave with:** one project rule, authored by you, that appears whenever the code it is about changes, with Axon's structural evidence attached, and a clear understanding of why it starts as a report rather than a gate. Adds Soma.

## Before you start

Have `soma` installed alongside `axon`; see [installation](https://usecns.dev/install/). Continue in the repository from the earlier steps. This step writes files meant for review under `docs/soma/` and generated maps under `.soma/`. If the repository already has a Soma configuration, read it before running `init`.

## Choose the rule

Pick a review comment you have written more than once in this repository. Good candidates are rules that the type system cannot express and that a test does not cover: a key that must be reused across a retry, a field that must never be logged, a migration that must be reversible, an event that must be published after the transaction commits. Write the rule as one sentence, and name the files or symbols it is about.

## Write it down

```
soma init --curator '@you'
soma concerns init <rule-id> --severity warning
```

Edit `docs/soma/concerns/<rule-id>.md`. The template has front matter and sections; the [first-steps lesson](https://usecns.dev/tutorial-soma/) shows a complete example. For a real repository, write:

* a **`path` trigger** on the files the rule is about. Once you want the rule to follow the code rather than the file, a `symbol` or `reaches` trigger does that using Axon's evidence;
* `state: shadow`, so the rule reports but does not gate;
* the **consequence** if the rule is broken, in one sentence;
* the **questions** a reviewer must answer, each marked `[expect: yes]` or `[expect: no]`;
* an **instrument**: the test or inspection that settles the question, with a `[[file:...]]` anchor on the code it checks.

Then validate, index and verify:

```
soma concerns validate <rule-id>
soma concerns index
soma docs reconfirm --all
soma verify
```

Commit `soma.toml` and `docs/soma/` on your branch through your normal review. Generated state in `.soma/` stays local.

**What you should notice:** the rule now has a home other than your memory and your review comments. Teammates and agents can read why it matters, not just that it does.

**Does not prove:** that the rule is right. Have the owner of the rule read it.

## Watch it come back

Make an edit to one of the files the trigger names, the kind of edit you would normally make, then check:

```
axon index --json
soma concerns check --base main --axon axon
```

`--axon axon` gives Soma the structural evidence from step 2. The report lists the concerns that fired and whether each is shadow or active.

**What you should notice:** the rule appears in the report before any test runs, with the questions you wrote. If the edit was harmless, the questions are quick to answer. If it was not, the rule has done its job earlier than a reviewer would have. Edits with no failing test are where this matters most; a rule can fire on a change that is wrong in a way no assertion checks.

**Does not prove:** that the change is wrong. A path trigger fires on any edit to the file, including a comment. The report is a request to answer the questions, and the instrument you named is what settles them. Run it.

## Hand the rule to an agent

Give a coding agent the report and the concern file:

```
Read docs/soma/concerns/<rule-id>.md and the output of
`soma concerns check --base main --axon axon`. Use `axon trace` on the
symbols the report names to find the affected callers. Answer each
concern question with file-and-line evidence. Run the instrument it
names. Say what Soma checked, what you checked, and what still needs
a person.
```

**What you should notice:** the agent's answer is organised around your questions, not around whatever it happened to grep first.

## When to make it a gate

A shadow rule that has fired usefully a few times is a candidate for promotion. Promotion is deliberate: the rule's tolerance is checked against history first, and the activation lands on the review base before it can gate a change. The [third first-steps lesson](https://usecns.dev/tutorial-soma-gate/) walks the commands; the [concern lifecycle contract](https://usecns.dev/contract-concerns/) is the rule for your repository. Once a rule is active, `soma concerns check --check` exits non-zero when it fires.

**What you should notice, the first time an active rule blocks a change you agree should be blocked:** that is the moment this stops being documentation and becomes part of how the repository defends itself.

**Does not prove:** anything about changes the rule did not fire on. Absence of a match is not a review.

## What you have

One rule that comes back, written once, attached to the code it protects, with the structural evidence to investigate it. Soma carries the reason; Axon carries the structure; your test carries the verdict.

**Next:** [record what a session learned and see it come back, age and graduate →](https://usecns.dev/your-repo-memory/)