Smart Supabase Tool
Production-ready command that handles explore, analyze, supabase, database. Includes structured workflows, validation checks, and reusable patterns for database.
Smart Supabase Tool
Execute common Supabase operations with intelligent context detection, including table queries, RPC calls, and storage management.
When to Use This Command
Run this command when you need to:
- Run ad-hoc SQL queries or RPC function calls against your Supabase database from the terminal
- Manage Supabase Storage buckets, upload files, or generate signed URLs quickly
- Inspect table schemas, row counts, and index statistics without opening the Supabase dashboard
Consider alternatives when:
- You need to create or manage database migrations (use supabase-migration-assistant-launcher)
- You need to audit security policies and RLS rules (use efficient-supabase-security-audit)
Quick Start
Configuration
name: smart-supabase-tool type: command category: database
Example Invocation
claude command:run smart-supabase-tool --query "SELECT * FROM users WHERE created_at > now() - interval '7 days'" --project myapp
Example Output
[Connect] Project: myapp | Region: us-east-1
[Detect] Query type: SELECT (read-only)
[Execute] Running query...
| id | email | created_at | plan |
|------|----------------------|---------------------|---------|
| 1042 | [email protected] | 2026-03-10 14:22:01 | pro |
| 1043 | [email protected] | 2026-03-11 09:15:33 | free |
| 1044 | [email protected] | 2026-03-14 18:40:12 | pro |
[Result] 3 rows returned in 42ms
Core Concepts
Supabase Tool Overview
| Aspect | Details |
|---|---|
| Operations | SQL queries, RPC calls, storage CRUD, schema introspection |
| Context Detection | Auto-identifies query type (read/write) and applies safety checks |
| Auth | Uses Supabase service role key for full access or anon key for RLS testing |
| Output Formats | Table, JSON, CSV, or piped to file |
Operation Workflow
[Parse Command + Detect Operation Type]
|
[Load Project Credentials]
|
[Safety Check] --> Write? --> Confirm?
|
[Execute via Supabase Client/REST API]
|
[Format + Display Results]
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
| query | string | none | SQL query or RPC function call to execute |
| project | string | auto | Supabase project reference (auto-detected from .env) |
| role | string | service | Auth role: service (full access) or anon (RLS enforced) |
| format | string | table | Output format: table, json, or csv |
| confirm-writes | boolean | true | Require confirmation before executing INSERT, UPDATE, DELETE |
Best Practices
-
Use Anon Role for RLS Testing - Switch to
--role anonto test that your Row Level Security policies work correctly from the client perspective. Service role bypasses all RLS. -
Always Preview Destructive Queries - Keep
--confirm-writesenabled. The command will show a dry-run of affected rows before executing any INSERT, UPDATE, or DELETE statement. -
Pipe Large Results to Files - For queries returning hundreds of rows, redirect output with
--format csv > output.csvto avoid terminal flooding and enable further analysis in spreadsheets. -
Auto-Detect Project from .env - Place your
SUPABASE_URLandSUPABASE_SERVICE_ROLE_KEYin a.envfile. The command reads these automatically, eliminating the need to specify--projecteach time. -
Use RPC for Complex Operations - Prefer Supabase RPC function calls over raw SQL for multi-step operations. RPC functions run inside a transaction and benefit from server-side error handling.
Common Issues
-
Permission Denied with Anon Key - RLS policies are blocking the query. This is expected behavior. Switch to
--role servicefor admin access, or verify your RLS policies grant the needed permissions. -
Connection Refused on localhost - Ensure your Supabase local dev instance is running with
supabase start. The command tries the URL from.env, which may point to a stopped local instance. -
Query Timeout on Large Tables - Add
LIMITclauses to queries on large tables. Full table scans without limits can exceed Supabase's default statement timeout of 8 seconds.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Git Commit Message Generator
Generates well-structured conventional commit messages by analyzing staged changes. Follows Conventional Commits spec with scope detection.
React Component Scaffolder
Scaffolds a complete React component with TypeScript types, Tailwind styles, Storybook stories, and unit tests. Follows project conventions automatically.
CI/CD Pipeline Generator
Generates GitHub Actions workflows for CI/CD including linting, testing, building, and deploying. Detects project stack automatically.