Agent skill

Supabase Reliability Patterns

by jeremylongshore in jeremylongshore/tons-of-skills-marketplace

Build resilient Supabase integrations: circuit breakers wrapping createClient calls, offline queue with IndexedDB, graceful degradation with cached fallbacks, health check endpoints, retry with…

MITAuto-check passedDevOps & Cloud

Install Supabase Reliability Patterns

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill supabase-reliability-patterns -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace supabase-reliability-patterns --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/supabase-reliability-patterns .claude/skills/supabase-reliability-patterns && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
supabase-reliability-patterns
GitHub stars
2.8k
Token cost
~2.7k tokens
SKILL.md length
438 words
Files
7 (incl. references)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

Build resilient Supabase integrations: circuit breakers wrapping createClient calls, offline queue with IndexedDB, graceful degradation with cached fallbacks, health check endpoints, retry with…

  • Works in 2 steps: Circuit Breaker and Retry with… → Offline Queue and Graceful Degradation
  • Building fault-tolerant apps
  • SKILL.md covers Overview, Prerequisites, Instructions and Output, plus 4 more sections
  • Needs SUPABASE_ANON_KEY

What it does

Supabase Reliability Patterns is an agent skill from jeremylongshore/tons-of-skills-marketplace. Build resilient Supabase integrations: circuit breakers wrapping createClient calls, offline queue with IndexedDB, graceful degradation with cached fallbacks, health check endpoints, retry with exponential backoff and jitter, and dual-write patterns for critical data. Use when building fault-tolerant apps, handling Supabase outages gracefully, implementing offline-first patterns, or adding retry logic to SDK calls. Trigger with phrases like "supabase circuit breaker", "supabase offline", "supabase retry"…

Its SKILL.md is about 2.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files, including reference files (for example `references/circuit-breaker.md`, `references/dead-letter-queue.md` and `references/errors.md`). Compatibility notes: Designed for Claude Code

It sits in DevOps & Cloud, covering Error handling and Incident response. It works with Supabase and Redis. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.

When your agent uses it

  • Building fault-tolerant apps
  • Handling Supabase outages gracefully
  • Implementing offline-first patterns
  • Adding retry logic to SDK calls

Example prompts

  • “supabase circuit breaker”
  • “supabase offline”
  • “supabase retry”
  • “/supabase-reliability-patterns”

Requirements

  • A credential in SUPABASE_ANON_KEY
  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Bash(supabase:*), Bash(curl:*), Grep

Workflow steps

2 steps, taken from the step headings in SKILL.md.

  1. Circuit Breaker and Retry with Exponential Backoff
  2. Offline Queue and Graceful Degradation

What it can do on your machine

Read from SKILL.md and the folder at commit 80f86df. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Bash(supabase:*)
    • Bash(curl:*)
    • Grep

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • martinfowler.com
    • docs.aws.amazon.com
    • status.supabase.com
    • developer.mozilla.org
    • supabase.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • SUPABASE_ANON_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code

    From compatibility in the SKILL.md frontmatter.

Context cost

Supabase Reliability Patterns loads about 2.7k tokens when it runs, and up to ~7.3k if it reads all its reference files. Until then it costs about 163 tokens; SKILL.md has 438 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~163
When it runs · the whole SKILL.md, loaded when a task matches
~2.7k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~7.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from jeremylongshore/tons-of-skills-marketplace at commit 80f86df, republished under its MIT licence (© jeremylongshore). 438 words, ~2,718 tokens.

Download SKILL.mdSave it as .claude/skills/supabase-reliability-patterns/SKILL.md (or your agent's skills folder). This skill also uses 6 other files; get the full folder from GitHub.
name
supabase-reliability-patterns
description
Build resilient Supabase integrations: circuit breakers wrapping createClient calls, offline queue with IndexedDB, graceful degradation with cached fallbacks, health check endpoints, retry with exponential backoff and jitter, and dual-write patterns for critical data. Use when building fault-tolerant apps, handling Supabase outages gracefully, implementing offline-first patterns, or adding retry logic to SDK calls. Trigger with phrases like "supabase circuit breaker", "supabase offline", "supabase retry", "supabase health check", "supabase fallback", "supabase resilience", "supabase dual write", "supabase outage".
allowed-tools
Read, Write, Edit, Bash(supabase:*), Bash(curl:*), Grep
compatibility
Designed for Claude Code
version
1.54.0
license
MIT
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
saas, supabase, reliability, resilience, circuit-breaker, offline, retry

Supabase Reliability Patterns

Overview

Production Supabase apps need six reliability layers: circuit breakers (stop calling Supabase when it's down to prevent cascading failures), offline queue (buffer writes when the network is unavailable and replay when reconnected), graceful degradation (serve cached or fallback data during outages), health checks (detect Supabase availability before routing traffic), retry with exponential backoff (handle transient errors without overwhelming the service), and dual-write (write critical data to both Supabase and a backup store). All patterns use real createClient from @supabase/supabase-js.

Prerequisites

  • @supabase/supabase-js v2+ installed
  • TypeScript project with Supabase client configured
  • For offline queue: browser environment with IndexedDB or server with Redis
  • For dual-write: secondary data store (Redis, DynamoDB, or local SQLite)

Instructions

Step 1 — Circuit Breaker and Retry with Exponential Backoff

A circuit breaker tracks failures per Supabase service (database, auth, storage) and stops making calls when a threshold is exceeded. Combined with retry logic, it prevents both cascading failures and unnecessary retries during extended outages.

Circuit Breaker Implementation
typescript
// lib/circuit-breaker.ts
import { createClient } from '@supabase/supabase-js'
import type { Database } from './database.types'

type CircuitState = 'CLOSED' | 'OPEN' | 'HALF_OPEN'

interface CircuitBreakerOptions {
  failureThreshold: number    // failures before opening
  resetTimeoutMs: number      // ms before trying again (half-open)
  halfOpenSuccesses: number   // successes in half-open to close
  name: string                // for logging
}

class CircuitBreaker {
  private state: CircuitState = 'CLOSED'
  private failures = 0
  private lastFailureTime = 0
  private halfOpenSuccesses = 0

  constructor(private opts: CircuitBreakerOptions) {}

  async call<T>(fn: () => Promise<T>, fallback?: () => T): Promise<T> {
    // Check if circuit should transition from OPEN to HALF_OPEN
    if (this.state === 'OPEN') {
      if (Date.now() - this.lastFailureTime > this.opts.resetTimeoutMs) {
        this.state = 'HALF_OPEN'
        this.halfOpenSuccesses = 0
        console.log(`[CircuitBreaker:${this.opts.name}] OPEN → HALF_OPEN`)
      } else {
        if (fallback) return fallback()
        throw new Error(`Circuit breaker ${this.opts.name} is OPEN`)
      }
    }

    try {
      const result = await fn()

      // Success in HALF_OPEN: count toward recovery
      if (this.state === 'HALF_OPEN') {
        this.halfOpenSuccesses++
        if (this.halfOpenSuccesses >= this.opts.halfOpenSuccesses) {
          this.state = 'CLOSED'
          this.failures = 0
          console.log(`[CircuitBreaker:${this.opts.name}] HALF_OPEN → CLOSED`)
        }
      } else {
        this.failures = 0  // reset on success in CLOSED state
      }

      return result
    } catch (error) {
      this.failures++
      this.lastFailureTime = Date.now()

      if (this.failures >= this.opts.failureThreshold) {
        this.state = 'OPEN'
        console.error(
          `[CircuitBreaker:${this.opts.name}] CLOSED → OPEN after ${this.failures} failures`
        )
      }

      if (fallback) return fallback()
      throw error
    }
  }

  get currentState() {
    return { state: this.state, failures: this.failures }
  }
}

// One circuit breaker per Supabase service domain
export const dbCircuit = new CircuitBreaker({
  name: 'database',
  failureThreshold: 5,
  resetTimeoutMs: 30_000,
  halfOpenSuccesses: 3,
})

export const authCircuit = new CircuitBreaker({
  name: 'auth',
  failureThreshold: 3,
  resetTimeoutMs: 15_000,
  halfOpenSuccesses: 2,
})

export const storageCircuit = new CircuitBreaker({
  name: 'storage',
  failureThreshold: 3,
  resetTimeoutMs: 60_000,
  halfOpenSuccesses: 2,
})
Retry with Exponential Backoff and Jitter
typescript
// lib/retry.ts
interface RetryOptions {
  maxRetries: number
  baseDelayMs: number
  maxDelayMs: number
  retryableErrors?: string[]  // Supabase error codes to retry
}

const DEFAULT_RETRYABLE = [
  'PGRST301',   // connection error
  '08006',      // connection failure
  '57014',      // query cancelled (timeout)
  '40001',      // serialization failure
  '53300',      // too many connections
]

export async function withRetry<T>(
  fn: () => Promise<{ data: T | null; error: any }>,
  opts: RetryOptions = { maxRetries: 3, baseDelayMs: 200, maxDelayMs: 5000 }
): Promise<{ data: T | null; error: any }> {
  const retryable = opts.retryableErrors ?? DEFAULT_RETRYABLE

  for (let attempt = 0; attempt <= opts.maxRetries; attempt++) {
    const result = await fn()

    if (!result.error) return result

    // Don't retry non-retryable errors (auth, RLS, validation)
    const errorCode = result.error.code ?? ''
    if (!retryable.includes(errorCode) && attempt > 0) {
      return result
    }

    if (attempt < opts.maxRetries) {
      // Exponential backoff with full jitter
      const delay = Math.min(
        opts.baseDelayMs * Math.pow(2, attempt) * (0.5 + Math.random() * 0.5),
        opts.maxDelayMs
      )
      console.warn(
        `[Retry] Attempt ${attempt + 1}/${opts.maxRetries} failed (${errorCode}), ` +
        `retrying in ${Math.round(delay)}ms`
      )
      await new Promise(resolve => setTimeout(resolve, delay))
    }
  }

  // Should not reach here, but return last result
  return fn()
}
Combining Circuit Breaker + Retry
typescript
// services/todo-service.ts
import { createClient } from '@supabase/supabase-js'
import type { Database } from '../lib/database.types'
import { dbCircuit } from '../lib/circuit-breaker'
import { withRetry } from '../lib/retry'

const supabase = createClient<Database>(
  process.env.SUPABASE_URL!,
  process.env.SUPABASE_ANON_KEY!
)

export const TodoService = {
  async list(userId: string) {
    return dbCircuit.call(
      // Retry transient errors inside the circuit breaker
      () => withRetry(() =>
        supabase
          .from('todos')
          .select('id, title, is_complete, created_at')
          .eq('user_id', userId)
          .order('created_at', { ascending: false })
      ),
      // Fallback when circuit is OPEN: return empty list
      () => ({ data: [], error: null })
    )
  },

  async create(todo: { title: string; user_id: string }) {
    return dbCircuit.call(
      () => withRetry(() =>
        supabase
          .from('todos')
          .insert(todo)
          .select('id, title, is_complete, created_at')
          .single()
      )
      // No fallback for writes — let the error propagate to the offline queue
    )
  },
}
Step 2 — Offline Queue and Graceful Degradation

See offline queue, graceful degradation, health checks, and dual-write for IndexedDB offline queue with auto-flush, cached fallback patterns, health check endpoints monitoring database/auth/storage, dual-write for critical data with Redis backup, and reconciliation jobs.

Output

  • Circuit breaker protecting database, auth, and storage calls independently
  • Retry with exponential backoff and jitter for transient Supabase errors
  • Offline queue buffering writes during network outages with auto-flush on reconnect
  • Graceful degradation serving cached or fallback data when Supabase is unavailable
  • Health check endpoint monitoring all three Supabase services
  • Dual-write pattern ensuring critical data survives Supabase outages
  • Reconciliation job detecting and replaying missing records
Show full SKILL.md (161 more words)Show less

Error Handling

IssueCauseSolution
Circuit stays OPEN indefinitelySupabase extended outageMonitor status.supabase.com; circuit auto-recovers via HALF_OPEN
Offline queue grows unboundedUser offline for hoursCap queue at 1000 items; show UI warning at 100
Stale cache served too longCache TTL too generousReduce cacheTtlMs; show "last updated" timestamp
Dual-write divergenceNetwork partitionRun reconciliation job every 5 min; alert on divergence count
Health check false positiveTransient network blipRequire 3 consecutive failures before marking unhealthy
Retry stormAll clients retry simultaneouslyJitter prevents thundering herd; circuit breaker stops retries when open

Examples

Example 1 — List todos with outage fallback. During a Supabase outage the circuit opens after 5 failures and the fallback serves an empty list instead of cascading errors:

typescript
import { TodoService } from './services/todo-service'

const { data, error } = await TodoService.list(userId)
// Healthy: data from Supabase (transient errors retried with backoff).
// Circuit OPEN: fallback returns { data: [], error: null } — UI renders
// an empty state instead of crashing.

Example 2 — Check circuit state before an expensive operation:

typescript
import { dbCircuit, storageCircuit } from './lib/circuit-breaker'

const { state, failures } = dbCircuit.currentState
if (state === 'OPEN') {
  console.warn(`Database circuit OPEN (${failures} failures) — deferring bulk import`)
} else if (storageCircuit.currentState.state !== 'OPEN') {
  await runBulkImport()
}

Resources

Next Steps

For organizational governance and policy guardrails, see supabase-policy-guardrails.

© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 6 other files (references) in skills/.curated/supabase-reliability-patterns of jeremylongshore/tons-of-skills-marketplace.

  • SKILL.md
  • references/circuit-breaker.md
  • references/dead-letter-queue.md
  • references/errors.md
  • references/examples.md
  • references/idempotency-keys.md
  • references/offline-degradation-health-dualwrite.md

Open the folder on GitHubat commit 80f86df

Compare with similar skills

Supabase Reliability Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Supabase Reliability Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Supabase Reliability Patterns this skilljeremylongshore/tons-of-skills-marketplace2.8k—~2.7kAutomated safety check: PassMIT
Release Itwondelai/skills2.4k—~4kAutomated safety check: PassMIT
Studio Error Handlingsupabase/supabase111k—~1.3kAutomated safety check: PassApache-2.0
Logging Observabilitygetsentry/toolkit918—~2.6kAutomated safety check: PassCustom licence
CI Validation Gatesbradygaster/squad3.3k—~1.1kAutomated safety check: PassMIT
Crash Instrumentationnexus-labs-automation/mobile-observability116—~744Automated safety check: PassMIT

Similar skills

  • Release It

    wondelai/skills

    Build production-ready systems with stability patterns: circuit breakers, bulkheads, timeouts, and retry logic.

    2.4k GitHub stars~4k tokensUpdated 28 days ago
    DevOps & CloudAuto-check passed
  • Studio Error Handling

    supabase/supabase

    Official

    Error display and troubleshooting pattern for Supabase Studio.

    111k GitHub stars~1.3k tokensUpdated today
    DevelopmentAuto-check passed
  • Logging Observability

    getsentry/toolkit

    Official

    Review code for correct logging and error handling patterns.

    918 GitHub stars~2.6k tokensUpdated today
    DevOps & CloudAuto-check passed
  • CI Validation Gates

    bradygaster/squad

    Defensive CI/CD patterns: semver validation, token checks, retry logic, and draft detection

    3.3k GitHub stars~1.1k tokensUpdated today
    DevOps & CloudAuto-check passed
  • Crash Instrumentation

    nexus-labs-automation/mobile-observability

    Set up crash instrumentation with actionable context. An agent skill from nexus-labs-automation/mobile-observability.

    116 GitHub stars~744 tokensUpdated 1 mo ago
    DevOps & CloudAuto-check passed
  • Incident Triage Harness

    madebyaris/advance-minimax-m3-cursor-rules

    Walks an agent through an evidence-first incident investigation across logs, metrics, code and screenshots, from first symptom to the smallest safe mitigation.

    126 GitHub stars~984 tokensUpdated 3 mo ago
    DevOps & CloudAuto-check passed

More from jeremylongshore/tons-of-skills-marketplace

All 3,342 skills in this repo
  • Performing Security Code Review

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.

    2.8k GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check: notes
  • Adapting Transfer Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill automates the adaptation of pre-trained machine learning models using transfer learning techniques.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Agent Context Loader

    jeremylongshore/tons-of-skills-marketplace

    Execute proactive auto-loading: automatically detects and loads agents.md files.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Aggregating Performance Metrics

    jeremylongshore/tons-of-skills-marketplace

    Aggregate and centralize performance metrics from applications, systems, databases, caches, and services.

    2.8k GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Analyzing Capacity Planning

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to analyze capacity requirements and plan for future growth.

    2.8k GitHub stars~947 tokensUpdated today
    Auto-check passed
  • Analyzing Database Indexes

    jeremylongshore/tons-of-skills-marketplace

    Process use when you need to work with database indexing. An agent skill from jeremylongshore/tons-of-skills-marketplace.

    2.8k GitHub stars~2k tokensUpdated today
    Auto-check passed

Works with

Questions about Supabase Reliability Patterns

What does Supabase Reliability Patterns do?

Build resilient Supabase integrations: circuit breakers wrapping createClient calls, offline queue with IndexedDB, graceful degradation with cached fallbacks, health check endpoints, retry with…. Supabase Reliability Patterns is an agent skill from jeremylongshore/tons-of-skills-marketplace. Build resilient Supabase integrations: circuit breakers wrapping createClient calls, offline queue with IndexedDB, graceful degradation with cached fallbacks, health check endpoints, retry with exponential backoff and jitter, and dual-write patterns for critical data.

When should I use Supabase Reliability Patterns?

Supabase Reliability Patterns fits situations like: building fault-tolerant apps; handling Supabase outages gracefully; implementing offline-first patterns; adding retry logic to SDK calls.

How do I install Supabase Reliability Patterns in Claude Code?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill supabase-reliability-patterns -a claude-code`. Or copy the skill folder (skills/.curated/supabase-reliability-patterns in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/supabase-reliability-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Supabase Reliability Patterns in Codex?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill supabase-reliability-patterns -a codex`. Or copy the skill folder (skills/.curated/supabase-reliability-patterns in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/supabase-reliability-patterns in your project. Codex loads it when a task matches its description.

Can I use Supabase Reliability Patterns in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill supabase-reliability-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/supabase-reliability-patterns, .gemini/skills/supabase-reliability-patterns, .github/skills/supabase-reliability-patterns and .opencode/skills/supabase-reliability-patterns in your project.

What does Supabase Reliability Patterns need to run?

Going by SKILL.md and its folder, Supabase Reliability Patterns needs credentials named SUPABASE_ANON_KEY. Our summary lists: A credential in SUPABASE_ANON_KEY. Its frontmatter pre-approves these tools: Read, Write, Edit, Bash(supabase:*), Bash(curl:*), Grep. Compatibility (from SKILL.md): Designed for Claude Code.

Does Supabase Reliability Patterns access the network?

SKILL.md names 5 domains. As links in the text: martinfowler.com, docs.aws.amazon.com, status.supabase.com, developer.mozilla.org and supabase.com. This is read from the text; nothing was executed.

Is Supabase Reliability Patterns safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Supabase Reliability Patterns use?

Supabase Reliability Patterns is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Supabase Reliability Patterns use?

About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 4.6k tokens, read only when the agent opens those files.

What are the alternatives to Supabase Reliability Patterns?

Skills that share tags, products or a category with Supabase Reliability Patterns: Release It (wondelai/skills, 2.4k stars), Studio Error Handling (supabase/supabase, 111k stars), Logging Observability (getsentry/toolkit, 918 stars) and CI Validation Gates (bradygaster/squad, 3.3k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Supabase Reliability Patterns?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,825 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 9, 2026.

Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.