agentleFS
malloydatamalloydata/publisher/skills/malloy-analyze/SKILL.md

malloy-analyze

Skill116 starsChanged 2 months agoMITView on GitHub

Open-ended exploration with no specific question to answer, and building views/dashboards/notebooks on an existing model. Use when the user asks "what's interesting?", "explore this data", "find insights", "look for patterns", "build a dashboard", or "create views". Not for a specific data question - answering one is `malloy-analysis`, and writing down what the answer assumed is `malloy-model-as-you-go`. For exploration start at Step 1; for views on an existing model jump to View Patterns.

The file

Show its rules and text

We split this skill into the rules it gives an agent

16 rules. About 0 are common, 7 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    View/dashboard building: create views, dashboards, notebooks from an existing model

    line 14
  2. Very specific:

    Call search_malloy_docs liberally: it has powerful analysis patterns (window functions, cohorts, percent-of-total, nested drill-downs).

    line 23
  3. Distinctive:

    Create a working analysis file (this grows throughout the session):

    line 47
  4. Distinctive:

    Time range: Check earliest/latest dates, gaps, seasonality.

    line 72
  5. Distinctive:

    Skip presentation if user already has a clear question: Use profiling to refine it and jump to INVESTIGATE.

    line 80
  6. Very specific:

    Search search_malloy_docs("window functions") for ranking and percentile patterns.

    line 95
  7. Very specific:

    Use nest: for multi-level drill-downs in a single query:

    line 140
  8. Very specific:

    Every useful query should leave an artifact in your .malloy file.

    line 157
  9. Distinctive:

    Check the denominator (high rate from tiny sample?)

    line 163
  10. Very specific:

    Look at raw data (select: * where: condition limit: 20)

    line 165
  11. Distinctive:

    Check for data artifacts (NULLs, duplicates, encoding)

    line 166
  12. Very specific:

    Document insights as view descriptions: #(doc) Top 10% of customers drive 62% of revenue.

    line 185
  13. Distinctive:

    DRY rule: Do NOT define measures/dimensions inline in views.

    line 202
  14. Very specific:

    No fixed scale on measures: use # currency (no scale).

    line 218
  15. Very specific:

    Place chart annotation on the nested view definition, not on nest: itself

    line 219
  16. Very specific:

    Use + to modify existing views: run: source -> my_view + { limit: 15, where: status = 'active' }

    line 264

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<!-- Copyright (c) Credible Data Inc. SPDX-License-Identifier: MIT -->

Analysis with Malloy

This skill covers two workflows:

  • EDA exploration (Steps 1-6): iteratively query data, build hypotheses, validate findings
  • View/dashboard building: create views, dashboards, notebooks from an existing model

Tool names are written bare here - get_context, execute_query, search_malloy_docs. The exact prefixed name depends on the host surface; match each against the tools you actually have.

To formalize analysis into a polished semantic model, hand off to the modeling skill's "Starting from Analysis" workflow (skill:malloy-model).

Prerequisites

  • The Malloy MCP tools must be configured (get_context, execute_query, search_malloy_docs). If they are not available, STOP and ensure your host's MCP server is connected.
  • Call search_malloy_docs liberally: it has powerful analysis patterns (window functions, cohorts, percent-of-total, nested drill-downs).

EDA WORKFLOW

ORIENT → PROFILE → HYPOTHESIZE → INVESTIGATE → VALIDATE → SYNTHESIZE
                     (user)                      (user)     (user)

Adaptive Checkpoints

The 6-step structure is a framework, not a rigid script.

SituationAdaptation
User has a clear hypothesis ("what's driving churn?")Skip HYPOTHESIZE, jump to INVESTIGATE on their question
Open-ended ("what's interesting?")Follow all steps. PROFILE and HYPOTHESIZE are essential
User wants you to just go ("explore and show me")Compress checkpoints, present findings at SYNTHESIZE

Step 1: ORIENT: Understand the Data

  1. Ground yourself with get_context. It returns the package's sources, views, and fields (with their docs), so this is where you learn what data exists.
  2. Note the source names, the connection they sit on, and the key tables/fields they expose.
  3. Inspect the existing dimensions, measures, and views the model already defines, then query the data to confirm shape and values.
  4. Create a working analysis file (this grows throughout the session):
    source: main_table is conn.table('schema.table') extend { primary_key: pk }

Output to user: Brief summary of available data. Ask: "What questions are you most interested in? Or should I look for what's interesting?"

Step 2: PROFILE: Statistical Profiling

Directed analysis (user has a question): Profile only columns relevant to their question. Open-ended (no question yet): Profile broadly, looking for surprises.

Key Profiling Queries

Column overview: run: source -> { index: * limit: 100 }

Numeric distributions:

run: source -> {
  aggregate: min_val is min(col), max_val is max(col), avg_val is avg(col), null_count is count() { where: col is null }
}

Categorical breakdown: run: source -> { group_by: col, aggregate: n is count(), order_by: n desc, limit: 20 }

Time range: Check earliest/latest dates, gaps, seasonality.

Duplicates: run: source -> { group_by: pk, aggregate: n is count(), having: n > 1, limit: 10 }

Add useful profiling dimensions/measures to your analysis file as you go. Build incrementally.

Step 3: HYPOTHESIZE: Form Questions

Skip presentation if user already has a clear question. Use profiling to refine it and jump to INVESTIGATE.

Signal from profilingHypothesis type
Skewed distributionOutlier analysis
Time patternsTrend/seasonality
Category imbalanceSegment comparison
Correlated columnsDriver analysis
Unexpected NULLsData quality

CHECKPOINT (open-ended only): Present 3-5 hypotheses ranked by potential impact. Ask which to pursue.

Step 4: INVESTIGATE: Deep-Dive

Outlier Detection

Search search_malloy_docs("window functions") for ranking and percentile patterns.

Trend Analysis

# line_chart
view: trend is { group_by: period is date_col.month, aggregate: key_metric, order_by: period }

Segment Comparison

view: segment_comparison is {
  group_by: segment_dim
  aggregate: row_count, key_metric
  nest:
    # line_chart
    trend is { group_by: period is date_col.month, aggregate: key_metric, order_by: period }
}

Driver Analysis

run: source -> {
  group_by: candidate_driver
  aggregate: row_count, avg_metric is avg(metric_col),
    high_rate is count() { where: metric_col > threshold } / nullif(count(), 0)
  order_by: high_rate desc
}

Multi-Source Comparison (Source vs Group)

Compare each source to its group average using query-as-source. Name the query directly. from(query_name) was removed from the language and no longer parses (unexpected 'from'):

query: team_stats is source -> { group_by: team, season, aggregate: team_avg is avg(points) }
query: driver_stats is source -> { group_by: driver, team, season, aggregate: driver_points is sum(points) }

source: driver_vs_team is driver_stats extend {
  join_one: ts is team_stats on team = ts.team and season = ts.season
  dimension: advantage is driver_points - ts.team_avg
}

Nested Analysis (Malloy's Superpower)

Use nest: for multi-level drill-downs in a single query:

# dashboard { columns=2 }
view: deep_dive is {
  nest: # big_value
    kpis is { aggregate: # label="Total" total_metric, # label="Count" row_count }
  nest: # bar_chart
    by_dim is { group_by: dim, aggregate: metric, order_by: metric desc, limit: 10 }
  nest: # line_chart
    over_time is { group_by: period is date.month, aggregate: metric, order_by: period }
}

columns=N is what gives a dashboard a layout. Bare # dashboard is flex mode, where tiles just flow and wrap and # colspan is silently ignored, so if your tiles look wrong, that is usually why. See skill:malloy-charts for the full tag set.

Build As You Go

Every useful query should leave an artifact in your .malloy file. New dimension? Add it. New measure? Add it. Interesting view? Save it. This file becomes the input for formalizing into a model if the user wants one.

Step 5: VALIDATE: Triangulate

For each finding, validate with at least ONE of:

  • Cross-check with another metric (revenue spiking? do order counts also?)
  • Check the denominator (high rate from tiny sample?)
  • Examine time consistency (pattern or one-time event?)
  • Look at raw data (select: * where: condition limit: 20)
  • Check for data artifacts (NULLs, duplicates, encoding)

CHECKPOINT: Present each finding with: the insight, the evidence, confidence level, and assumptions made.

Step 6: SYNTHESIZE: Compelling Summary

Build a dashboard view that tells the story:

# dashboard { columns=2 }
view: analysis_summary is {
  nest: # big_value
    headlines is { aggregate: ... }
  nest: # line_chart
    trend is { ... }
  nest: # bar_chart
    breakdown is { ... }
}

Document insights as view descriptions: #(doc) Top 10% of customers drive 62% of revenue.

Present to user: top 3-5 insights, supporting views, open questions, and recommended next steps (unless your host's instructions say it shows follow-up suggestions of its own, which then carry them).

Ready to formalize? Hand off to the modeling skill's "Starting from Analysis" workflow (skill:malloy-model).

VIEW PATTERNS

For building views on an existing model (base + joined source files already exist).

Starter Views (2-3 max initially)

  1. summary: KPI cards (# big_value)
  2. by_time: Time trend (# line_chart)
  3. by_category: Category breakdown (# bar_chart)
  4. dashboard: Nested view combining the above (# dashboard)

DRY rule: Do NOT define measures/dimensions inline in views. Reference existing ones from base source files.

View Annotations

AnnotationUse ForNotes
# big_valueKPI summary2-5 metrics with # label on each
# transposeSummary with group_bySwaps rows/columns
# dashboardMulti-visualizationTiles nested views
# line_chartTime trendONE aggregate only
# bar_chartCategory breakdownONE aggregate only
(none)Detailed tableSupports multiple aggregates

Rules:

  • One tag per line, never combine annotations on one line
  • One aggregate per chart view, charts render only the first
  • No fixed scale on measures: use # currency (no scale); fixed scale only in views after confirming ranges
  • Place chart annotation on the nested view definition, not on nest: itself

For complete chart reference including scatter_chart, shape_map, sparklines, and all configuration options, see skill:malloy-charts or call search_malloy_docs("rendering").

Field-Level Formatting

TagUse For
# currencyMonetary values
# percentRates/percentages
# number=autoLarge counts (K/M/B)
# number=idNon-quantity numbers (years, IDs)
# label="Name"Custom display name
# hiddenInternal/helper fields
# duration=secondsTime durations

NOTEBOOKS (.malloy)

A notebook is notebooks/<slug>.malloy with ## artifact { kind=notebook title="..." }. The format to author is a one-column layout of tiles: tiles=[…] in the tag lists prose blocks (intro { kind=text }, body in a ##|(markdown) intro ... |## block) and "source -> view" queries, and skill:malloy-notebooks has the full format. The example below is the older cell form, which Publisher still reads: prose is ##(markdown) text or a ##|(markdown) ... |## block, and each run: is a query cell.

## artifact { kind=notebook title="Sales analysis" }
import "../order_analysis.malloy"

##|(markdown)
# Sales Analysis
|##

run: order_analysis -> summary

A .malloy notebook compiles as a model, so the linter and /compile report its errors before you save. An existing .malloynb is not covered: its errors show only when a cell runs. Never write a new .malloynb.

A notebook is also the home for a polished, narrated report: alternate prose (the story) with queries (the views), and let each view carry its chart tags. For the full format and report-authoring conventions, see skill:malloy-notebooks.

Interactive Filters

Notebooks do NOT define filters themselves. When you import a model, the model's runtime parameters are inherited and displayed automatically: the publisher renders the controls, parses caller parameters, and applies them server-side. You don't redeclare them in the consumer. If the analysis needs a knob the model doesn't expose, the right move is to add it to the source itself, not to wedge filtering into the consumer.

Declare that knob as a given:. #(filter) is deprecated. Never add a #(filter) annotation: every use, including required, implicit, and date/number ranges, has a given: form. See skill:malloy-model § Parameterizing sources with given:.

The notebook-level ##(filters) annotation and the dimension-level #(filter) {"type": "..."} JSON-blob form are unsupported legacy syntax, don't use them.

View Refinement

Use + to modify existing views: run: source -> my_view + { limit: 15, where: status = 'active' }

Done

Step complete. Output: analysis .malloy file with views, insights, and reusable building blocks. For chart/renderer details, see skill:malloy-gotchas-rendering or call search_malloy_docs. To formalize into a model, hand off to the modeling skill (skill:malloy-model).

Publishing is out of scope for now: open-source Publisher serves the model from disk, and self-hosters publish via git plus their host's publish path.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.