Cortex Agents + dbt Template

Trustworthy pipelines for AI agents. How to manage the full Cortex Agent lifecycle (semantic views, agent specs, evaluations, and scheduling) as version-controlled, tested, reproducible code with dbt Projects on Snowflake.

Why agents-as-code

An AI agent is only as trustworthy as the data and the process behind it. Yet most agents are assembled by click-ops in a UI: no version history, no peer review, no tests, and no reliable way to promote the same thing from dev to prod. When the agent gives a wrong answer, there is nothing to diff and nothing to roll back.

The problem: click-ops agents

  • No version control: changes live only in the UI
  • No peer review: nobody signs off before prod
  • No tests: accuracy is a vibe, not a metric
  • No reproducibility: dev and prod drift apart
  • No promotion path: rebuilding by hand per environment

The fix: agents as code

  • Git-backed: every change diffed and reviewable
  • PR review + CI: builds on dev before merge
  • Measured: evaluations gate on ≥95% correctness
  • One codebase: env.yml targets dev / staging / prod
  • One command: EXECUTE DBT PROJECT rebuilds it all

What the template delivers

5
Phases from questions to production
3
Environments, one codebase
≥95%
Answer-correctness bar to ship
0
Click-ops steps
1
EXECUTE DBT PROJECT to rebuild

The lifecycle, at a glance

1. Sources sources.yml 2. Staging stg_*.sql 3. Semantic View accuracy 4. Agent spec 5. Evaluations scores Ship SI / Teams iterate: inspect trace → fix the right layer → re-run
One dbt project builds every box. The feedback loop is where evaluation scores drive the next improvement cycle.

Deep dives

Build Runbook
The Full Build, Phase by Phase
The five-phase runbook from business questions to a shipped agent (orientation, semantic view, orchestration, response, tools, and evaluation) with the exact dbt commands to run live.
Open the runbook →
Semantic Views
The Semantic View
Where accuracy is won or lost: business names, KPIs as metrics, verified queries, the additive AI_SQL_GENERATION and AI_QUESTION_CATEGORIZATION clauses, and the enforced clause order.
Open the reference →
Agent Spec
The Agent Spec
The three-layer model (orchestration, response, and tool descriptions) plus the four-part tool-description formula that drives routing accuracy, and the failure patterns to watch for.
Open the reference →
Evaluations
Cortex Agent Evaluations
How readiness is measured: the Goal-Plan-Action metrics, the ground-truth dataset, running an evaluation, and iterating to the ≥95% ship bar.
Open the reference →

About this template

Built from the cortex-agents-dbt-project-template (see dbt Projects on Snowflake). The walkthrough mirrors the project's WORKING-SESSION.md runbook; the reference pages draw on its README.md best practices.