malloy
Expert guidance for Malloy, the experimental data language from Google that replaces SQL for analytics with a composable, reusable, and more readable syntax. Helps developers write Malloy models, build nested queries, and explore data with Malloy's VS Code extension and notebook interface.
What this skill does
# Malloy — Semantic Data Language
## Overview
Malloy, the experimental data language from Google that replaces SQL for analytics with a composable, reusable, and more readable syntax. Helps developers write Malloy models, build nested queries, and explore data with Malloy's VS Code extension and notebook interface.
## Instructions
### Source Definition
Define reusable data models:
```malloy
// models/ecommerce.malloy — Ecommerce data model
source: orders is duckdb.table('orders.parquet') extend {
// Dimensions (attributes to group by)
dimension:
order_date is created_at::date
order_month is created_at.month
order_year is created_at.year
is_high_value is amount > 100
order_size is pick
'small' when items_count < 3
'medium' when items_count < 10
'large'
// Measures (aggregations)
measure:
order_count is count()
total_revenue is sum(amount)
avg_order_value is avg(amount)
unique_customers is count(distinct customer_id)
revenue_per_customer is total_revenue / unique_customers
// Reusable named queries (views)
view: revenue_by_month is {
group_by: order_month
aggregate:
total_revenue
order_count
avg_order_value
order_by: order_month
}
view: top_customers is {
group_by: customer_id
aggregate:
total_revenue
order_count
order_by: total_revenue desc
limit: 20
}
view: daily_dashboard is {
group_by: order_date
aggregate:
total_revenue
order_count
unique_customers
avg_order_value
order_by: order_date desc
limit: 30
}
}
```
### Queries
Write composable, readable analytics queries:
```malloy
// queries/analysis.malloy — Analytics queries using the model
import "models/ecommerce.malloy"
// Simple aggregation
run: orders -> {
aggregate:
total_revenue
order_count
avg_order_value
}
// Group by with filters
run: orders -> {
where: order_year = 2026
group_by: order_month
aggregate:
total_revenue
order_count
order_by: order_month
}
// Nested queries — multiple levels of aggregation in one query
run: orders -> {
group_by: order_size
aggregate:
total_revenue
order_count
avg_order_value
// Nested: for each order_size, show monthly breakdown
nest: monthly_trend is {
group_by: order_month
aggregate: total_revenue
order_by: order_month
}
// Nested: for each order_size, show top customers
nest: top_customers is {
group_by: customer_id
aggregate: total_revenue, order_count
order_by: total_revenue desc
limit: 5
}
}
// Pipeline: chain transformations
run: orders
-> { where: status = 'completed' }
-> revenue_by_month // Reuse named view
-> { where: total_revenue > 10000 } // Filter the result
```
### Joins and Relationships
```malloy
// models/full_model.malloy — Multi-table model with joins
source: customers is duckdb.table('customers.parquet') extend {
dimension: signup_month is created_at.month
measure:
customer_count is count()
avg_lifetime_value is avg(lifetime_value)
}
source: products is duckdb.table('products.parquet') extend {
dimension: price_tier is pick
'budget' when price < 25
'mid-range' when price < 100
'premium'
measure: product_count is count()
}
source: order_items is duckdb.table('order_items.parquet') extend {
// Join to related tables
join_one: orders on order_id = orders.id
join_one: products on product_id = products.id
join_one: customers is orders.customer_id = customers.id
measure:
total_quantity is sum(quantity)
item_revenue is sum(quantity * unit_price)
// Query across joined tables
view: revenue_by_category is {
group_by: products.category
aggregate:
item_revenue
total_quantity
order_by: item_revenue desc
}
view: customer_product_matrix is {
group_by: customers.signup_month
aggregate: item_revenue
nest: by_category is {
group_by: products.category
aggregate: item_revenue
}
}
}
```
### Notebooks and Visualization
```malloy
// In Malloy notebook (.malloynb) or VS Code extension
// Malloy auto-renders results as charts when appropriate
// Bar chart — group by with single measure
run: orders -> {
group_by: status
aggregate: order_count
}
// # bar_chart
// Line chart — time series
run: orders -> revenue_by_month
// # line_chart
// Dashboard — multiple visualizations from one query
run: orders -> {
group_by: order_size
aggregate: total_revenue, order_count
nest: trend is {
group_by: order_month
aggregate: total_revenue
}
}
// # dashboard
```
### DuckDB and BigQuery Connections
```malloy
// Connection configuration
// DuckDB (local files)
connection: duckdb is duckdb [
parquet_path: "./data/"
]
// BigQuery
connection: bq is bigquery [
project_id: "my-gcp-project"
dataset: "analytics"
]
// Use BigQuery tables in models
source: events is bq.table('analytics.events') extend {
measure: event_count is count()
}
```
## Installation
```bash
# VS Code Extension (recommended)
# Install "Malloy" from VS Code Marketplace
# CLI
npm install -g @malloydata/malloy-cli
# Python package
pip install malloy
# Run a Malloy file
malloy run analysis.malloy
```
## Examples
### Example 1: Integrating Malloy into an existing application
**User request:**
```
Add Malloy to my Next.js app for the AI chat feature. I want streaming responses.
```
The agent installs the SDK, creates an API route that initializes the Malloy client, configures streaming, selects an appropriate model, and wires up the frontend to consume the stream. It handles error cases and sets up proper environment variable management for the API key.
### Example 2: Optimizing queries performance
**User request:**
```
My Malloy calls are slow and expensive. Help me optimize the setup.
```
The agent reviews the current implementation, identifies issues (wrong model selection, missing caching, inefficient prompting, no batching), and applies optimizations specific to Malloy's capabilities — adjusting model parameters, adding response caching, and implementing retry logic with exponential backoff.
## Guidelines
1. **Models separate from queries** — Define sources and views in model files; write queries in separate files or notebooks
2. **Name your views** — Reusable views (named queries) are Malloy's superpower; define common analyses once, use everywhere
3. **Nested queries for rich analysis** — Instead of multiple separate queries, nest related analyses into a single query
4. **Use pick for categorization** — The `pick` expression replaces SQL's verbose CASE WHEN for creating dimensions
5. **Pipeline for progressive filtering** — Chain queries with `->` to progressively refine results; each step is readable
6. **DuckDB for local analysis** — Use DuckDB connection with Parquet files for fast local analytics; switch to BigQuery for production
7. **Malloy notebooks for exploration** — Use `.malloynb` files for iterative data exploration with inline visualization
8. **Version your models** — Malloy models are code; store in Git alongside your data pipelines
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.