Skip to main content

Rules

What a rule is​

A rule is a Markdown file with instructions that the agent receives automatically. You don't have to repeat the same requirements in every chat: response language, code style, the libraries the project uses.

Kinds of rules:

  • Global: a personal rule for all projects, for example to make the agent answer in the same format everywhere. It lives in ~/.explyt/rules/.
  • Project: the conventions of one repository. It lives in <project>/.explyt/rules/; you can commit the file, and the whole team gets the rule.

You can create subdirectories inside rules/: every .md file is a rule.

tip

Ask the agent: "Create a rule: this project uses Kotlin 2.0 and data classes instead of records". It creates the file with the right frontmatter itself.

Where the agent looks for rules​

PathRule IDFormat
~/.explyt/rules/**/*.mdglobal:.explyt/rules/team.mdfrontmatter + Markdown
<project>/.explyt/rules/**/*.mdproject:.explyt/rules/team.mdfrontmatter + Markdown
<project>/AGENTS.mdproject:AGENTS.mdplain Markdown

Compatibility with other tools​

Explyt CLI always reads AGENTS.md in the project root, with no extra setup. It is read as is, without frontmatter, and applies to the whole session.

CLAUDE.md files and the rules of Cursor, Codex and OpenCode are read only after you allow them. See Rules of other agents.

Keep these limits in mind:

  • AGENTS.md and CLAUDE.md in project subdirectories are not read, only in the root.
  • Parent directories are not searched: the project root is the directory where you started explyt.
  • Create new rules in .explyt/rules/, where every feature of the format is available.

Rules of other agents​

If you are moving from Claude Code, Cursor, Codex or OpenCode, you don't need to copy their rules: Explyt CLI can read them in place. The files are only read and never changed.

By default these files are not read. When the agent finds another agent's files at the start of a session, it asks whether to read them, separately for the home directory and for the project. In the terminal, /import-agents opens the same window again so that you can change your answers.

The answers are stored in the otherAgents section of the global ~/.explyt/settings.json. You can also edit it by hand:

{
"otherAgents": {
"enabled": ["claude", "codex"],
"projectDefault": { "cursor": "deny" },
"projects": { "/home/me/work/app": { "cursor": "allow", "claude": "allow" } }
}
}
KeyWhat it sets
enabledagents whose files in the home directory are read
projectDefaultper agent, "allow" or "deny": whether to read its files in the root of any project
projectsthe same for individual projects: the key is the absolute path to the project, the value overrides projectDefault

Agent IDs: claude, cursor, codex, opencode, pi, kilo, gemini, lowercase and exactly as written. Only claude, cursor, codex and opencode add rules; the others add skills, see Skills.

The easiest way is to ask the agent: "Read the Cursor rules in this project".

Which files are read​

AgentPathRule IDFormat
claude~/.claude/CLAUDE.mduser:.claude/CLAUDE.mdplain Markdown
claude~/.claude/rules/**/*.mduser:.claude/rules/style.mdClaude rule
codex$CODEX_HOME/AGENTS.override.md, otherwise $CODEX_HOME/AGENTS.mduser:CODEX_HOME/AGENTS.mdplain Markdown
opencode~/.config/opencode/AGENTS.mduser:.config/opencode/AGENTS.mdplain Markdown
claude<project>/CLAUDE.mdproject:CLAUDE.mdplain Markdown
claude<project>/.claude/CLAUDE.mdproject:.claude/CLAUDE.mdplain Markdown
claude<project>/CLAUDE.local.mdproject:CLAUDE.local.mdplain Markdown
claude<project>/.claude/rules/**/*.mdproject:.claude/rules/api.mdClaude rule
cursor<project>/.cursorrulesproject:.cursorrulesplain Markdown
cursor<project>/.cursor/rules/**/*.mdcproject:.cursor/rules/ts.mdcCursor rule
codex<project>/AGENTS.override.mdproject:AGENTS.override.mdplain Markdown

Rows with ~ are turned on by enabled, rows with <project> by projectDefault and projects. $CODEX_HOME is used if it is an absolute path, otherwise ~/.codex. If the project is the home directory, the project rows are not read.

The order is: home rows, then <project>/AGENTS.md, then project rows, then the rules from .explyt/rules/.

Rule formats​

  • Claude rule. Of the frontmatter, only paths counts: a list of glob patterns or a string of comma-separated patterns (src/*.{ts,tsx}, test/** is two patterns). With paths, the rule is delivered after a matching file is read, like filePattern. Without paths, or when the YAML is invalid, the rule applies to the whole session.
  • Cursor rule (.mdc). alwaysApply, globs and description count. alwaysApply: true makes it a whole-session rule. Otherwise globs works like filePattern. Cursor often writes globs: *.ts without quotes, which is not valid YAML: the fields are then read line by line as written. A rule with neither alwaysApply: true nor globs (in Cursor, an agent-requested or manual rule) doesn't apply, and /rules shows it as invalid.
  • In both formats, a file with an unclosed frontmatter block doesn't apply, and /rules reports an error.

Limits​

  • The otherAgents keys are read only from the global ~/.explyt/settings.json. In the project file they are ignored with a warning, so a cloned repository can't turn on reading other agents' files by itself.
  • A key in projects matches the project through symbolic links too, and on a case-insensitive file system in any letter case. If two keys point to the same project, deny wins.
  • An unknown agent ID is ignored. A value of the wrong shape is ignored with a warning; valid entries next to it keep working.
  • Answers given in the startup window or in /import-agents apply from the next turn. Changes made in settings.json by hand apply from the next turn for rules, and from the next session start or /reload for skills and MCP servers.
  • You can disable a single rule of another agent by its ID through rules.disabledRules, like any other rule.

When a rule reaches the agent​

You can add a YAML frontmatter block before the rule text. Both fields are optional.

FieldValuesPurpose
strictnesssystem, user-message, tool-callwhen the rule text reaches the model; system by default
filePatterna glob such as **/*.kt, or a list of globsthe rule is delivered after a file matching any of the patterns is read

strictness values:

  1. system: the rule is part of the system prompt. It suits stable instructions: the response language, the general result format. This is the default, so a file without frontmatter also works as system.
  2. user-message: the rule is delivered with every message you send. It helps in long conversations where the instruction needs repeating.
  3. tool-call: the rule is delivered after each batch of tool results.

The more often a rule repeats, the more tokens it uses.

With filePattern, the rule is delivered after a matching file is read successfully, at most once per turn, and strictness is ignored. Paths are compared with the / separator and case-sensitively: src/**/*.kt matches only inside the project, **/*.kt matches any path.

Examples​

A rule for every message:

---
strictness: user-message
---
Answer in English and write code comments in English.

A rule for Kotlin files:

---
filePattern: "**/*.kt"
---
This project targets Kotlin 2.0. Prefer data classes.

A rule for several patterns:

---
filePattern: ["**/*.kt", "**/*.gradle.kts"]
---
Take dependency versions from the version catalog.

A rule without frontmatter applies to the whole session:

Make small, focused commits.

If a rule doesn't apply​

A rule with an error is silently skipped. This happens when:

  • the YAML in the frontmatter doesn't parse or isn't a set of fields;
  • strictness has an unknown value and there is no filePattern;
  • filePattern is an empty string, an empty list or a list with empty strings.

The model receives only the rule text; the frontmatter is not sent. Changes to rules apply from the next message: the current turn continues with the old rules.

How rules reach the model​

A rule is delivered in one of four places: the system prompt, the user message, a tool call, or a file read that matches a path pattern.

  • System prompt rules (system) are collected at the start of each of your turns and don't change during the turn. If you change such a rule, it goes into the prompt from the next turn, and the prompt cache starts over on that turn.
  • Other rules arrive when their trigger fires: your message, a tool result or a read of a matching file. They are added to the end of the model request as a hidden message and are not saved in the session history, so they don't bloat it.

The list of the agent's open tasks is added to the end of every request the same way: the model sees the current list even if it created it many turns ago.

After context compaction, system prompt rules and the task list stay in place. Other rules come again when their trigger fires again.

See the list of rules​

The /rules command in the terminal shows all rules found and their state.

Disable a rule​

Disable a rule when it gets in the way of a task but you want to keep the file. Add the rule ID to rules.disabledRules in settings.json:

{
"rules": {
"disabledRules": ["project:AGENTS.md", "global:.explyt/rules/team.md"]
}
}

The ID consists of a prefix (project:, global:, user:) and the path from the root of its location, as in the tables above. IDs are compared exactly: patterns and a different letter case are not supported.

Project rules (IDs starting with project:) can be disabled only in the project <project>/.explyt/settings.json. The same entry in the global file has no effect.

Rules of a Marketplace plugin (IDs starting with plugin:) can't be disabled this way: they apply while the plugin is enabled in the project, and disabling the plugin removes all of its rules.

To delete a rule for good, delete its file.