New to semantic modeling? See What is a Semantic Layer? to understand the concepts, or the Malloy Language Documentation for language details.
The Building Blocks
A Malloy model is built from a handful of constructs. You’ll see them in everything the agent generates:- Sources — tables from your environment’s connections, extended with semantics:
source: orders is conn.table('sales.orders') extend { ... } - Joins — relationships between sources, declared once and available to every query
- Dimensions — attributes to group and filter by
- Measures — aggregate calculations like revenue or order count, defined once and reused everywhere
- Views — saved query patterns built from dimensions and measures
- Annotations — tags on sources and fields that tell Credible how to treat them. Annotations are how you evolve a model beyond its logical definition:
#(doc)documents a field,#(index)makes its values searchable,#(authorize)controls who can query a source, and#@ persistmaterializes it for performance. The rest of this section is largely about applying them.
Stages of Model Development
A model matures in stages, and the pages in this section follow them in order:- Model — build the logical model: sources, joins, dimensions, measures, and views (this page)
- Optimize for AI retrieval — document fields and index values with Discovery tags so agents find and understand your data
- Secure — control who sees which sources, rows, and columns with fine-grained Access Control annotations
- Optimize performance and cost — materialize expensive sources and manage index freshness with persistence annotations (Performance & Cost)
- Publish — version and serve the model to every consumer with Publishing
Prerequisites
- A place to build — a workspace in the Credible App, or an IDE with the Credible Extension
- A database connection — see Connect a Database
Build a Model with the Agent
The workflow is the same whether you’re chatting in the app or in your IDE:-
Describe what you want to model. Be specific about your data and analysis goals:
- “Build a model of my ecommerce data so I can analyze sales by product and brand”
- “Create a semantic model for customer analytics including lifetime value”
- “Model the orders table with customer and product relationships”
- The agent discovers and proposes. Using its MCP (Model Context Protocol) tools, the agent explores your indexed tables and schemas, then proposes — backed by real data — which tables to include, how they join, and which dimensions and measures to define. Credible’s open-source agent skills — curated in the open with the world’s data experts — guide it to follow Malloy best practices automatically. The same skills run on every surface, so the workflow is identical in the app and in your IDE.
-
Confirm and iterate. Approve or adjust each proposal in plain language, and the agent writes the model — every field defined, documented with
#(doc), and indexed with#(index)where it helps discovery. In the app, the agent previews queries in the chat so you see real results at each step; in your IDE, review the generated.malloyfiles and approve the changes.
Validate as You Build
Preview results against real data before you publish:- In the app — the agent runs queries against the draft package and shows results in the chat; open the draft at any time to browse the generated files
- In your IDE — use the buttons above each source definition: Schema to view the compiled structure, Explore to interactively query in the Explorer, and Preview for a quick data check
Next Steps
Continue through the stages, or jump straight to publishing your first model:Discovery
Document and index your model so agents find and understand your data
Publish Your Model
Make your model available across the platform