Home › Snowflake › Snowflake SQL + Snowpark Cursor rules

Snowflake SQL + Snowpark Cursor rules

Cursor rules for Snowflake work: idempotent SQL, warehouses and roles, Snowpark Python DataFrames, cost-aware queries, and safe deployments.

CursorSnowflake

How to use

Save this as .cursor/rules/snowflake.mdc in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.cursor/rules/snowflake.mdcDownload  
---
description: Snowflake SQL and Snowpark conventions
globs: ["**/*.sql", "snowpark/**/*.py", "**/snowflake.yml"]
alwaysApply: false
---

# Snowflake

- Use fully qualified names `DATABASE.SCHEMA.OBJECT` in deployable SQL; never depend on the session's current database.
- DDL is idempotent: `CREATE OR ALTER` / `CREATE ... IF NOT EXISTS` where supported; avoid `CREATE OR REPLACE TABLE` on tables with data (it drops history and grants). Use `CREATE OR REPLACE` freely for views and functions.
- Least privilege: work under a functional role, not `ACCOUNTADMIN`/`SYSADMIN`. Grants live in versioned scripts.
- Cost: select only needed columns (no `SELECT *` on wide tables), filter on clustering/date columns, add `LIMIT` to exploratory queries, and use an XS warehouse with auto-suspend for dev.
- Use `QUALIFY` for window filtering, `MERGE` for upserts, and `COPY INTO` / Snowpipe for loads instead of row-by-row inserts.
- Semi-structured data: `VARIANT` with `:path::type` casts and `LATERAL FLATTEN`; cast early and name columns.
- Time: store `TIMESTAMP_TZ` or UTC `TIMESTAMP_NTZ` consistently; document which.
- Snowpark Python: build lazy DataFrames (`session.table(...).filter(col(...))`), push work into Snowflake, and call `.collect()`/`.to_pandas()` only on small results. Register UDFs/stored procs with explicit `packages` and types.
- Secrets and connection params come from `connections.toml`/env vars or key-pair auth, never from code.
- Deploy with the repo's tool (Snowflake CLI `snow`, dbt, or schemachange); don't run ad hoc DDL in production.

## Done when
SQL runs cleanly in a dev schema, `snow`/dbt validation passes, and new objects have grants and comments.

More: all Snowflake rules · all Cursor rules

Related rules

Convex backend rules

Cursor rules for Convex backends: schema, validated queries/mutations/actions, indexes, and auth checks.

CursorConvex

Drizzle ORM rules

Cursor rules for Drizzle ORM with Postgres or SQLite: schema files, drizzle-kit migrations, and type-safe queries.

CursorDrizzle ORM

Firebase (modular SDK) rules

Cursor rules for Firebase web apps with the modular v11+ SDK, Firestore security rules, and emulator tests.

CursorFirebase

Mongoose (MongoDB ODM) rules

Cursor rules for Mongoose 8 with TypeScript: typed schemas, indexes, lean queries, validation, and transactions.

CursorMongoDB

Prisma ORM rules

Cursor rules for Prisma ORM 6 with PostgreSQL: schema changes, migrations, typed queries, and transactions.

CursorPrisma

Supabase backend rules

Cursor rules for apps on Supabase: Row Level Security first, migrations, typed clients and Edge Functions.

CursorSupabase

Get the best new AI prompts every week

One short email a week: the best new prompts and rules for ChatGPT, Claude, Gemini, Midjourney, Cursor and more, plus what changed in the tools. Free, unsubscribe anytime.

Finishes on our newsletter page at beehiiv (opens in a new tab). Or subscribe directly.