Supabase Context Guide for AI Coding (llms.txt + Rules + MCP)

Open source Firebase alternative with Postgres database, Authentication, instant APIs, and Realtime subscriptions.

1. Supabase Official llms.txt & Clean Markdown Documentation

Official Support (Jeremy Howard Spec v2)

Feed this clean, token-efficient Markdown documentation directly to Antigravity, Cursor, or Claude Code to prevent hallucinations and outdated API syntax.

# Standard llms.txt Index Endpoint
https://supabase.com/docs/llms.txt

# Comprehensive Documentation Bundle
https://supabase.com/docs/llms-full.txt
Estimated Token Footprint: ~32k tokens (Fits smoothly inside standard 128k/1M context windows)

2. Production-Ready Supabase Cursor Rules (.cursorrules & .mdc)

Best practices for building with Supabase in modern AI IDEs (Antigravity, Cursor, Windsurf). Save this into .cursor/rules/supabase.mdc in your project repository.

// .cursor/rules/supabase.mdc or .gemini/rules/supabase.md
- Always use @supabase/ssr package for Next.js App Router (createBrowserClient / createServerClient).
- Never expose SUPABASE_SERVICE_ROLE_KEY to the client/browser bundle.
- Implement Row Level Security (RLS) policies on every public table by default.
- Prefer database functions and generated TypeScript types from 'supabase gen types typescript'.

3. Supabase Antigravity & Claude Code System Instructions

Add this concise instruction block to your workspace .gemini/rules or project system prompt.

// Context Anchor for Supabase
When writing code for Supabase, refer directly to the verified specifications at https://supabase.com/docs/llms.txt.
Follow strict error-handling and avoid deprecated API calls.

4. Model Context Protocol (MCP) Server Setup for Supabase

Connect your AI coding agent directly to live Supabase tools and schemas via MCP.

{
  "mcpServers": {
    "supabase": {
      "command": "npx",
      "args": ["-y", "@supabase/mcp-server-supabase@latest", "--access-token", "YOUR_TOKEN"]
    }
  }
}

5. Troubleshooting: Common Supabase AI Coding Issues & Fixes

Frequently reported errors when LLMs generate Supabase code without proper context:

⚠️ Proactive Fix: Fix: Avoid calling createServerClient in Client Components. Ensure NEXT_PUBLIC_SUPABASE_ANON_KEY is defined in environment variables.

6. Best Used With (Supabase Architecture Combos)

Engineers building with Supabase frequently combine these complementary developer frameworks: