Skip to main content
ClaudeWave
Slash Command238 repo starsupdated 4mo ago

supabase-performance-optimizer

This slash command optimizes Supabase database performance by delegating tasks to specialized agents based on the provided arguments. Use it to address specific performance concerns including query and index optimization, RLS and function security, realtime subscription issues, storage cleanup, or run all agents for comprehensive database optimization.

Install in Claude Code
Copy
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/maslennikov-ig/claude-code-orchestrator-kit/HEAD/.claude/commands/supabase-performance-optimizer.md -o ~/.claude/commands/supabase-performance-optimizer.md
Then start a new Claude Code session; the slash command loads automatically.

supabase-performance-optimizer.md

# Supabase Performance Optimizer

Optimize Supabase database performance with specialized agents: **$ARGUMENTS**

## Agent Delegation Matrix

| Argument | Agent | What it fixes |
|----------|-------|---------------|
| `--queries`, `--indexes`, `--rls`, `--functions` | `supabase-fixer` | Advisors API issues (security + performance) |
| `--realtime` | `supabase-realtime-optimizer` | Publication issues, subscription indexes |
| `--storage` | `supabase-storage-optimizer` | Orphaned files, table sizes, data types |
| `--all` | All three agents | Complete optimization |

## Task Execution

Based on **$ARGUMENTS**, delegate to the appropriate agent(s):

### For `--queries`, `--indexes`, `--rls`, `--functions`:

Use Task tool with:
- `subagent_type`: `supabase-fixer`
- `prompt`: Focus on performance advisors for query/index optimization, or security advisors for RLS/function issues

### For `--realtime`:

Use Task tool with:
- `subagent_type`: `supabase-realtime-optimizer`
- `prompt`: Optimize realtime subscriptions, check publications, add missing indexes for filters

### For `--storage`:

Use Task tool with:
- `subagent_type`: `supabase-storage-optimizer`
- `prompt`: Analyze table sizes, find orphaned files, optimize data types

### For `--all`:

Run all three agents sequentially:
1. First: `supabase-fixer` (security + performance advisors)
2. Then: `supabase-realtime-optimizer` (realtime publications)
3. Finally: `supabase-storage-optimizer` (storage cleanup)

## Expected Output

Each agent generates a structured report in `.tmp/current/`:
- `database-fixing-report.md` (from supabase-fixer)
- `realtime-optimization-report.md` (from supabase-realtime-optimizer)
- `storage-optimization-report.md` (from supabase-storage-optimizer)

## Quick Reference

```bash
# Fix security issues (RLS, functions)
/supabase-performance-optimizer --rls --functions

# Optimize queries and indexes
/supabase-performance-optimizer --queries --indexes

# Optimize realtime subscriptions
/supabase-performance-optimizer --realtime

# Clean up storage
/supabase-performance-optimizer --storage

# Full optimization (all agents)
/supabase-performance-optimizer --all
```