home / skills / jeremylongshore / claude-code-plugins-plus-skills / supabase-reference-architecture

This skill helps design and enforce a scalable Supabase reference architecture with a clean project layout, client wrapper, and health checks.

npx playbooks add skill jeremylongshore/claude-code-plugins-plus-skills --skill supabase-reference-architecture

Review the files below or copy the command above to add this skill to your agents.

Files (5)
SKILL.md
1.5 KB
---
name: supabase-reference-architecture
description: |
  Implement Supabase reference architecture with best-practice project layout.
  Use when designing new Supabase integrations, reviewing project structure,
  or establishing architecture standards for Supabase applications.
  Trigger with phrases like "supabase architecture", "supabase best practices",
  "supabase project structure", "how to organize supabase", "supabase layout".
allowed-tools: Read, Grep
version: 1.0.0
license: MIT
author: Jeremy Longshore <[email protected]>
---

# Supabase Reference Architecture

## Prerequisites
- Understanding of layered architecture
- Supabase SDK knowledge
- TypeScript project setup
- Testing framework configured

## Instructions

### Step 1: Create Directory Structure
Set up the project layout following the reference structure above.

### Step 2: Implement Client Wrapper
Create the singleton client with caching and monitoring.

### Step 3: Add Error Handling
Implement custom error classes for Supabase operations.

### Step 4: Configure Health Checks
Add health check endpoint for Supabase connectivity.

## Output
- Structured project layout
- Client wrapper with caching
- Error boundary implemented
- Health checks configured

## Error Handling

See `{baseDir}/references/errors.md` for comprehensive error handling.

## Examples

See `{baseDir}/references/examples.md` for detailed examples.

## Resources
- [Supabase SDK Documentation](https://supabase.com/docs/sdk)
- [Supabase Best Practices](https://supabase.com/docs/best-practices)

Overview

This skill implements a Supabase reference architecture with a best-practice project layout, client wrapper, error handling, and health checks. It helps teams establish consistent patterns for new Supabase integrations and reviews. Use it to bootstrap structured, maintainable Supabase applications quickly.

How this skill works

The skill provides a recommended directory structure and guides on creating a singleton Supabase client that includes caching and monitoring. It defines custom error classes and an error boundary pattern for predictable error handling. It also shows how to expose a health-check endpoint that verifies Supabase connectivity and basic operations.

When to use it

  • Designing a new Supabase-backed application or microservice
  • Onboarding teams to a consistent Supabase project layout
  • Reviewing or refactoring an existing Supabase integration
  • Establishing architecture standards and best practices for data access
  • Implementing observability and resilience around Supabase calls

Best practices

  • Organize code into clear layers: api, services, clients, models, and tests
  • Use a singleton client wrapper to centralize caching, retries, and metrics
  • Define explicit custom error classes for common Supabase failures
  • Keep health checks lightweight: simple connectivity and sample query
  • Write tests around client behavior, caching, and error handling

Example use cases

  • Initialize a new TypeScript project with the recommended folder layout before adding features
  • Replace ad-hoc Supabase calls with a centralized client to add caching and monitoring
  • Add a health-check endpoint to Kubernetes liveness/readiness probes
  • Standardize error responses across services by using shared error classes
  • Create onboarding guides and templates for developers joining the project

FAQ

Do I need TypeScript for this architecture?

TypeScript is recommended for type safety and clearer client contracts, but the patterns can be adapted to plain JavaScript.

What should the health check verify?

Keep it minimal: confirm the client can authenticate and run a simple read (e.g., select 1) or ping a lightweight table.