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

# Rules

> Standing instructions that load always, or only when the session touches a matching file.

A rule is a standing instruction rather than something you invoke. Put one at
`.seri/rules/<name>.mdc` for this project, or under your profile root for every project. The
extension is `.mdc`, which is the only name a rule has.

```markdown theme={null}
---
description: TypeScript conventions for this repo.
globs: "**/*.{ts,tsx}"
alwaysApply: false
---

Make illegal states unrepresentable. Parse external data at the boundary.
```

## When a rule loads

Frontmatter decides it, and there are exactly three outcomes.

| Frontmatter         | Trigger  | Effect                                                   |
| ------------------- | -------- | -------------------------------------------------------- |
| `alwaysApply: true` | always   | in the prompt for the whole session, next to `AGENTS.md` |
| `globs:` set        | on touch | arrives when the session touches a matching file         |
| `description` only  | inert    | loads nothing, and says so at startup naming the file    |

A file setting both `globs` and `alwaysApply: true` is always-on and is never also injected per
touch. `alwaysApply` wins.

## How a glob rule arrives

The rule stays out of the prompt until a `read_file` or `write_file` lands on a matching path.
Then it arrives as a note in the conversation, once per session rather than once per file.

Matching a `read_file` is deliberate. It puts the rule in front of the model **before** it
composes the edit, rather than after.

**The rule text never enters the system prompt mid-session.** That string is frozen when the
session starts, and keeping it frozen is what lets a provider reuse its cached prefix for every
turn. A rule that fires appends to the conversation instead, which is where every tool result
already goes.

## Writing globs

Patterns accept `**`, braces and ranges. A comma-separated list is several patterns, while commas
inside `{…}` stay part of one.

```yaml theme={null}
globs: "**/*.{ts,tsx,js,jsx}"        # one pattern, commas inside braces
globs: src/**,scripts/**             # two patterns, commas between them
```

Paths are matched relative to the worktree with separators normalised, so `src/**` means the same
thing on Windows, macOS and Linux.

<Note>
  Rules are human-authored, like `AGENTS.md`. seri never writes one. The one artifact it proposes
  is a [skill](/guides/skills).
</Note>
