Skip to content

Rules

Rules are the core configuration unit in AgentsMesh. Each rule is a Markdown file with optional YAML frontmatter stored in .agentsmesh/rules/.

The root rule

_root.md is the only required file. It is always applied regardless of target, scope, or glob.

---
root: true
---
# Project Guidelines
- Write tests before implementation.
- Max 200 lines per file.
- Use TypeScript strict mode.
- Prefer pure functions over classes.

Additional rules

Additional rules live alongside _root.md and can be scoped by target, glob pattern, or left unscoped (applied to all targets).

Unscoped rule (all targets)

---
description: Security conventions
---
Never log sensitive data. Validate all external inputs.
Use parameterized queries. Avoid `eval()`.

Target-scoped rule

---
description: Frontend conventions
targets: [cursor, claude-code]
globs: [src/components/**/*.tsx]
---
Use functional components with hooks. No class components.
Prefer Tailwind utility classes over custom CSS.

Codex CLI rule with instruction variant

---
description: Codex execution rule
codexEmit: execution
codexInstructionVariant: override
---
Always run `pnpm typecheck` before committing.

Frontmatter reference

FieldTypeDescription
rootbooleanAlways-applied rule. Required for _root.md.
descriptionstringHuman-readable rule name shown in tool menus.
targetsstring[]Limit rule to specific tools. Empty = all targets. Valid values: claude-code, cursor, copilot, gemini-cli, cline, codex-cli, windsurf, continue, junie.
globsstring[]File patterns this rule applies to (tool-dependent). Uses gitignore-style glob syntax.
triggerstringWindsurf activation mode: always_on, model_decision, glob, manual.
codexEmitstringCodex CLI instruction type: advisory or execution.
codexInstructionVariantstringCodex nested instruction format: default or override.

Tool-specific behavior

Rules are mapped to each tool’s native format during generation:

ToolNative formatNotes
Claude Code.claude/rules/*.mdFrontmatter preserved.
Cursor.cursor/rules/*.mdcConverted to .mdc format with Cursor-specific frontmatter.
Copilot.github/copilot-instructions.mdAll rules merged into a single file.
Gemini CLI.gemini/rules/*.mdFrontmatter preserved.
Cline.cline/rules/*.mdFrontmatter preserved.
Codex CLIAGENTS.mdRules embedded per codexEmit/codexInstructionVariant.
Windsurf.windsurf/rules/*.mdtrigger field applied.
Continue.continue/rules/*.mdFrontmatter stripped.
Junie.junie/guidelines.mdAll rules merged.

File naming

Rule filenames become the rule identifier in tool menus. Use kebab-case descriptive names:

.agentsmesh/rules/
_root.md
security.md
frontend-react.md
backend-api.md
testing.md

No name collisions are allowed. AgentsMesh lints for duplicate rule names during agentsmesh lint.