agentleFS
ai-analyst-labai-analyst-lab/ai-analyst/.claude/skills/connect-snowflake/SKILL.md

connect-snowflake

Skill304 starsChanged 2 months agoMITView on GitHub

Query the live/remote Snowflake warehouse instead of the local practice copy. Use when the user says "connect to snowflake", "use the live data", "go remote", "query the warehouse", or asks "is this hitting snowflake or duckdb?". Assumes credentials already exist (first-time setup is /setup-snowflake); opts into remote via ConnectionManager and verifies the connection type before any query runs.

  • Reads credentials
  • Installs packages

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run queries against the live Snowflake warehouse — not the local DuckDB practice copy.

    line 14
  2. Very specific:

    Use DATABASE.SCHEMA.TABLE for physical Snowflake sources, obtained from mgr.table_reference('orders') or the verified connection …

    line 67
  3. Distinctive:

    Before trusting any number, confirm:

    line 78
  4. Distinctive:

    Always tell the user which source is live.

    line 87
  5. Very specific:

    Read .knowledge/datasets/{active}/quirks.md before trusting edge columns.

    line 100

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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

Skill: Connect to Live Snowflake

Purpose

Run queries against the live Snowflake warehouse — not the local DuckDB practice copy. This is the runbook for "actually go remote." Credentials and config already exist; this skill is about opting into remote and verifying you landed there.

This is distinct from /setup-snowflake (the first-time wizard that collects the connection fields, stores the approved credential in .env, and verifies the native ConnectionManager session). Use this skill when the warehouse is already configured and you just want to query the live data through ConnectionManager.

When to Use

Trigger on any request to use the live/remote Snowflake data, e.g.:

  • "connect to snowflake", "query snowflake", "use the live data / live warehouse"
  • "run this against snowflake / the real data / production", "go remote"
  • "is this hitting snowflake or duckdb?", "query the live tables"
  • Any analysis where the user explicitly wants live warehouse numbers rather than the local DuckDB practice snapshot

How the repo decides local vs. remote

detect_active_source() (in helpers/data/data_helpers.py) defaults to the local DuckDB copy even though the active dataset declares connection_type: snowflake. It only goes remote when you opt in, via either:

  • Env flag (per-shell): AAP_USE_REMOTE=1 (also accepts true / yes), OR
  • Persisted flag: use_remote: true in .knowledge/active.yaml

Set use_remote: true in .knowledge/active.yaml for a persistent opt-in, and set AAP_USE_REMOTE=1 in the same shell command as python3 as a belt-and-suspenders guard. To confirm you actually landed on the warehouse (not the local fallback), call ConnectionManager.verify_remote(): it returns {"remote": bool, "identity": {account, warehouse, database, schema, version}, "reason": ...} from Snowflake's own session context functions. Treat remote: False as "you are NOT on Snowflake" and fix the reason before querying.

Instructions

Step 1 — Run through ConnectionManager with remote opted in

ConnectionManager auto-loads .env, expands the $SNOWFLAKE_* placeholders from the manifest, and lazy-connects. The export must be in the same Bash call as the python3 — shell env does not persist between separate tool calls.

export AAP_USE_REMOTE=1 && python3 -W ignore -c "
import warnings; warnings.filterwarnings('ignore')
from helpers.data.connection_manager import ConnectionManager
mgr = ConnectionManager()
print('backend:', mgr.connection_type)   # MUST print 'snowflake'
events = mgr.table_reference('events')
df = mgr.query(f'SELECT event_type, COUNT(*) n FROM {events} GROUP BY event_type ORDER BY n DESC')
print(df.to_string(index=False))
mgr.close()
"

Use DATABASE.SCHEMA.TABLE for physical Snowflake sources, obtained from mgr.table_reference('orders') or the verified connection configuration. The data warehouse is compute, not part of this object name. Short names are valid Snowflake syntax but are rejected by the course analytical-query policy so execution and evaluation use the same explicit source. CTE aliases stay unqualified. On rejection, correct the reference and retry once; never change the intended source or disable the guard. Use Snowflake dialect: DATE_TRUNC('month', col), etc. — or get_dialect("snowflake") from helpers/data/sql_dialect.py.

Step 2 — Verify you're actually on Snowflake (not the DuckDB fallback)

Before trusting any number, confirm:

  • mgr.connection_type returns snowflake (if it prints duckdb, the opt-in didn't take — re-check that export AAP_USE_REMOTE=1 ran in the same command).
  • A SELECT CURRENT_ACCOUNT(), CURRENT_WAREHOUSE(), CURRENT_DATABASE(), CURRENT_SCHEMA() returns the account, warehouse, database, and schema from your own connection config (.env / connection_templates/) — compare against what you expect, never assume.

Always tell the user which source is live.

Step 3 — Log every query

ConnectionManager.query() auto-logs at execution by default — that covers the requirement. If you query some other way (raw connector, MCP), log manually:

python3 scripts/log_query.py --dataset {active} --agent ad-hoc \
  --purpose "..." --sql "..." --result "..."

Gotchas

  • export AAP_USE_REMOTE=1 and the python3 call must share one Bash command (&&), or the flag is lost and you silently get DuckDB.
  • Read .knowledge/datasets/{active}/quirks.md before trusting edge columns.
  • Ignore the LibreSSL / urllib3 / NotOpenSSL warnings — harmless. Suppress with -W ignore + warnings.filterwarnings('ignore') as shown.
  • Requires snowflake-connector-python (pip install -e ".[warehouses]"; see the /setup-snowflake prerequisite).
  • A PAT lives in .env as SNOWFLAKE_TOKEN; a legacy password uses SNOWFLAKE_PASSWORD. Account, user, warehouse, database, schema, and role live in the dataset manifest. Never echo or cat .env.

To go back to local DuckDB

Unset the opt-in: unset AAP_USE_REMOTE for the shell, and/or set use_remote: false in .knowledge/active.yaml. connection_type will then report duckdb.

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.