kw-login-supabase-cli
Login Supabase CLI
Authenticate with Supabase CLI and link a project. Execute ALL steps automatically. Only pause when user input is truly needed.
RULES:
- NEVER write tokens, secrets, or private keys to
.envor any file. - NEVER add
.envto.gitignore. The.envonly contains public/publishable keys and should be committed. - NEVER read
.env— it's not needed for CLI setup. - CLI auth is always via
npx supabase loginin the user's terminal. Never use--token-stdinor paste tokens.
Workflow — Execute all steps sequentially
Step 1: Authenticate
Run npx supabase projects list to test auth.
If it works: Show the project list and ask: "Is this the correct Supabase account for this project?" Options:
- "Yes" → continue to Step 2
- "No, different account" → tell user to run
npx supabase loginin their terminal, wait for confirmation, then re-verify
If it fails: Tell the user to run npx supabase login in their terminal. Wait for confirmation, then re-verify with npx supabase projects list.
Step 2: Initialize project
Check if supabase/config.toml exists. If NOT, run npx supabase init to create the supabase/ directory structure. Then continue.
Step 3: Check if already linked
Check supabase/.temp/project-ref exists AND supabase/config.toml has project_id. If BOTH exist → skip to Step 5. Otherwise continue to Step 4.
Step 4: Link project
Check project_id in supabase/config.toml. If found, confirm: "Detected project ref <ref>. Link this project?" Options:
- "Yes, link it" → proceed
- "No, use another" → ask for the correct ref
If no ref found, ask the user: "Your project ref is in the Supabase dashboard: Project Settings > General. It's a 20-character ID."
Then run: npx supabase link --project-ref <ref>
If the command warns about major_version, fix supabase/config.toml immediately — add or update [db] section with the version from the warning.
Step 5: Verify .gitignore
Check if supabase/.temp/ is in .gitignore. Add it ONLY if missing. Do NOT add .env, .env.local, or .env.*.local.
Step 6: Confirm
Run npx supabase projects list to verify. Show a summary table:
| Step | Status |
|---|---|
| Login with correct account | OK/FAIL |
Project linked (<ref> — <name>) |
OK/FAIL |
.gitignore (supabase/.temp/) |
OK/Already existed |
Troubleshooting
- Login hangs: Firewall or proxy may block the browser callback. Try from a different terminal.
- "project not found": Verify ref is 20 chars and the account has access.
- Switch account:
npx supabase loginagain — overwrites the global token.
More from kwazema/claude-skills
kw-gsd-fortify
>
10kw-cubic
>
9kw-stack-audit
>
9kw-code-cleanup
Add a code quality cleanup phase to the current GSD milestone. Use when the user says "code cleanup", "cleanup phase", "limpieza de codigo", "add cleanup phase", or wants to add lint/refactoring/quality checks as a milestone phase.
9kw-update-skills
>
9kw-vite-checker-setup
>
9