/snowflake-pack:snowflake-query-forensics [query-id-or-evidence-json]from snowflake-pack
Audits and diagnoses slow or failed Snowflake queries using query history, Query Insights, and operator stats. Investigates queueing, lock waits, spill, poor pruning, exploding joins, and regression patterns.
Ships in snowflake-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Build a read-only query root-cause packet from platform evidence. Distinguish observed facts, derived metrics, and hypotheses; isolate one variable for any later experiment.
Problem: A slow elapsed time does not identify whether compilation, execution, queueing, blocking, spill, pruning, or query shape is responsible, and some diagnostic surfaces are delayed or unavailable for particular query classes.
Outcome: A query-scoped packet that ranks observed operator evidence, preserves competing explanations, and defines the next read-only check without changing SQL or compute.
OPERATE or MONITOR on the
warehouse when operator statistics are required.Write only for new local evidence and
report artifacts; never use it to alter SQL or Snowflake state.ACCOUNTADMIN. Query-history visibility and operator-stat access
depend on the approved role. GET_QUERY_OPERATOR_STATS requires OPERATE or
MONITOR on the warehouse. Report missing access; do not grant it.metadata.history_source and role must
exactly match the receipted anchor row and source; a digest cannot repair a semantic
mismatch.query_runs, never
attribute them to the anchor, and require the explicit comparison-alignment fields.has_* metadata is safe only when its value is an actual boolean.Before collection, read references/history-and-collection.md. For a completed query, read references/operator-statistics.md. When Query Insights is available, read references/query-insights-boundaries.md.
For bounded live history collection, use the shared read-only collector with an approved Snowflake CLI profile:
python3 "${CLAUDE_SKILL_DIR}/scripts/collect_snowflake_evidence.py" \
--surface query --connection <approved-readonly-profile> \
--source-max-age-seconds <positive-incident-bound> \
--output snowflake-query-collector.json
Use normalized input schema 2.0 and collector receipt schema 2. Before analysis,
apply the complete contract in
History and collection, including exact anchor
UUID, source, role, source-specific terminal status, anchor-only maximum time, reviewed
SQL cap, and an independently preserved input digest. Treat an embedded checksum as
consistency evidence, never authenticity. A missing or mismatched receipt field, stale
anchor, cap hit, truncation, or absent external digest blocks confirmed, completeness,
comparison, regression, and ROI claims. Keep aligned comparison runs in query_runs;
do not attribute them to the anchor. Narrow or partition any truncated collection before
making workload or absence claims.
Follow this sequence:
Require at least one of:
Capture the symptom, expected behavior, comparison query/run if available, account, role, warehouse, execution state, and source timestamps. If the user only says “queries are slow,” first identify a bounded candidate set; do not scan unbounded history.
SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY for longer historical comparisons, while
disclosing its documented latency.QUERY_INSIGHTS only as an additional platform-detected signal; absence of an
insight does not prove absence of a problem.GET_QUERY_OPERATOR_STATS(QUERY_ID) only after confirming the query completed,
is within the supported retrieval window, and the role has warehouse visibility.Use only the source-specific terminal statuses listed in History and collection. Unknown, running, queued, blocked, and warehouse-resume states remain nonterminal and fail closed. The bundled collector receipts Account Usage; Information Schema discovery remains partial without its own reviewed matching receipt.
The detailed choice table and bounded SQL are in references/history-and-collection.md.
Collect only fields needed to distinguish:
Exclude raw query text by default. If literals or object names are relevant, have the operator provide a redacted fragment separately.
Normalize the bundle to the schema in references/operator-statistics.md, then run:
python3 "${CLAUDE_SKILL_DIR}/scripts/analyze_query_evidence.py" \
--input query-evidence.json \
--json-out query-forensics.json \
--markdown-out query-forensics.md
The analyzer emits:
It never rewrites SQL, chooses a warehouse size, or assigns a root cause from a single metric.
For every hypothesis, include at least one competing explanation and the next read-only test. Examples:
Use references/output-contract.md. Required contents:
Before delivery, verify that the packet names the query ID and evidence surfaces, gives
actual source timestamps, reports evidence_binding: BOUND and source_freshness: FRESH before making a completeness claim, contains no raw query text or credentials,
includes at least one operator row bound to a surface-compatible terminal query, and
keeps all three confidence classes separate. Re-run the analyzer on the saved
normalized JSON; the machine-readable result must be identical for identical input. If
a proposed experiment appears, confirm it changes one variable, uses a user-supplied
success objective, names an approver, and has not been executed.
Return query-forensics.json and query-forensics.md in the user's chosen working
directory, plus the exact analyzer command used. The packet includes identity and
freshness, confirmed observations, estimated/derived metrics, at-risk hypotheses, top
operators, warnings, non-claims, and a one-variable experiment proposal only when the
user supplies a success objective. Do not write runtime output into the skill directory.
Return a partial or inconclusive packet rather than guessing when:
| Condition | Meaning | Required response |
|---|---|---|
| Query ID cannot be found | Wrong surface/window/account, retention, latency, or visibility may apply | Check scope and freshness; return unknown rather than “query did not run.” |
| Query is running or too old | Operator statistics are not available | Produce a history-only partial packet and state the missing operator boundary. |
GET_QUERY_OPERATOR_STATS privilege failure | Approved role lacks warehouse OPERATE/MONITOR | Preserve the sanitized error and request owner review; do not grant privileges. |
| No Query Insights row | Exclusion, availability, timing, or no supported signal are all possible | State which interpretation is supported; never certify health from absence. |
| Analyzer rejects evidence | Negative/non-finite counters, malformed timestamps, or invalid objects | Correct from source data; do not coerce or invent fields. |
| User demands resize, rewrite, cancellation, or clustering change | Mutation exceeds this skill's authority | Return evidence and an approval-bounded experiment proposal, then stop. |
Confirm the query completed, collect operator statistics, and report the exact remote spill bytes and affected operator. Compare the same parameterized hash and aligned data volume. Return query-shape and capacity-pressure hypotheses separately; do not resize.
Decompose queue and transaction-blocked time from query history. If blocked time is present, identify the relevant transaction evidence through approved read-only surfaces. Do not cancel the blocker. The packet names the blocker owner and escalation path.
Reject that inference. Query Insights has documented exclusions. Use history and operator evidence, and report whether insights were unavailable, inapplicable, absent, or actually returned no rows.
scripts/analyze_query_evidence.py — deterministic
evidence validator and classifier.eval-spec.yaml (opens in a new tab)references/history-and-collection.md (opens in a new tab)references/load-hash-and-sos.md (opens in a new tab)references/operator-statistics.md (opens in a new tab)references/output-contract.md (opens in a new tab)references/query-insights-boundaries.md (opens in a new tab)scripts/analyze_query_evidence.py (opens in a new tab)scripts/collect_snowflake_evidence.py (opens in a new tab)scripts/sql/query.sql (opens in a new tab)tests/fixtures/collector_query_output.json (opens in a new tab)tests/fixtures/query_evidence.json (opens in a new tab)tests/fixtures/query_evidence_incomplete.json (opens in a new tab)tests/test_analyze_query_evidence.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
inherithigh10 skills in this plugin
/snowflake-access-guardianAudit Snowflake effective access and produce a safe least-privilege change packet.
Trace account-role inheritance, primary and secondary roles, managed-access
schemas, ownership, direct-to-user/PUBLIC grants, orphaned principals, and
existing-versus-future-grant conflicts. Use when access is unexpectedly broad or
denied, a role graph needs review, or an authorization cleanup needs evidence.
Trigger with phrases like "Snowflake access audit", "trace Snowflake grants",
"why can this user read", "Snowflake RBAC drift", or "future grants conflict".
/snowflake-cost-leak-hunterAudit and analyze Snowflake warehouse, serverless, Adaptive, storage, transfer, and AI cost evidence with a typed ledger that prevents double counting and exposes freshness, attribution, control, and invoice boundaries. Use when a Snowflake bill increased, a team needs chargeback/showback evidence, credits appear unexplained, or an operator asks which usage merits investigation. Trigger with "Snowflake bill increased", "find idle Snowflake credits", "Snowflake cost attribution", or "untagged Snowflake spend". Do not use to mutate cost controls or claim savings./snowflake-data-quality-sentinelAssess trusted Snowflake data metric function coverage and expectation evidence
without reading customer rows. Use when evaluations, definitions, schedules,
notifications, anomaly state, or monitoring coverage may be incomplete or
unhealthy. Trigger with "Snowflake data quality", "DMF expectation",
"definition drift", "missing evaluation", or "notification gap".
/snowflake-deploy-medicReview and safely diagnose Snowflake infrastructure and database deployments
across the snowflakedb/snowflake Terraform 2.x provider, grants/state/imports,
schemachange versioned and repeatable migrations, Snowflake CLI/drivers, and
behavior-change releases. Use before a production deploy, when a plan wants
to replace or revoke grants, state is unreadable, a migration checksum drifts,
or a CLI/driver upgrade changes behavior. Produces a zero-change/plan verdict,
ordered remediation, and tested rollback requirements. It never applies,
destroys, deploys, runs mutating SQL, or edits state/history automatically.
Trigger with "Snowflake Terraform plan", "grant import", "terraform state",
"schemachange checksum", "repeatable migration", "Snowflake CLI upgrade",
"driver BCR", or "rollback Snowflake deploy". Use when a production change
needs a current plan, migration-integrity, toolchain, or rollback gate.
/snowflake-failover-readiness-drillAnalyze Snowflake failover-group RPO/RTO readiness from independently trusted,
privacy-preserving live receipts without executing refresh, failover, failback,
redirect, cancellation, resume, or session changes. Use when an owner needs a
Business Critical disaster-recovery preflight, replication failure diagnosis,
dangling-reference check, or operator-executed drill proof. Trigger with "Snowflake
failover drill", "replication RPO", "failback proof", or "secondary refresh".
/snowflake-governance-coverage-auditorAudit trusted Snowflake classification, tags, masking, row access, projection,
join, aggregation, and privacy-policy evidence without reading customer data.
Use when governance enforcement may be missing or ambiguous. Trigger with
"Snowflake governance coverage", "policy precedence", "tag policy gaps",
"classification failure", or "POLICY_CONTEXT verification".
npx claudepluginhub jeremylongshore/tons-of-skills-marketplace --plugin snowflake-packOther plugins' skills for the same job