snowflake-reliability-patterns
Implement Snowflake reliability patterns: replication, failover, Time Travel recovery, and application-level resilience for Snowflake integrations. Use when building fault-tolerant pipelines, configuring disaster recovery, or adding resilience to production Snowflake services. Trigger with phrases like "snowflake reliability", "snowflake failover", "snowflake replication", "snowflake disaster recovery", "snowflake Time Travel".
Best use case
snowflake-reliability-patterns is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Implement Snowflake reliability patterns: replication, failover, Time Travel recovery, and application-level resilience for Snowflake integrations. Use when building fault-tolerant pipelines, configuring disaster recovery, or adding resilience to production Snowflake services. Trigger with phrases like "snowflake reliability", "snowflake failover", "snowflake replication", "snowflake disaster recovery", "snowflake Time Travel".
Teams using snowflake-reliability-patterns should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/snowflake-reliability-patterns/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How snowflake-reliability-patterns Compares
| Feature / Agent | snowflake-reliability-patterns | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Implement Snowflake reliability patterns: replication, failover, Time Travel recovery, and application-level resilience for Snowflake integrations. Use when building fault-tolerant pipelines, configuring disaster recovery, or adding resilience to production Snowflake services. Trigger with phrases like "snowflake reliability", "snowflake failover", "snowflake replication", "snowflake disaster recovery", "snowflake Time Travel".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Snowflake Reliability Patterns
## Overview
Production-grade reliability patterns for Snowflake: database replication, account failover, Time Travel recovery, and application-level circuit breakers.
## Instructions
### Step 1: Time Travel for Point-in-Time Recovery
```sql
-- Query historical data (up to 90 days on Enterprise Edition)
SELECT * FROM orders
AT (TIMESTAMP => '2026-03-21 14:00:00'::TIMESTAMP_NTZ);
-- Restore a table to a previous state
CREATE OR REPLACE TABLE orders
CLONE orders AT (TIMESTAMP => '2026-03-21 14:00:00'::TIMESTAMP_NTZ);
-- Restore a dropped table
UNDROP TABLE orders;
UNDROP SCHEMA my_schema;
UNDROP DATABASE my_database;
-- Query by offset (5 minutes ago)
SELECT * FROM orders AT (OFFSET => -300);
-- Query by statement ID (before a specific query ran)
SELECT * FROM orders BEFORE (STATEMENT => '<query_id_of_bad_update>');
-- Set retention period per table
ALTER TABLE critical_data SET DATA_RETENTION_TIME_IN_DAYS = 90;
ALTER TABLE temp_staging SET DATA_RETENTION_TIME_IN_DAYS = 0; -- No Time Travel
```
### Step 2: Database Replication Across Regions
```sql
-- Enable replication on source account (primary)
ALTER DATABASE PROD_DW ENABLE REPLICATION TO ACCOUNTS
myorg.us_east_account,
myorg.eu_west_account;
-- On target account: create replica database
CREATE DATABASE PROD_DW_REPLICA
AS REPLICA OF myorg.us_west_account.PROD_DW;
-- Refresh replica (manual or scheduled)
ALTER DATABASE PROD_DW_REPLICA REFRESH;
-- Check replication status
SELECT * FROM TABLE(INFORMATION_SCHEMA.DATABASE_REPLICATION_USAGE_HISTORY(
DATE_RANGE_START => DATEADD(hours, -24, CURRENT_TIMESTAMP())
));
-- Check replication lag
SELECT database_name, primary_snowflake_region,
replication_allowed, is_primary,
DATEDIFF('minute', snowflake_region_last_refresh_time, CURRENT_TIMESTAMP()) AS lag_minutes
FROM TABLE(INFORMATION_SCHEMA.REPLICATION_DATABASES())
WHERE database_name = 'PROD_DW_REPLICA';
```
### Step 3: Account Failover Groups
```sql
-- Create failover group (replicates databases, warehouses, roles, etc.)
-- On primary account:
CREATE FAILOVER GROUP prod_failover
OBJECT_TYPES = DATABASES, WAREHOUSES, ROLES, USERS, INTEGRATIONS
ALLOWED_DATABASES = PROD_DW
ALLOWED_ACCOUNTS = myorg.us_east_account
REPLICATION_SCHEDULE = '10 MINUTE';
-- On secondary account: create as replica
CREATE FAILOVER GROUP prod_failover
AS REPLICA OF myorg.us_west_account.prod_failover;
-- Promote secondary to primary (during outage)
ALTER FAILOVER GROUP prod_failover PRIMARY;
-- After recovery, switch back
-- On original primary:
ALTER FAILOVER GROUP prod_failover PRIMARY;
```
### Step 4: Application-Level Connection Failover
```typescript
// src/snowflake/resilient-connection.ts
import snowflake from 'snowflake-sdk';
interface FailoverConfig {
primary: snowflake.ConnectionOptions;
secondary: snowflake.ConnectionOptions;
healthCheckIntervalMs: number;
}
class ResilientSnowflakeConnection {
private activeConn: snowflake.Connection | null = null;
private isPrimary = true;
private config: FailoverConfig;
constructor(config: FailoverConfig) {
this.config = config;
}
async connect(): Promise<snowflake.Connection> {
try {
this.activeConn = await this.tryConnect(this.config.primary);
this.isPrimary = true;
return this.activeConn;
} catch (primaryErr) {
console.warn('Primary Snowflake connection failed, trying secondary');
try {
this.activeConn = await this.tryConnect(this.config.secondary);
this.isPrimary = false;
return this.activeConn;
} catch (secondaryErr) {
throw new Error(`Both Snowflake connections failed.
Primary: ${primaryErr.message}
Secondary: ${secondaryErr.message}`);
}
}
}
private tryConnect(opts: snowflake.ConnectionOptions): Promise<snowflake.Connection> {
return new Promise((resolve, reject) => {
const conn = snowflake.createConnection(opts);
conn.connect((err, conn) => (err ? reject(err) : resolve(conn)));
});
}
async healthCheck(): Promise<{ connected: boolean; isPrimary: boolean }> {
try {
await new Promise<void>((resolve, reject) => {
this.activeConn!.execute({
sqlText: 'SELECT 1',
complete: (err) => (err ? reject(err) : resolve()),
});
});
return { connected: true, isPrimary: this.isPrimary };
} catch {
return { connected: false, isPrimary: this.isPrimary };
}
}
}
// Usage
const resilientConn = new ResilientSnowflakeConnection({
primary: {
account: 'myorg-primary',
username: process.env.SNOWFLAKE_USER!,
password: process.env.SNOWFLAKE_PASSWORD!,
warehouse: 'PROD_WH',
database: 'PROD_DW',
},
secondary: {
account: 'myorg-secondary',
username: process.env.SNOWFLAKE_USER!,
password: process.env.SNOWFLAKE_PASSWORD!,
warehouse: 'PROD_WH',
database: 'PROD_DW_REPLICA',
},
healthCheckIntervalMs: 30000,
});
```
### Step 5: Pipeline Retry and Idempotency
```sql
-- Idempotent data loading (safe to retry)
MERGE INTO silver.orders AS target
USING (
SELECT * FROM bronze.raw_orders
WHERE ingestion_time >= DATEADD(hours, -1, CURRENT_TIMESTAMP())
) AS source
ON target.order_id = source.order_id
WHEN NOT MATCHED THEN INSERT
(order_id, customer_id, amount, order_date)
VALUES
(source.order_id, source.customer_id, source.amount, source.order_date);
-- MERGE is idempotent: running it twice with the same data produces the same result
-- Prefer MERGE over INSERT for retry-safe pipelines
-- Task retry configuration
CREATE OR REPLACE TASK reliable_transform
WAREHOUSE = ETL_WH
SCHEDULE = '5 MINUTE'
ALLOW_OVERLAPPING_EXECUTION = FALSE -- Prevent concurrent runs
SUSPEND_TASK_AFTER_NUM_FAILURES = 3 -- Auto-suspend after 3 failures
WHEN SYSTEM$STREAM_HAS_DATA('orders_stream')
AS
MERGE INTO dim_orders ...;
ALTER TASK reliable_transform RESUME;
```
### Step 6: Backup Strategy
```sql
-- Zero-copy clone backups (instant, no extra storage until data changes)
CREATE DATABASE PROD_DW_BACKUP_20260322
CLONE PROD_DW;
-- Automated daily backup via task
CREATE OR REPLACE TASK daily_backup
WAREHOUSE = ADMIN_WH
SCHEDULE = 'USING CRON 0 3 * * * UTC'
AS
BEGIN
LET backup_name VARCHAR := 'PROD_DW_BACKUP_' || TO_CHAR(CURRENT_DATE(), 'YYYYMMDD');
EXECUTE IMMEDIATE 'CREATE DATABASE IF NOT EXISTS ' || :backup_name || ' CLONE PROD_DW';
-- Clean up backups older than 7 days
-- (done via separate cleanup task or stored procedure)
END;
```
## Recovery Time Objectives
| Scenario | Recovery Method | RTO | RPO |
|----------|---------------|-----|-----|
| Accidental table drop | UNDROP | Instant | Zero |
| Bad data update | Time Travel CLONE | Minutes | Configurable (up to 90 days) |
| Regional outage | Failover group | 10-30 min | Replication lag |
| Account compromise | Contact Snowflake support | Hours | Last backup |
## Error Handling
| Issue | Cause | Solution |
|-------|-------|----------|
| Time Travel expired | Past retention period | Increase DATA_RETENTION_TIME_IN_DAYS |
| Replication lag high | Large data changes | Check replication schedule, network |
| Failover fails | Secondary not synced | Verify failover group status |
| UNDROP fails | Object recreated with same name | Rename current object first |
## Resources
- [Time Travel](https://docs.snowflake.com/en/user-guide/data-time-travel)
- [Database Replication](https://docs.snowflake.com/en/user-guide/account-replication-intro)
- [Failover Groups](https://docs.snowflake.com/en/user-guide/account-replication-failover-failback)
- [Business Continuity](https://docs.snowflake.com/en/user-guide/replication-intro)
## Next Steps
For policy enforcement, see `snowflake-policy-guardrails`.Related Skills
workhuman-sdk-patterns
Workhuman sdk patterns for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman sdk patterns".
wispr-sdk-patterns
Wispr Flow sdk patterns for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr sdk patterns".
windsurf-sdk-patterns
Apply production-ready Windsurf workspace configuration and Cascade interaction patterns. Use when configuring .windsurfrules, workspace rules, MCP servers, or establishing team coding standards for Windsurf AI. Trigger with phrases like "windsurf patterns", "windsurf best practices", "windsurf config patterns", "windsurfrules", "windsurf workspace".
windsurf-reliability-patterns
Implement reliable Cascade workflows with checkpoints, rollback, and incremental editing. Use when building fault-tolerant AI coding workflows, preventing Cascade from breaking builds, or establishing safe practices for multi-file AI edits. Trigger with phrases like "windsurf reliability", "cascade safety", "windsurf rollback", "cascade checkpoint", "safe cascade workflow".
webflow-sdk-patterns
Apply production-ready Webflow SDK patterns — singleton client, typed error handling, pagination helpers, and raw response access for the webflow-api package. Use when implementing Webflow integrations, refactoring SDK usage, or establishing team coding standards. Trigger with phrases like "webflow SDK patterns", "webflow best practices", "webflow code patterns", "idiomatic webflow", "webflow typescript".
vercel-sdk-patterns
Production-ready Vercel REST API patterns with typed fetch wrappers and error handling. Use when integrating with the Vercel API programmatically, building deployment tools, or establishing team coding standards for Vercel API calls. Trigger with phrases like "vercel SDK patterns", "vercel API wrapper", "vercel REST API client", "vercel best practices", "idiomatic vercel API".
vercel-reliability-patterns
Implement reliability patterns for Vercel deployments including circuit breakers, retry logic, and graceful degradation. Use when building fault-tolerant serverless functions, implementing retry strategies, or adding resilience to production Vercel services. Trigger with phrases like "vercel reliability", "vercel circuit breaker", "vercel resilience", "vercel fallback", "vercel graceful degradation".
veeva-sdk-patterns
Veeva Vault sdk patterns for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva sdk patterns".
vastai-sdk-patterns
Apply production-ready Vast.ai SDK patterns for Python and REST API. Use when implementing Vast.ai integrations, refactoring SDK usage, or establishing coding standards for GPU cloud operations. Trigger with phrases like "vastai SDK patterns", "vastai best practices", "vastai code patterns", "idiomatic vastai".
twinmind-sdk-patterns
Apply production-ready TwinMind SDK patterns for TypeScript and Python. Use when implementing TwinMind integrations, refactoring API usage, or establishing team coding standards for meeting AI integration. Trigger with phrases like "twinmind SDK patterns", "twinmind best practices", "twinmind code patterns", "idiomatic twinmind".
together-sdk-patterns
Together AI sdk patterns for inference, fine-tuning, and model deployment. Use when working with Together AI's OpenAI-compatible API. Trigger: "together sdk patterns".
techsmith-sdk-patterns
TechSmith sdk patterns for Snagit COM API and Camtasia automation. Use when working with TechSmith screen capture and video editing automation. Trigger: "techsmith sdk patterns".