@agentlink.sh/cli 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,345 @@
1
+ # agentlink
2
+
3
+ Teach AI agents the right way to build on Supabase.
4
+
5
+ [Agent Link](https://agentlink.sh) is an opinionated skill set for Claude Code — and this CLI is how you start a project with it. One command scaffolds a Supabase backend with schema isolation, RPC-first data access, row-level security, multi-tenancy, and edge functions already wired up — plus a frontend (React + Vite or Next.js) with auth, theming, and shadcn/ui ready to go. Your agent doesn't have to figure out the architecture — it's already there. From that foundation, five domain skills give it one clear path for every decision: how to structure tables, write RLS policies, expose APIs, handle background work, and connect a frontend. No ambiguity, no wrong turns. First-try results.
6
+
7
+ ## Install
8
+
9
+ ### macOS
10
+
11
+ ```bash
12
+ curl -fsSL https://agentlink.sh/install | sh
13
+ ```
14
+
15
+ ### Linux
16
+
17
+ ```bash
18
+ wget -qO- https://agentlink.sh/install | sh
19
+ ```
20
+
21
+ ### Windows (PowerShell)
22
+
23
+ ```powershell
24
+ irm https://agentlink.sh/install.ps1 | iex
25
+ ```
26
+
27
+ ### npm
28
+
29
+ ```bash
30
+ npm install -g @agentlinksh/cli
31
+ ```
32
+
33
+ Or run directly with npx (requires Node.js 18+):
34
+
35
+ ```bash
36
+ npx @agentlinksh/cli@latest
37
+ ```
38
+
39
+ The install scripts automatically detect your OS, install Node.js if needed, and set up the CLI globally.
40
+
41
+ ## Quick start
42
+
43
+ ```bash
44
+ # Create a new project (cloud by default, zero questions with name + prompt)
45
+ agentlink my-app "Build a project management tool with kanban boards"
46
+
47
+ # Interactive wizard (asks project name and frontend choice)
48
+ agentlink
49
+ ```
50
+
51
+ ## Commands
52
+
53
+ ### `agentlink [name] [prompt]`
54
+
55
+ Interactive wizard that scaffolds a new project or updates an existing one. Uses Supabase Cloud by default — region is auto-detected from your timezone, all recommended skills are installed automatically.
56
+
57
+ ```bash
58
+ # Interactive wizard
59
+ agentlink
60
+
61
+ # With project name
62
+ agentlink my-app
63
+
64
+ # With name and prompt (zero questions — express mode)
65
+ agentlink my-app "Build a project management tool with kanban boards"
66
+
67
+ # Local Docker mode (instead of cloud)
68
+ agentlink my-app --local
69
+
70
+ # NextJS instead of React + Vite
71
+ agentlink my-app --nextjs
72
+
73
+ # Backend only (no frontend)
74
+ agentlink my-app --no-frontend
75
+
76
+ # Skip companion skills
77
+ agentlink my-app --no-skills
78
+
79
+ # Non-interactive (CI-friendly)
80
+ agentlink my-app --yes --non-interactive --token $SUPABASE_TOKEN --org $ORG_ID --region us-east-1
81
+ ```
82
+
83
+ **Options:**
84
+
85
+ | Flag | Description |
86
+ | ------------------- | ------------------------------------------------ |
87
+ | `--debug` | Write debug log to `agentlink-debug.log` |
88
+ | `--force-update` | Force update even if project is up to date |
89
+ | `--no-frontend` | Skip frontend scaffolding (backend only) |
90
+ | `--nextjs` | Use NextJS instead of React + Vite |
91
+ | `--local` | Use local Docker instead of Supabase Cloud |
92
+ | `--no-skills` | Skip companion skill installation |
93
+ | `--no-launch` | Skip launching Claude Code after scaffold |
94
+ | `-y, --yes` | Auto-confirm all prompts |
95
+ | `--token <token>` | Supabase access token (skips interactive login) |
96
+ | `--org <id>` | Supabase organization ID |
97
+ | `--region <region>` | Supabase Cloud region (auto-detected if omitted) |
98
+ | `--prompt <prompt>` | Alternative to positional prompt argument |
99
+ | `--resume` | Resume a previously failed scaffold |
100
+ | `--non-interactive` | Error instead of prompting when info is missing |
101
+
102
+ ### `agentlink login`
103
+
104
+ Authenticate with Supabase via OAuth (opens browser). Tokens are cached and auto-refreshed.
105
+
106
+ ```bash
107
+ agentlink login
108
+ ```
109
+
110
+ ### `agentlink deploy`
111
+
112
+ Deploy schema changes, edge functions, and secrets from dev to a target environment.
113
+
114
+ ```bash
115
+ agentlink deploy # Deploy to prod (default)
116
+ agentlink deploy --dry-run # Preview without applying
117
+ agentlink deploy --ci # Non-interactive for CI/CD
118
+ agentlink deploy --env staging
119
+ ```
120
+
121
+ ### `agentlink env`
122
+
123
+ Manage project environments.
124
+
125
+ ```bash
126
+ agentlink env add prod # Connect a production cloud project
127
+ agentlink env use local # Switch to local Docker for dev
128
+ agentlink env list # Show all environments
129
+ agentlink env remove staging # Remove an environment config
130
+ ```
131
+
132
+ ### `agentlink check`
133
+
134
+ Verify project setup. Outputs JSON with diagnostic info: `setup_hash_match`, `supabase_running`, database state (extensions, queues, functions, secrets, api_schema), and file checks.
135
+
136
+ ```bash
137
+ agentlink check
138
+ ```
139
+
140
+ ### `agentlink info [name]`
141
+
142
+ Show documentation about scaffolded components. Without a name, lists all components. With a name, shows type, summary, description, signature, and related components.
143
+
144
+ ```bash
145
+ agentlink info # List all components
146
+ agentlink info tenant_select # Detail for one component
147
+ ```
148
+
149
+ ### `agentlink db apply`
150
+
151
+ Apply all schema files in `supabase/schemas/` to the database using pg-delta declarative apply.
152
+
153
+ ```bash
154
+ agentlink db apply
155
+ agentlink db apply --db-url postgresql://... # Custom DB URL
156
+ ```
157
+
158
+ ### `agentlink db migrate <name>`
159
+
160
+ Generate a migration from the diff between the current database state and the schema files.
161
+
162
+ ```bash
163
+ agentlink db migrate add_charts_table
164
+ agentlink db migrate add_charts_table --db-url postgresql://...
165
+ ```
166
+
167
+ ### `agentlink template <name>`
168
+
169
+ Scaffold only the frontend template (no Supabase setup).
170
+
171
+ ```bash
172
+ agentlink template my-app # React + Vite
173
+ agentlink template my-app --nextjs # NextJS
174
+ ```
175
+
176
+ ## What it does
177
+
178
+ The scaffold runs a multi-step process:
179
+
180
+ 1. **Prerequisites** — Checks for Supabase CLI, pg-delta, and psql
181
+ 2. **Configure files** — Writes template files, `config.toml`, and `.env.local`
182
+ 3. **Start Supabase** — Starts locally (Docker) or creates a Cloud project
183
+ 4. **Read config** — Reads Supabase API keys and connection info
184
+ 5. **Write env** — Updates `.env.local` with API keys and DB URL
185
+ 6. **Setup database** — Applies SQL schemas, writes migrations, configures auth
186
+ 7. **Verify setup** — Runs verification queries to confirm all components
187
+ 8. **Setup frontend** — Writes React + Vite or NextJS files (if selected)
188
+ 9. **Install frontend deps** — Runs `npm install` for the frontend
189
+ 10. **Configure Claude Code** — Sets up `CLAUDE.md` and Claude settings
190
+ 11. **Install MCP** — Installs Supabase MCP server (local mode only)
191
+ 12. **Install plugin** — Installs Agent Link plugin and companion skills
192
+ 13. **Finalize** — Creates git repo, writes `agentlink.json` manifest
193
+
194
+ Running `agentlink` inside an existing project (with `agentlink.json`) triggers the **update** flow instead, which patches template files, updates the plugin, applies schema changes, and regenerates migrations.
195
+
196
+ ## Modes
197
+
198
+ ### Cloud mode (default)
199
+
200
+ Creates a Supabase Cloud project. No local Docker or psql required. Uses the Management API for database operations, auth config, PostgREST config, and edge function deployment. Authenticates via OAuth (browser), token flag (`--token`), or cached credentials (`~/.config/agentlink/credentials.json`). Region is auto-detected from your timezone.
201
+
202
+ ### Local mode (`--local`)
203
+
204
+ Runs Supabase in Docker via `supabase start`. Requires Docker and psql. Applies schemas via psql. Installs the Supabase MCP server for Claude Code.
205
+
206
+ ## Frontend options
207
+
208
+ | Option | Frontend | Key features |
209
+ | ------------------------------ | ------------------ | ------------------------------------------------- |
210
+ | React + Vite (default) | Vite + React | Auth UI, theme switcher, shadcn/ui components |
211
+ | NextJS (`--nextjs`) | Next.js App Router | SSR, server/client Supabase modules, same auth UI |
212
+ | Backend only (`--no-frontend`) | None | Minimal package.json with dev dependencies only |
213
+
214
+ ## Companion skills
215
+
216
+ The CLI installs all recommended companion skills for Claude Code automatically. Use `--no-skills` to skip.
217
+
218
+ **Base skills (all frontends):**
219
+
220
+ - `supabase/agent-skills@supabase-postgres-best-practices` (required)
221
+ - `anthropics/skills@frontend-design`
222
+ - `shadcn/ui`
223
+ - `vercel-labs/agent-skills@vercel-react-best-practices`
224
+ - `resend/react-email`
225
+ - `resend/email-best-practices`
226
+ - `resend/resend-skills`
227
+
228
+ **Additional for NextJS:**
229
+
230
+ - `vercel-labs/next-skills --skill next-best-practices`
231
+
232
+ ## Scaffolded project structure
233
+
234
+ ```
235
+ my-app/
236
+ ├── agentlink.json # Project manifest
237
+ ├── CLAUDE.md # AI agent instructions
238
+ ├── .env.local # Environment variables
239
+ ├── .env.example
240
+ ├── .claude/
241
+ │ └── settings.local.json # Claude Code permissions
242
+ ├── supabase/
243
+ │ ├── config.toml
244
+ │ ├── schemas/
245
+ │ │ ├── _schemas.sql # Schema + role grants
246
+ │ │ ├── _extensions.sql # Extension declarations
247
+ │ │ ├── public/
248
+ │ │ │ ├── profiles.sql # User profiles table
249
+ │ │ │ ├── multitenancy.sql # Tenants, memberships, invitations
250
+ │ │ │ ├── _auth_tenant.sql # Tenant auth helpers (RLS)
251
+ │ │ │ ├── _internal_admin.sql # Vault, edge function calls, set_updated_at
252
+ │ │ │ └── _hooks.sql # Auth hooks
253
+ │ │ └── api/
254
+ │ │ ├── profile.sql # Profile RPCs
255
+ │ │ └── tenant.sql # Tenant/invitation/membership RPCs
256
+ │ ├── migrations/ # Generated (never hand-written)
257
+ │ └── functions/
258
+ │ ├── _shared/
259
+ │ │ ├── withSupabase.ts # Auth wrapper for edge functions
260
+ │ │ ├── responses.ts # Response helpers
261
+ │ │ └── types.ts # Type definitions
262
+ │ ├── queue-worker/ # PGMQ message queue handler
263
+ │ └── send-email/ # Email sending + templates
264
+ ├── src/ # Frontend source (Vite or NextJS)
265
+ └── package.json
266
+ ```
267
+
268
+ ## Template architecture
269
+
270
+ Scaffolded projects get their files from `src/template/supabase/`, which mirrors
271
+ the target directory structure. SQL files are loaded as text by esbuild's built-in
272
+ text loader. Edge function `.ts` and `.tsx` files are loaded as text by custom esbuild
273
+ plugins (see `tsup.config.ts`).
274
+
275
+ All template files are imported and registered in `src/templates.ts`:
276
+
277
+ - `TEMPLATE_FILES` — map of relative path to content, used by `writeTemplateFiles()`
278
+ - `EXEC_SQL` — subset of SQL that gets executed against the database during setup
279
+ - `computeSetupHash()` — integrity hash for the agentlink manifest
280
+
281
+ Files that depend on runtime values (`config.toml`, `.env`, seed SQL) are generated
282
+ dynamically in `src/supabase.ts` and are not part of the template directory.
283
+
284
+ ### Adding a new scaffolded file
285
+
286
+ 1. Create the file at its target path under `src/template/supabase/`
287
+ (e.g., `src/template/supabase/functions/my-function/index.ts`)
288
+ 2. If it's a `.ts` file, add a type declaration in `src/template.d.ts`:
289
+ ```typescript
290
+ declare module "./template/supabase/functions/my-function/index.ts" {
291
+ const content: string;
292
+ export default content;
293
+ }
294
+ ```
295
+ 3. In `src/templates.ts`, add the import and register it in `TEMPLATE_FILES`:
296
+ ```typescript
297
+ import myFunction from "./template/supabase/functions/my-function/index.ts";
298
+ // ...
299
+ "functions/my-function/index.ts": myFunction,
300
+ ```
301
+ 4. If the file is SQL that needs to be executed against the database during setup,
302
+ also add it to the `EXEC_SQL` object and call it from `scaffold.ts`.
303
+
304
+ ## Development
305
+
306
+ ```bash
307
+ cd cli
308
+ npm install
309
+ npm run build # tsup -> dist/index.js (ESM, Node 18+)
310
+ npm run dev # tsup --watch
311
+ npm run lint # ESLint
312
+ node dist/index.js # Run locally
313
+ ```
314
+
315
+ ### Source files
316
+
317
+ | File | Purpose |
318
+ | --------------------------- | --------------------------------------------------------- |
319
+ | `src/index.ts` | Commander entry point, command definitions |
320
+ | `src/wizard.ts` | Interactive setup flow |
321
+ | `src/scaffold.ts` | Multi-step scaffolding with spinner UI |
322
+ | `src/update.ts` | Project update mechanism |
323
+ | `src/db.ts` | Database schema operations (apply, migrate) |
324
+ | `src/check.ts` | Setup verification |
325
+ | `src/info.ts` | Component documentation lookup |
326
+ | `src/cloud.ts` | Cloud mode (tokens, orgs, regions, Management API, OAuth) |
327
+ | `src/oauth.ts` | Supabase OAuth PKCE flow and token refresh |
328
+ | `src/deploy.ts` | Deploy command (diff, validate, push) |
329
+ | `src/env.ts` | Environment management (add, use, list, remove) |
330
+ | `src/migration-analysis.ts` | Static analysis of migration SQL for data risks |
331
+ | `src/manifest.ts` | `agentlink.json` I/O and environment resolution |
332
+ | `src/supabase.ts` | Supabase CLI operations, migration management |
333
+ | `src/templates.ts` | Template file registry and hash computation |
334
+ | `src/vite-templates.ts` | React + Vite template files |
335
+ | `src/nextjs-templates.ts` | NextJS template files |
336
+ | `src/claude-md.ts` | CLAUDE.md generation |
337
+ | `src/claude-settings.ts` | Claude Code settings |
338
+ | `src/sql.ts` | SQL generation (seeds, checks) |
339
+ | `src/utils.ts` | Shell commands, logging, validation |
340
+ | `src/theme.ts` | Terminal colors (Sheikah blue, amber, red) |
341
+ | `src/progress.ts` | Resume state management |
342
+ | `src/ui.ts` | Spinner and progress display |
343
+ | `src/banner.ts` | CLI banner |
344
+ | `src/constants.ts` | Pinned versions, Supabase/pgdelta CLI paths |
345
+ | `src/template.d.ts` | TypeScript declarations for embedded templates |