v1.20.64see what's new →

Rules

Rules are markdown files that tell an agent how to behave — your standards, conventions, and hard lines. They persist across every session, so you stop repeating yourself in chat. Write them once; agi-cli syncs them to every agent in the format that agent expects.

One file, every agent

The canonical rules file is AGENTS.md. On sync, agi-cli writes it out under each agent's own name — you never maintain parallel copies.

~/.agents/rules/AGENTS.md   ──▶  ~/.claude/CLAUDE.md
                            ──▶  ~/.codex/AGENTS.md
                            ──▶  ~/.gemini/GEMINI.md
                            ──▶  ~/.cursor/.cursorrules
                            ──▶  ~/.opencode/OPENCODE.md

Edit AGENTS.md only. CLAUDE.md and GEMINI.md in your rules directory are symlinks to it; editing a generated file directly gets overwritten on the next sync.

Write your first rule

Start with a handful of lines that capture what you'd otherwise repeat every session.

# ~/.agents/rules/AGENTS.md

- Tests live next to source. No mocking — exercise the real path.
- Use bun, not npm or yarn.
- Python: built-in type hints, loguru for logging.
- Never commit .env.dev or .env.prod.

Manage rules

agents rules list                       # what's installed, per agent
agents rules add --agents claude,codex  # sync your rules to specific agents
agents rules view claude                # read the active rules with rendering
agents rules switch <preset>            # choose the active rule preset for a version

Layered, like the rest of your config

Rules resolve through the config layers — a project's ./.agents/rules/ merges on top of your user rules, which sit on top of the shipped system rules. Project rules only apply inside that project tree, so a repo can add its own standards without touching your global setup.

Related