RULES.md File
When you initialize a nao project withnao 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:
- 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.
- Broad rules: how to query and how to answer (tone, SQL conventions, data access).
RULES.md should never duplicate context that already lives elsewhere in your repo. It points to it.
Recommended structure
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 dbtschema.ymlcolumn docs already describe your tables - theMost Used Tablespointers 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.
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.
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
- 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.
Context Engineering Principles
Learn how to organize rules effectively using MECE principles and modular structure