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

# Rules text

> A portable, plain-text format for one scenario's rules.

Rules text holds the rules for one [scenario](https://docs.allocait.app/concepts/scenarios.md) and nothing else. Each asset class gets an allocation band (how much of the portfolio the class may take), a size range for one long holding, a size range for one short, or any mix. In the app, Allocait reads the text, shows you what would change, and applies it only after you approve. An agent that calls `apply_rules`, or the REST API with `dry_run` false, writes when it makes the call. Allocait does not require a preview first.

You or an agent can edit the text outside the app and import it back. [Write your rules](https://docs.allocait.app/guides/write-your-rules.md) walks through the steps, and [Rules text format](https://docs.allocait.app/concepts/rules-text-format.md) lists every key. The [full spec](https://allocait.app/rules/spec.md) is the text agents read.

## Example

Illustrative example. The figures are hypothetical, not a recommendation.

```markdown theme={null}
---
version: 1
name: Example rules
classes:
  Equities: { target: 53, min: 44, max: 67, position_size: { min: 3, max: 9 }, short_position_size: { min: 1, max: 5 } }
  Fixed Income: { target: 24, min: 18, max: 29 }
  Cash: { min: 3, max: 11 }
---

# Notes

Anything you like goes here. Allocait ignores everything below the second `---` line.
```

The text is one frontmatter block of rules, then notes. [Rules text format](https://docs.allocait.app/concepts/rules-text-format.md) explains each key, the defaults and the class names.

## Importing

Import replaces all of the scenario's rules with what's in the text. Classes named in the text get rules; any class not named loses its rule. Import never renames, reorders, or deletes an asset class. Restoring an import's restore point can remove a custom class that import created, if nothing uses it.

In the app, before anything is written, Allocait shows a preview: every class that would change, be added, or be removed, old value next to new. In the app, nothing applies until you approve it.

Before an import writes anything, Allocait saves a restore point of the scenario's current rules. An agent's `save_class_rule` call saves one too. Restoring one puts the scenario's rules back as they were at that point and undoes any later changes. It also removes a custom class that the import created, if nothing uses that class. A restore saves a new restore point, so it can be undone the same way. Allocait keeps the newest 20 restore points per account. Restore points are for undoing the whole scenario. Separately, the Rules tab lists the recent past values of each class rule, newest first; an agent reads them as `rule_changes` on `get_rules`. Allocait keeps no reasoning with either.

> [!NOTE]
>
> A scenario with no rules yet has no rules text to show. Allocait says so plainly instead of showing an empty text.

## Next steps

* [Write your rules](https://docs.allocait.app/guides/write-your-rules.md) turns your own rules into rules text and imports it.
* [Rules text format](https://docs.allocait.app/concepts/rules-text-format.md) lists every key and default.
* [Scenarios](https://docs.allocait.app/concepts/scenarios.md) explains which scenario an import replaces.
* [Allocation bands](https://docs.allocait.app/concepts/allocation-bands.md) and [Size ranges](https://docs.allocait.app/concepts/position-sizes.md) explain how each rule is checked.


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