Analyze Your Data
Create an AGENTS.md with domain-specific context, then put your AI analyst to work answering real business questions.
Why this step matters
Your AI agent now has the tools — it can read your schema, it can query your warehouse. But tools alone aren't enough. A general-purpose AI doesn't know that "DAU" means Daily Active Users, that your timestamps are in UTC, or that joining two of your largest tables without a filter will timeout.
The AGENTS.md file is where you give the agent this domain knowledge. It's a plain markdown file at the root of your project that the AI reads before doing anything. Think of it as onboarding documentation — the same kind you'd write for a new analyst joining your team, except the reader is an AI.
Once AGENTS.md is in place, the agent stops guessing and starts reasoning with real context. That's the difference between "this query probably works" and "this query is correct."
What you'll do
- Create an
AGENTS.mdfile with domain-specific context for your industry - Ask the agent real business questions and see it work
How AGENTS.md works
The AGENTS.md file sits at the root of your Bruin project. AI coding tools (Cursor, Claude Code, Codex) automatically read it when they start a session in the project directory. Here's what to include:
- Project overview — what the data is about, who uses it
- Data access rules — tell the agent how to query data. Bruin CLI's
bruin querycommand is the standard way for an agent to run SQL against your warehouse. You should instruct the agent to always show you the SQL before executing it, and to use--limiton large tables to avoid expensive queries. Also explicitly state it's read-only — noINSERT,UPDATE,DELETE, orDROPon production tables. - Domain glossary — acronyms, KPIs, business-specific definitions the agent wouldn't know on its own
- Data caveats — timezone handling, known NULL semantics, sync delays, data freshness
- Query guidelines — restrictions on expensive operations (e.g. avoid full table scans on large tables), preferred SQL patterns
Create your AGENTS.md
Create an AGENTS.md file at the root of your Bruin project. Start with the generic sections below — these apply regardless of your industry. Replace <connection-name> with the connection you set up in Step 2.
# AGENTS.md
## Data access
- Use `bruin query --connection <connection-name> --query "<SQL>"` for all data access
- Always show the SQL query and explain your reasoning before executing it
- Use `--limit 10` when exploring unfamiliar tables or testing complex queries
- Read the `assets/` directory to understand available tables and their schemas before querying
- This is a **read-only** environment — never run INSERT, UPDATE, DELETE, or DROP statements
Add industry-specific context
Now add the sections that are specific to your domain — a project overview, glossary of terms, data caveats, and query guidelines. Pick the tab closest to your use case and append the content to the same AGENTS.md file.
Finance / Stock Market
Append the following to your AGENTS.md. Adjust the details to match your actual data and schema names.
## Project overview
This project contains financial and stock market data for investment analysis.
The data includes company financials, stock prices, market indicators, and
fundamental metrics.
## Domain glossary
- **FCF** — Free Cash Flow: operating cash flow minus capital expenditures
- **EPS** — Earnings Per Share: net income divided by outstanding shares
- **P/E** — Price-to-Earnings ratio: stock price divided by EPS
- **EBITDA** — Earnings Before Interest, Taxes, Depreciation, and Amortization
- **TTM** — Trailing Twelve Months: sum of the last 4 quarterly values
- **Market Cap** — share price multiplied by total outstanding shares
- **YoY** — Year over Year comparison
- **QoQ** — Quarter over Quarter comparison
- **Beta** — measure of stock volatility relative to the overall market
- **Dividend Yield** — annual dividends per share divided by stock price
## Data caveats
- All timestamps are in **UTC**
- Financial data has a **15-minute delay** from market close for EOD data
- Quarterly financial reports use the company's fiscal quarter, which may not align with calendar quarters
- `NULL` values in financial columns typically mean the metric is not applicable (e.g., EPS for pre-revenue companies), not that data is missing
- Stock splits affect historical price comparisons — always use split-adjusted prices when comparing across time periods
## Query guidelines
- When comparing financial metrics across time, prefer **TTM** over single-quarter values to smooth seasonality
- Always filter by date range — full table scans on price history tables are expensive
- For market cap weighted calculations, use the most recent `shares_outstanding` value
- Prefer `QUALIFY ROW_NUMBER()` over subqueries for finding latest records
Example prompts to try:
- "Which companies had their free cash flow margin improve in the past 4 quarters but saw their stock price decrease more than 10% during the same period?"
- "What's the average P/E ratio by sector, and which companies are trading more than 2 standard deviations below their sector average?"
- "Show me the top 10 companies by TTM revenue growth that also have positive free cash flow."
What just happened
You now have a working AI data analyst. The AGENTS.md file gives the agent the domain knowledge it needs to write accurate, context-aware queries. Combined with the schema metadata from Step 3 and the MCP connection from Step 4, the agent has everything it needs to start: it knows your tables, understands your business terms, and can query your warehouse directly.
Keep talking to it — ask follow-up questions, request visualizations, explore anomalies. The more you use it, the more you can refine the AGENTS.md — add new terms, tighten query guidelines, note edge cases you discover. This file is living documentation that gets better over time.
In the next step, we'll look at ways to push the agent's context even further — with a structured glossary and connections to your team's existing documentation in Notion or Confluence.
Tips for getting the most out of your AI analyst
- Be specific with prompts — "What's the revenue trend?" is okay, but "What's the monthly NMV trend for the electronics category, excluding returns, for the past 12 months?" is much better
- Ask to see the SQL first — Tell the agent to show you the query before running it, especially for complex analyses
- Use
--limitfor exploration — When the agent is exploring unfamiliar tables, have it use--limit 10to avoid expensive full-table scans - Iterate on AGENTS.md — When the agent gets something wrong, add a clarification to AGENTS.md so it doesn't repeat the mistake