Labsco
astronomer logo

analyzing-data

โ˜… 397

by astronomer ยท part of astronomer/agents

Query your data warehouse to answer business questions with cached patterns and concept mappings. Supports pattern lookup and caching for repeated question types, with outcome recording to improve future queries Includes concept-to-table mapping cache and table schema discovery via INFORMATION_SCHEMA or codebase grep Provides run_sql() and run_sql_pandas() kernel functions returning Polars or Pandas DataFrames for analysis CLI commands for managing concept, pattern, and table caches, plus...

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeQuick setup
๐Ÿงฉ One of 7 skills in the astronomer/agents package โ€” works on its own, and pairs well with its siblings.

Query your data warehouse to answer business questions with cached patterns and concept mappings. Supports pattern lookup and caching for repeated question types, with outcome recording to improve future queries Includes concept-to-table mapping cache and table schema discovery via INFORMATION_SCHEMA or codebase grep Provides run_sql() and run_sql_pandas() kernel functions returning Polars or Pandas DataFrames for analysis CLI commands for managing concept, pattern, and table caches, plus...

Inspect the full instructions your agent will receiveExpand

This is the exact playbook injected into your agent when the skill activates โ€” shown here so you can audit it before installing. You don't need to read it to use the skill.

by astronomer

Query your data warehouse to answer business questions with cached patterns and concept mappings. Supports pattern lookup and caching for repeated question types, with outcome recording to improve future queries Includes concept-to-table mapping cache and table schema discovery via INFORMATION_SCHEMA or codebase grep Provides run_sql() and run_sql_pandas() kernel functions returning Polars or Pandas DataFrames for analysis CLI commands for managing concept, pattern, and table caches, plus... npx skills add https://github.com/astronomer/agents --skill analyzing-data Download ZIPGitHub397

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

Pattern lookup โ€” Check for a cached query strategy:

Copy & paste โ€” that's it
uv run scripts/cli.py pattern lookup " "

If a pattern exists, follow its strategy. Record the outcome after executing:

Copy & paste โ€” that's it
uv run scripts/cli.py pattern record --success # or --failure

Concept lookup โ€” Find known table mappings:

Copy & paste โ€” that's it
uv run scripts/cli.py concept lookup 

Table discovery โ€” If cache misses, search the codebase (Grep pattern="<concept>" glob="**/*.sql") or query INFORMATION_SCHEMA. See reference/discovery-warehouse.md.

Execute query:

Copy & paste โ€” that's it
uv run scripts/cli.py exec "df = run_sql('SELECT ...')"
uv run scripts/cli.py exec "print(df)"

Cache learnings โ€” Always cache before presenting results:

Copy & paste โ€” that's it
# Cache concept โ†’ table mapping
uv run scripts/cli.py concept learn -k 
# Cache query strategy (if discovery was needed)
uv run scripts/cli.py pattern learn -q "question" -s "step" -t "TABLE" -g "gotcha"

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:

Copy & paste โ€” that's it
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

Copy & paste โ€” that's it
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 # Install package

Concept Cache

Copy & paste โ€” that's it
uv run scripts/cli.py concept lookup # Look up
uv run scripts/cli.py concept learn -k # 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

Copy & paste โ€” that's it
uv run scripts/cli.py pattern lookup "question" # Look up
uv run scripts/cli.py pattern learn -q "..." -s "..." -t "TABLE" -g "gotcha" # Learn
uv run scripts/cli.py pattern record --success # Record outcome
uv run scripts/cli.py pattern list # List all
uv run scripts/cli.py pattern delete # Delete

Table Schema Cache

Copy & paste โ€” that's it
uv run scripts/cli.py table lookup # Look up schema
uv run scripts/cli.py table cache -c '[...]' # Cache schema
uv run scripts/cli.py table list # List cached
uv run scripts/cli.py table delete # Delete

Cache Management

Copy & paste โ€” that's it
uv run scripts/cli.py cache status # Stats
uv run scripts/cli.py cache clear [--stale-only] # Clear

References