create-baton 1.0.0 → 1.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-baton",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Set up Baton AI orchestration protocol in any project",
5
5
  "bin": {
6
6
  "create-baton": "./bin/create-baton.js"
package/src/constants.js CHANGED
@@ -11,9 +11,9 @@ const IDE_MAP = {
11
11
 
12
12
  // Stack → which skill directories to copy into stacks/
13
13
  const STACK_MAP = {
14
- 'Next.js + Supabase': ['nextjs', 'supabase'],
15
- 'Next.js + other': ['nextjs'],
16
- 'React + Node': [],
14
+ 'Next.js + Supabase': ['nextjs', 'supabase', 'tailwind', 'shadcn', 'typescript', 'vercel'],
15
+ 'Next.js + other': ['nextjs', 'tailwind', 'shadcn', 'typescript', 'vercel'],
16
+ 'React + Node': ['tailwind', 'typescript', 'prisma'],
17
17
  'Python': [],
18
18
  'Other': [],
19
19
  };
@@ -92,23 +92,29 @@ Based on chosen tech stack, read relevant skill files:
92
92
  - Next.js → `skills/stacks/nextjs/SKILL.md`
93
93
  - Supabase → `skills/stacks/supabase/SKILL.md`
94
94
  - Tailwind → `skills/stacks/tailwind/SKILL.md`
95
- - etc.
95
+ - shadcn/ui → `skills/stacks/shadcn/SKILL.md`
96
+ - TypeScript → `skills/stacks/typescript/SKILL.md`
97
+ - Prisma → `skills/stacks/prisma/SKILL.md`
98
+ - Vercel → `skills/stacks/vercel/SKILL.md`
96
99
 
97
100
  ### Step 3: Load Pattern Skills (Based on Features)
98
101
 
99
102
  If project needs specific patterns:
100
103
  - Authentication → `skills/patterns/authentication/SKILL.md`
104
+ - Database design → `skills/patterns/database-design/SKILL.md`
101
105
  - File uploads → `skills/patterns/file-uploads/SKILL.md`
102
- - Background jobs → `skills/patterns/background-jobs/SKILL.md`
103
- - etc.
106
+ - Payments → `skills/patterns/payments/SKILL.md`
107
+ - Email → `skills/patterns/email/SKILL.md`
108
+ - SEO → `skills/patterns/seo/SKILL.md`
109
+ - API integration → `skills/patterns/api-integration/SKILL.md`
104
110
 
105
111
  ### Step 4: Load Domain Skills (If Applicable)
106
112
 
107
113
  If project is in a specialized domain:
108
- - Fintech → `skills/domains/fintech/SKILL.md`
114
+ - SaaS → `skills/domains/saas/SKILL.md`
109
115
  - E-commerce → `skills/domains/ecommerce/SKILL.md`
110
- - Healthcare → `skills/domains/healthcare/SKILL.md`
111
- - etc.
116
+ - Portfolio → `skills/domains/portfolio/SKILL.md`
117
+ - API service → `skills/domains/api/SKILL.md`
112
118
 
113
119
  ### Step 5: Verify Current Documentation
114
120
 
@@ -129,6 +135,25 @@ Tell the user:
129
135
 
130
136
  After research, summarize findings in 3-5 bullet points before proceeding.
131
137
 
138
+ ### Step 7: Condense Skills into Tech Stack
139
+
140
+ After reading all relevant skills (Steps 1-4), extract only the rules, patterns, and gotchas that apply to THIS project. Write them into `.ai-rules/tech-stack.md` during file generation (Phase 3).
141
+
142
+ **What to extract:**
143
+ - Stack-specific patterns the project will actually use
144
+ - Security rules relevant to chosen stack
145
+ - Common pitfalls for this exact combination of tools
146
+ - Key commands and workflows
147
+
148
+ **What to leave out:**
149
+ - Rules for tools/patterns the project doesn't use
150
+ - Generic advice already covered in core skills
151
+ - Setup instructions (only needed once)
152
+
153
+ **After Session 0:** Do NOT re-read `skills/` every session. Read `.ai-rules/tech-stack.md` instead — it contains everything this project needs, condensed. Only go back to `skills/` if you encounter a new problem area not covered by existing context (e.g., project adds payments mid-build → read `skills/patterns/payments/SKILL.md`, then update tech-stack.md).
154
+
155
+ **The skills/ folder stays** as a reference library. Disk is free, tokens aren't.
156
+
132
157
  ---
133
158
 
134
159
  ## Phase 3: Generate Files
@@ -225,8 +250,11 @@ See "IDE Config Templates" section below for exact templates.
225
250
  ```
226
251
 
227
252
  ### .ai-rules/tech-stack.md
253
+
254
+ This file is the **condensed single source of technical truth** for this project. During Session 0, read all relevant skills and distill project-specific rules here. After Session 0, this replaces re-reading skills/.
255
+
228
256
  ```markdown
229
- # Tech Stack Best Practices
257
+ # Tech Stack [Project Name]
230
258
 
231
259
  ## Stack
232
260
  [Chosen stack from Q4]
@@ -235,15 +263,17 @@ See "IDE Config Templates" section below for exact templates.
235
263
  [From research - typical folder structure for this stack]
236
264
 
237
265
  ## Key Patterns
238
- [From research - 5-10 bullet points of best practices]
266
+ [Condensed from skills only rules that apply to THIS project's stack + features]
267
+ [Example: if using Next.js + Supabase + Stripe, include patterns from all three]
239
268
 
240
269
  ## Common Commands
241
270
  [Build, dev, test commands for this stack]
242
271
 
243
272
  ## Pitfalls to Avoid
244
- [From research - 3-5 common mistakes]
273
+ [Condensed from skills mistakes specific to this project's tool combination]
245
274
 
246
- ## Security Hardening (MANDATORY)
275
+ ## Security Rules
276
+ [Condensed from skills/core/security + stack-specific security patterns]
247
277
  - RLS (Row Level Security) on ALL database tables
248
278
  - Zod validation on ALL form inputs and API routes
249
279
  - Environment variables for ALL secrets (never in code)
@@ -256,6 +286,12 @@ See "IDE Config Templates" section below for exact templates.
256
286
  1. Create SQL/migration file with descriptive name
257
287
  2. Ask user to run migration
258
288
  3. Wait for confirmation before building UI that depends on it
289
+
290
+ ## Skills Loaded
291
+ [List which skills were condensed into this file, so future sessions know what's covered]
292
+ - skills/core/security, skills/core/testing, ...
293
+ - skills/stacks/nextjs, skills/stacks/supabase, ...
294
+ - skills/patterns/authentication, ...
259
295
  ```
260
296
 
261
297
  ### .ai-rules/structure.md
@@ -626,12 +662,14 @@ Same content as .cursorrules — Windsurf uses similar format.
626
662
  1. Read context files in order:
627
663
  - `handoff/SESSION_N.md` (current session)
628
664
  - `.ai-rules/project.md`
629
- - `.ai-rules/tech-stack.md`
665
+ - `.ai-rules/tech-stack.md` (condensed skills — this is your technical reference)
630
666
  - `.ai-rules/patterns.md`
631
667
  - `.ai-rules/structure.md`
632
668
  - `PROGRESS.md`
633
669
  - `BACKLOG.md`
634
670
 
671
+ **Do NOT re-read `skills/` every session.** Tech-stack.md already contains what you need. Only go back to skills/ when encountering a new problem area — then update tech-stack.md with what you learn.
672
+
635
673
  2. Run health check (after Session 2):
636
674
  - Run build command
637
675
  - Verify no errors from previous session
@@ -706,10 +744,10 @@ After creating the handoff, ask:
706
744
 
707
745
  When working on any task:
708
746
 
709
- 1. **Check `.ai-rules/patterns.md` FIRST** — Project-specific discoveries
710
- 2. **Check `skills/core/`**Universal security, testing, production rules
711
- 3. **Check `skills/stacks/`**Tech stack patterns
712
- 4. **Check `skills/patterns/`**Implementation patterns
747
+ 1. **Check `.ai-rules/tech-stack.md` FIRST** — Condensed skills for this project
748
+ 2. **Check `.ai-rules/patterns.md`**Project-specific discoveries
749
+ 3. **Check `skills/` ONLY if needed** For new problem areas not yet in tech-stack.md
750
+ 4. **Update tech-stack.md**If you loaded a new skill, condense relevant parts into tech-stack.md
713
751
  5. **Only then web search** — If nothing found above
714
752
  6. **Document new findings** — Add to patterns.md or propose skill update
715
753
 
@@ -0,0 +1,318 @@
1
+ ---
2
+ name: api
3
+ description: >-
4
+ API service patterns — RESTful design, endpoint versioning, authentication,
5
+ rate limiting, documentation, and error handling. Load at Session 0 when
6
+ building a backend API, webhook service, or microservice. Stays loaded
7
+ entire lifecycle.
8
+ ---
9
+
10
+ # API Service Domain Skill
11
+
12
+ > An API is a contract. Breaking it breaks everyone who depends on you.
13
+
14
+ ---
15
+
16
+ ## Load This Skill When
17
+
18
+ - User says they're building an API, backend service, or webhook handler
19
+ - Project serves data to other apps (mobile, frontend, third-party)
20
+ - No user-facing UI — the API IS the product
21
+
22
+ ---
23
+
24
+ ## API Design (Session 0-1)
25
+
26
+ ### URL Structure
27
+
28
+ ```
29
+ GET /api/v1/items — List items
30
+ GET /api/v1/items/:id — Get single item
31
+ POST /api/v1/items — Create item
32
+ PATCH /api/v1/items/:id — Update item
33
+ DELETE /api/v1/items/:id — Delete item
34
+ ```
35
+
36
+ **Rules:**
37
+ - Plural nouns (`/items` not `/item`)
38
+ - No verbs in URLs (`/items` not `/getItems`)
39
+ - Nest for relationships (`/items/:id/comments`)
40
+ - Maximum 2 levels of nesting
41
+ - Version in URL (`/api/v1/`) from day one
42
+
43
+ ### Response Format
44
+
45
+ Always return consistent JSON:
46
+
47
+ ```json
48
+ // Success
49
+ {
50
+ "data": { ... },
51
+ "meta": { "page": 1, "total": 42 }
52
+ }
53
+
54
+ // Error
55
+ {
56
+ "error": {
57
+ "code": "VALIDATION_ERROR",
58
+ "message": "Name is required",
59
+ "details": [
60
+ { "field": "name", "message": "Cannot be empty" }
61
+ ]
62
+ }
63
+ }
64
+ ```
65
+
66
+ **Never return:**
67
+ - Raw database errors
68
+ - Stack traces
69
+ - Inconsistent formats (sometimes array, sometimes object)
70
+
71
+ ### HTTP Status Codes (Use These, Not Others)
72
+
73
+ | Code | When |
74
+ |------|------|
75
+ | 200 | Success (GET, PATCH) |
76
+ | 201 | Created (POST) |
77
+ | 204 | Deleted (DELETE, no body) |
78
+ | 400 | Bad request (validation failed) |
79
+ | 401 | Not authenticated |
80
+ | 403 | Authenticated but not authorized |
81
+ | 404 | Resource not found |
82
+ | 409 | Conflict (duplicate, version mismatch) |
83
+ | 429 | Rate limited |
84
+ | 500 | Server error (your fault) |
85
+
86
+ Don't use obscure status codes. These 10 cover everything.
87
+
88
+ ---
89
+
90
+ ## Authentication (Session 1-2)
91
+
92
+ ### API Key Authentication (Simplest)
93
+
94
+ ```typescript
95
+ // Middleware
96
+ const apiKey = req.headers['x-api-key'];
97
+ if (!apiKey || !isValidApiKey(apiKey)) {
98
+ return Response.json(
99
+ { error: { code: 'UNAUTHORIZED', message: 'Invalid API key' } },
100
+ { status: 401 }
101
+ );
102
+ }
103
+ ```
104
+
105
+ **API key rules:**
106
+ - Prefix keys for identification (`baton_live_...`, `baton_test_...`)
107
+ - Store hashed, not plaintext
108
+ - Support key rotation (multiple active keys per user)
109
+ - Different keys for test vs production
110
+
111
+ ### When to Use What
112
+
113
+ | Method | Use For |
114
+ |--------|---------|
115
+ | API keys | Server-to-server, simple integrations |
116
+ | JWT tokens | User-facing apps, short-lived sessions |
117
+ | OAuth 2.0 | Third-party integrations, "Login with X" |
118
+
119
+ **Default:** API keys for most backend services. Only add OAuth when third parties need access.
120
+
121
+ ---
122
+
123
+ ## Rate Limiting (Session 2-3)
124
+
125
+ ### Implement From Day One
126
+
127
+ ```typescript
128
+ // Simple in-memory rate limiter (replace with Redis for production)
129
+ const rateLimit = {
130
+ windowMs: 60 * 1000, // 1 minute
131
+ maxRequests: 100, // per window
132
+ };
133
+ ```
134
+
135
+ ### Rate Limit Headers
136
+
137
+ Always return these:
138
+ ```
139
+ X-RateLimit-Limit: 100
140
+ X-RateLimit-Remaining: 87
141
+ X-RateLimit-Reset: 1708300800
142
+ ```
143
+
144
+ ### Tiered Limits
145
+
146
+ | Tier | Requests/min | Use Case |
147
+ |------|-------------|----------|
148
+ | Free | 60 | Testing, hobby |
149
+ | Pro | 600 | Production apps |
150
+ | Enterprise | 6000 | High-volume |
151
+
152
+ ---
153
+
154
+ ## Pagination (Session 1-2)
155
+
156
+ ### Cursor-Based (Recommended)
157
+
158
+ ```
159
+ GET /api/v1/items?limit=20&cursor=abc123
160
+ ```
161
+
162
+ Response:
163
+ ```json
164
+ {
165
+ "data": [...],
166
+ "meta": {
167
+ "has_more": true,
168
+ "next_cursor": "def456"
169
+ }
170
+ }
171
+ ```
172
+
173
+ **Why cursor over offset:** Offset pagination breaks when data changes between pages. Cursor doesn't.
174
+
175
+ ### If Offset is Simpler
176
+
177
+ ```
178
+ GET /api/v1/items?page=1&per_page=20
179
+ ```
180
+
181
+ Response includes `total`, `page`, `per_page`, `total_pages`.
182
+
183
+ Fine for admin dashboards. Not for public APIs with frequent writes.
184
+
185
+ ---
186
+
187
+ ## Validation (Session 1-2)
188
+
189
+ ### Validate Everything at the Boundary
190
+
191
+ ```typescript
192
+ import { z } from 'zod';
193
+
194
+ const createItemSchema = z.object({
195
+ name: z.string().min(1).max(255),
196
+ description: z.string().optional(),
197
+ price_cents: z.number().int().positive(),
198
+ });
199
+
200
+ // In route handler
201
+ const parsed = createItemSchema.safeParse(body);
202
+ if (!parsed.success) {
203
+ return Response.json({
204
+ error: {
205
+ code: 'VALIDATION_ERROR',
206
+ message: 'Invalid input',
207
+ details: parsed.error.issues,
208
+ }
209
+ }, { status: 400 });
210
+ }
211
+ ```
212
+
213
+ ---
214
+
215
+ ## Versioning (Session 0)
216
+
217
+ ### URL Versioning (Default)
218
+
219
+ ```
220
+ /api/v1/items
221
+ /api/v2/items
222
+ ```
223
+
224
+ **Rules:**
225
+ - Start at v1, not v0
226
+ - Only bump version for breaking changes
227
+ - Keep old version running for at least 6 months
228
+ - Announce deprecation in response headers
229
+
230
+ ```
231
+ Deprecation: true
232
+ Sunset: Sat, 01 Jan 2027 00:00:00 GMT
233
+ Link: <https://docs.example.com/migration>; rel="deprecation"
234
+ ```
235
+
236
+ ---
237
+
238
+ ## Documentation (Session 4+)
239
+
240
+ ### Minimum Viable Docs
241
+
242
+ Every endpoint needs:
243
+ - URL and method
244
+ - Request body (with example)
245
+ - Response body (with example)
246
+ - Error responses
247
+ - Authentication required (yes/no)
248
+
249
+ ### OpenAPI/Swagger
250
+
251
+ Generate from code if possible. Don't maintain a separate spec file.
252
+
253
+ ```typescript
254
+ // If using Next.js API routes, consider next-swagger-doc
255
+ // If standalone, use tsoa or express-openapi-validator
256
+ ```
257
+
258
+ ### README Quick Start
259
+
260
+ ```markdown
261
+ ## Quick Start
262
+
263
+ 1. Get an API key at https://example.com/dashboard
264
+ 2. Make your first request:
265
+
266
+ curl -X GET https://api.example.com/v1/items \
267
+ -H "X-API-Key: your_key_here"
268
+ ```
269
+
270
+ Every API needs a "get started in 30 seconds" section.
271
+
272
+ ---
273
+
274
+ ## Webhooks (If Your API Sends Events)
275
+
276
+ ### Webhook Design
277
+
278
+ ```json
279
+ {
280
+ "id": "evt_abc123",
281
+ "type": "item.created",
282
+ "created_at": "2026-02-14T10:00:00Z",
283
+ "data": { ... }
284
+ }
285
+ ```
286
+
287
+ **Rules:**
288
+ - Sign every webhook (HMAC-SHA256)
289
+ - Include event type and timestamp
290
+ - Retry on failure (3 attempts, exponential backoff)
291
+ - Let users configure webhook URLs
292
+ - Log all deliveries (success and failure)
293
+
294
+ ---
295
+
296
+ ## Session Checkpoints
297
+
298
+ ### Session 2: Foundation Check
299
+ - [ ] Core CRUD endpoints work
300
+ - [ ] Authentication enforced
301
+ - [ ] Consistent error format
302
+ - [ ] Validation on all inputs
303
+
304
+ ### Session 4: Production Check
305
+ - [ ] Rate limiting active
306
+ - [ ] Pagination on list endpoints
307
+ - [ ] API documentation exists
308
+ - [ ] Error responses don't leak internals
309
+
310
+ ### Session 7: Launch Check
311
+ - [ ] All endpoints documented with examples
312
+ - [ ] Rate limits tested under load
313
+ - [ ] API keys can be rotated
314
+ - [ ] Monitoring/logging on all routes
315
+
316
+ ---
317
+
318
+ *Last updated: Baton Protocol v3.1*