Skip to main content
Rules guide your agent’s behavior, ensuring it responds appropriately and follows your organization’s standards.

RULES.md File

When you initialize a nao project with nao init, a RULES.md file is automatically created in your project root. It is loaded with every message to the agent, so keep it lean. RULES.md has two jobs:
  1. Orchestrator: point the agent to the right context fast - which metric maps to which definition, which topic maps to which file, which question type maps to which table or skill.
  2. Broad rules: how to query and how to answer (tone, SQL conventions, data access).
Everything else - per-table schemas, full metric semantics, domain-specific rules - belongs in a referenced file. RULES.md should never duplicate context that already lives elsewhere in your repo. It points to it.
Since RULES.md is included with every message, keeping it concise optimizes performance and cost. When nao sync has already populated per-table docs, a semantic layer, or docs/, point to those instead of restating them.
nao init scaffolds RULES.md with the sections below. Keep the ones that fit your project and drop any already covered by synced context.

Point to context, don’t copy it

The ## Context map section is what keeps RULES.md lean. Instead of restating column lists or metric formulas, route the agent to where they already live:

Conditional sections

Two sections are conditional. Include them only when that context does not already exist elsewhere:
  • Tables detail: skip it when per-table docs (query_history.md, ai_summary.md) or dbt schema.yml column docs already describe your tables - the Most Used Tables pointers and the Context map route there already. Reserve it for cross-table pitfalls documented nowhere else.
  • Key Metrics Reference: skip it when a semantic layer or metric docs define your metrics. Replace it with a one-line pointer so each metric keeps a single canonical definition.
Each metric should have exactly one canonical definition across all your context. Duplicating it in RULES.md and a semantic layer is the most common cause of inconsistent answers.

Chart and visualization guidelines

RULES.md can also tell the agent how charts should look, so every visualization stays on-brand and consistent. Add a ## Chart & Visualization Guidelines section with two parts:
  • Brand color palette: the colors to use for chart series. Single-series charts use the primary brand color; multi-series charts spread across the palette, then use tints and shades of those colors beyond about six series rather than introducing off-brand hues. Tell the agent to never fall back to the charting library’s default palette.
  • Semantic colors: fixed colors for when a chart encodes good vs bad values (deltas, variances, positive or negative KPIs). Keep these separate from the brand palette, which stays reserved for purely categorical series.
Fill the palette from your company’s design system or brand guidelines. nao init scaffolds this section with placeholder colors for you to replace.

Broad rules example

Beyond routing, RULES.md holds the broad rules for how the agent queries and answers. Here’s an example of that portion:

Sub Rules Files

For detailed, domain-specific information, create additional .md files in your context. The agent will read these files only when needed. File Structure Example
You can use sub-rules files for this kind of context:
  • Business Context: Context on your company and products.
  • Business Glossary: Glossary on your business key concepts and terms.
  • Domain-Specific Context: Specific knowledge on a domain (Business definitions, key metrics, key tables)
  • Data Quality Information: Context on specific data issues or specificity to add explainability to the agent.
  • Events Information: Context on specific events that happened and can help explain data.
Organize your rules modularly to keep token costs low and maintain agent focus. Each metric should have only one canonical definition across all your rules files.

Context Engineering Principles

Learn how to organize rules effectively using MECE principles and modular structure
Example: Specialized File (marketing.md) Here’s an example of a specialized context file: