{
 "schema": "aiblocks-page/1",
 "id": "connect-code-to-supabase-builder-prompt",
 "type": "prompt",
 "name": "Supabase connection prompt writer",
 "summary": "Paste one prompt into Claude Code to connect your app to Supabase from the server, keep the secret key safe and run a first read check.",
 "headline": "Supabase connection prompt writer",
 "subhead": "Get a coding brief to connect your app to Supabase, with scoped access, safe secrets and a read check.",
 "job": {
  "id": "build-software",
  "name": "Build and ship software"
 },
 "level": "intermediate",
 "thinking": "medium",
 "tested": true,
 "updated": "2026-11-03",
 "first_published": "2026-10-25",
 "inputs": [
  {
   "type": "codebase",
   "required": true,
   "label": "Codebase",
   "what": "a project's code, in a folder or repo the AI can open"
  }
 ],
 "outputs": [
  {
   "type": "code_change",
   "required": true,
   "label": "Code change",
   "what": "a change to the code, with what it fixes and how it was checked"
  }
 ],
 "you_give": [
  "Your code project, open in Claude Code",
  "Your Supabase URL and service role key, saved in .env.local",
  "The agent_jobs and agent_activity_log tables in your Supabase project"
 ],
 "you_get": [
  "A server-only Supabase client file (lib/supabase/admin.ts)",
  "A test script (scripts/test-db-connection.ts)",
  "A plain explanation of the service role key, and what the test should print"
 ],
 "use_when": [
  "You are building an app with a Next.js or Node server and want it to talk to Supabase.",
  "You want a first read test that proves the link works.",
  "You are new to coding and want each part explained simply."
 ],
 "skip_when": [
  "You are building browser code or a client-side app: this prompt makes a server-only client, so use the Supabase docs for your framework.",
  "You use a framework other than Next.js or Node: follow the Supabase docs for that framework instead.",
  "You have not made the agent_jobs and agent_activity_log tables yet: create them in Supabase first, or the test will fail."
 ],
 "output_sample": {
  "input": [
   "Your code project, open in Claude Code",
   "Your Supabase project URL",
   "Your Supabase service role key, saved in .env.local",
   "Your agent_jobs and agent_activity_log tables"
  ],
  "prerequisites": [
   "Claude Code, or an AI that can create files in your project",
   "A Supabase project with the two tables already made",
   "A Node or Next.js server project"
  ],
  "output": [
   {
    "name": "lib/supabase/admin.ts",
    "contains": "A server-only Supabase client called supabaseAdmin that stops with a clear error if a key is missing."
   },
   {
    "name": "scripts/test-db-connection.ts",
    "contains": "A script that reads up to 5 rows from agent_jobs and counts the rows in agent_activity_log."
   },
   {
    "name": "Plain-English explanation",
    "contains": "Short notes on the service role key, why it stays out of browser code, and the data and error pattern."
   },
   {
    "name": "Test result",
    "contains": "The lines you should see when you run the script, where zero rows is fine on new tables."
   }
  ]
 },
 "how_to_use": [
  "Open your project in Claude Code. This prompt creates files, so it needs an AI that can write to your project.",
  "Install the two packages it needs: npm install @supabase/supabase-js and npm install -D tsx. The prompt asks before it installs them.",
  "Save your Supabase URL and service role key in .env.local. Keep that file out of git, because the service role key skips Row Level Security.",
  "Paste the prompt from the download and let it create the two files.",
  "Run npx tsx scripts/test-db-connection.ts in your terminal.",
  "Check that you see the two lines about agent_jobs and the activity log. Zero rows is fine on new tables.",
  "If you see an error, check the key names in .env.local and that both tables exist."
 ],
 "checks": [],
 "next": [
  {
   "name": "Postgres performance tuner",
   "url": "https://useaiblocks.com/skills/postgres-performance-tuner",
   "why": "Build it"
  }
 ],
 "source": null,
 "credits": [],
 "files": [
  "references/worked-example.md"
 ],
 "links": {
  "page": "https://useaiblocks.com/prompts/connect-code-to-supabase-builder-prompt",
  "markdown": "https://useaiblocks.com/prompts/connect-code-to-supabase-builder-prompt.md",
  "json": "https://useaiblocks.com/prompts/connect-code-to-supabase-builder-prompt.json",
  "instructions": "https://useaiblocks.com/skills/connect-code-to-supabase-builder-prompt/SKILL.md",
  "download": "https://useaiblocks.com/skills/connect-code-to-supabase-builder-prompt.zip",
  "api_item": "https://useaiblocks.com/api/v1/items/connect-code-to-supabase-builder-prompt",
  "api_document": "https://useaiblocks.com/api/v1/documents/prompt/connect-code-to-supabase-builder-prompt",
  "mcp": "https://useaiblocks.com/mcp"
 }
}
