Skip to main content
skill CX Codex

analyzing-data — Claude Code skill: SQL queries to your warehouse

Turns business questions into SQL, runs them against the data warehouse and caches the table mappings it finds along the way.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add astronomer/agents --skill analyzing-data -a claude-code
Open on GitHub

What analyzing-data does

The skill takes a plain-language question, writes SQL and runs it through a kernel that starts on the first exec call. Everything goes through a CLI at scripts/cli.py, with commands for pattern lookup, concept lookup and table schemas. Whatever it discovers gets cached, so the next question about the same tables skips the discovery step.

The workflow is ordered: check the pattern cache for a matching strategy, look up the concept-to-table mapping, and fall back to searching the codebase (Grep over **/*.sql) or querying INFORMATION_SCHEMA when the cache misses. Results come back as Polars or Pandas DataFrames, with pl and pd pre-imported. Independent queries can go out together through run_sql_many, which fans them out concurrently — but it is fail-fast, so one bad query throws away the results of the ones that worked.

All CLI commands are relative to the skill directory, so cd there before running anything. exec waits 120 seconds by default and then interrupts the query, which may still finish server-side; long queries need -t. The kernel shuts itself down after 2 hours idle and keeps its state until then.

What it helps with

  • count a metric straight from a warehouse table
  • build a time trend from raw rows
  • map a business concept to a table and remember it
  • join several tables in one query
  • run ad-hoc SQL without wiring up a connection by hand

Example prompts for the agent

  • how many active users did we have last month?
  • find customers in Europe and show their orders
  • compute weekly conversion and save the pattern

How to install analyzing-data

1Skills CLI (Vercel)

npx skills add astronomer/agents --skill analyzing-data -a claude-code

2Manually: put the files in place

~/.claude/skills/analyzing-data/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/analyzing-data/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about analyzing-data

How do I install analyzing-data in Claude?

Run npx skills add astronomer/agents --skill analyzing-data -a claude-code. The skill lands at ~/.claude/skills/analyzing-data/SKILL.md.

What does analyzing-data do?

It turns business questions into SQL, runs them against the warehouse and returns the result as a DataFrame. Along the way it caches table schemas and query strategies.

What does the skill need to run?

Commands go through uv run scripts/cli.py, and you need to be in the skill's directory first. The kernel starts automatically on the first exec call.

Source text

SKILL.md · Apache-2.0
---
name: analyzing-data
description: Queries the data warehouse with SQL and answers business questions about data. Use when answering anything that needs warehouse data - counts, metrics, trends, aggregations, joins across tables, data lookups, or ad-hoc SQL analysis (for example "who uses X", "how many Y", "show me Z", "find customers", "what is the count").
---

# Data Analysis

Answer business questions by querying the data warehouse. The kernel auto-starts on first `exec` call.

**All CLI commands below are relative to this skill's directory.** Before running any `scripts/cli.py` command, `cd` to the directory containing this file.

## Workflow

1. **Pattern lookup** — Check for a cached query strategy:
   ```bash
   uv run scripts/cli.py pattern lookup "<user's question>"
   ```
   If a pattern exists, follow its strategy. Record the outcome after executing:
   ```bash
   uv run scripts/cli.py pattern record <name> --success  # or --failure
   ```

2. **Concept lookup** — Find known table mappings:
   ```bash
   uv run scripts/cli.py concept lookup <concept>
   ```

3. **Table discovery** — If cache misses, search the codebase (`Grep pattern="<concept>" glob="**/*.sql"`) or query `INFORMATION_SCHEMA`. See [reference/discovery-warehouse.md](reference/discovery-warehouse.md).

4. **Execute query**:
   ```bash
   uv run scripts/cli.py exec "df = run_sql('SELECT ...')"
   uv run scripts/cli.py exec "print(df)"
   ```

5. **Cache learnings** — Always cache before presenting results:
   ```bash
   # Cache concept → table mapping
   uv run scripts/cli.py concept learn <concept> <TABLE> -k <KEY_COL>
   # Cache query strategy (if discovery was needed)
   uv run scripts/cli.py pattern learn <name> -q "question" -s "step" -t "TABLE" -g "gotcha"
   ```

6. **Present findings** to user.

## Kernel Functions

| Function | Returns |
|----------|---------|
| `run_sql(query, limit=100)` | Polars DataFrame |
| `run_sql_pandas(query, limit=100)` | Pandas DataFrame |
| `run_sql_many(queries, limit=100)` | List of Polars DataFrames (one per query) |

`pl` (Polars) and `pd` (Pandas) are pre-imported.

**Run independent queries together** with `run_sql_many` — they execute concurrently (Snowflake async / connection-pool fan-out) instead of one at a time:

```bash
uv run scripts/cli.py exec "dfs = run_sql_many(['SELECT ...', 'SELECT ...']); print(dfs[0])"
```

`run_sql_many` is **fail-fast**: if any query errors, the call raises and the results of the queries that succeeded are discarded. Use separate `run_sql` calls if you need partial results.

**Timeouts:** `exec` waits up to 120s by default, then interrupts the query and returns a "client stopped waiting" message (the query may still finish server-side). Raise it for known long-running queries: `uv run scripts/cli.py exec "..." -t 600`.

**Idle kernel:** the kernel self-terminates after 2h idle (preserving state until then). Override with `ASTRO_KERNEL_IDLE_TIMEOUT` (seconds; `0` disables).

## CLI Reference

### Kernel

```bash
uv run scripts/cli.py warehouse list      # List warehouses
uv run scripts/cli.py start [-w name]     # Start kernel (with optional warehouse)
uv run scripts/cli.py exec "..."          # Execute Python code
uv run scripts/cli.py status              # Kernel status
uv run scripts/cli.py restart             # Restart kernel
uv run scripts/cli.py stop                # Stop kernel
uv run scripts/cli.py install <pkg>       # Install package
```

### Concept Cache

```bash
uv run scripts/cli.py concept lookup <name>                     # Look up
uv run scripts/cli.py concept learn <name> <TABLE> -k <KEY_COL> # Learn
uv run scripts/cli.py concept list                               # List all
uv run scripts/cli.py concept import -p /path/to/warehouse.md   # Bulk import
```

### Pattern Cache

```bash
uv run scripts/cli.py pattern lookup "question"                                      # Look up
uv run scripts/cli.py pattern learn <name> -q "..." -s "..." -t "TABLE" -g "gotcha"  # Learn
uv run scripts/cli.py pattern record <name> --success                                # Record outcome
uv run scripts/cli.py pattern list                                                   # List all
uv run scripts/cli.py pattern delete <name>                                          # Delete
```

### Table Schema Cache

```bash
uv run scripts/cli.py table lookup <TABLE>            # Look up schema
uv run scripts/cli.py table cache <TABLE> -c '[...]'  # Cache schema
uv run scripts/cli.py table list                       # List cached
uv run scripts/cli.py table delete <TABLE>             # Delete
```

### Cache Management

```bash
uv run scripts/cli.py cache status                # Stats
uv run scripts/cli.py cache clear [--stale-only]  # Clear
```

## References

- [reference/discovery-warehouse.md](reference/discovery-warehouse.md) — Large table handling, warehouse exploration, INFORMATION_SCHEMA queries
- [reference/common-patterns.md](reference/common-patterns.md) — SQL templates for trends, comparisons, top-N, distributions, cohorts

© astronomer · Apache-2.0 · astronomer/agents

Similar skills

All skills for Data and databases →

From the same set24

airflow A Claude skill for Apache Airflow work through the af CLI: list and trigger DAGs, read task logs, trace import and parse errors. CX Codex +1 1,500installs managing-astro-local-env Controls local Apache Airflow environments with Astro CLI across Docker and standalone modes. Helps start services, tail logs, and query the Airflow API. CX Codex +1 1,400installs testing-dags Runs an Airflow DAG, waits for it to finish, and digs into the logs when it fails. Built for test-debug-fix loops. CX Codex +1 1,200installs debugging-dags Walks an agent from a failed Airflow task to the actual root cause, then to a fix and a way to keep it from recurring. Handy when a DAG won't parse or a task dies without an obvious reason. CX Codex +1 1,200installs authoring-dags Guides the creation and validation of Apache Airflow DAGs across a six-phase workflow. Useful when writing new data pipelines or adding downstream tasks to existing DAGs. CX Codex +1 1,200installs setting-up-astro-project A skill that walks the agent through creating an Airflow project with the Astro CLI: folder layout, dependencies, connections and variables. CX Codex +1 1,100installs migrating-airflow-2-to-3 Walks Airflow 2.x DAG code through the move to 3.x: imports, operators, hooks, metadata access. Useful when the upgrade is due and hunting breaking changes by hand is tedious. CX Codex +1 1,100installs checking-freshness The skill checks when a table was last updated and tells you whether the data is safe to use. CX Codex +1 1,000installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor