@girardmedia/bootspring 1.2.0 → 2.0.3

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.
Files changed (253) hide show
  1. package/README.md +107 -14
  2. package/bin/bootspring.js +166 -27
  3. package/cli/agent.js +189 -17
  4. package/cli/analyze.js +499 -0
  5. package/cli/audit.js +557 -0
  6. package/cli/auth.js +495 -38
  7. package/cli/billing.js +302 -0
  8. package/cli/build.js +695 -0
  9. package/cli/business.js +109 -26
  10. package/cli/checkpoint-utils.js +168 -0
  11. package/cli/checkpoint.js +639 -0
  12. package/cli/cloud-sync.js +447 -0
  13. package/cli/content.js +198 -0
  14. package/cli/context.js +1 -1
  15. package/cli/deploy.js +543 -0
  16. package/cli/fundraise.js +112 -50
  17. package/cli/github-cmd.js +435 -0
  18. package/cli/health.js +477 -0
  19. package/cli/init.js +84 -13
  20. package/cli/legal.js +107 -95
  21. package/cli/log.js +2 -2
  22. package/cli/loop.js +976 -73
  23. package/cli/manager.js +711 -0
  24. package/cli/metrics.js +480 -0
  25. package/cli/monitor.js +812 -0
  26. package/cli/onboard.js +521 -0
  27. package/cli/orchestrator.js +12 -24
  28. package/cli/prd.js +594 -0
  29. package/cli/preseed-start.js +1483 -0
  30. package/cli/preseed.js +2302 -0
  31. package/cli/project.js +436 -0
  32. package/cli/quality.js +233 -0
  33. package/cli/security.js +913 -0
  34. package/cli/seed.js +1441 -5
  35. package/cli/skill.js +273 -211
  36. package/cli/suggest.js +989 -0
  37. package/cli/switch.js +453 -0
  38. package/cli/visualize.js +527 -0
  39. package/cli/watch.js +769 -0
  40. package/cli/workspace.js +607 -0
  41. package/core/analyze-workflow.js +1134 -0
  42. package/core/api-client.js +535 -22
  43. package/core/audit-workflow.js +1350 -0
  44. package/core/build-orchestrator.js +480 -0
  45. package/core/build-state.js +577 -0
  46. package/core/checkpoint-engine.js +408 -0
  47. package/core/config.js +1109 -26
  48. package/core/context-loader.js +21 -1
  49. package/core/deploy-workflow.js +836 -0
  50. package/core/entitlements.js +93 -22
  51. package/core/github-sync.js +610 -0
  52. package/core/index.js +8 -1
  53. package/core/ingest.js +1111 -0
  54. package/core/metrics-engine.js +768 -0
  55. package/core/onboard-workflow.js +1007 -0
  56. package/core/preseed-workflow.js +934 -0
  57. package/core/preseed.js +1617 -0
  58. package/core/project-context.js +325 -0
  59. package/core/project-state.js +694 -0
  60. package/core/r2-sync.js +583 -0
  61. package/core/scaffold.js +525 -7
  62. package/core/session.js +258 -0
  63. package/core/task-extractor.js +758 -0
  64. package/core/telemetry.js +28 -6
  65. package/core/tier-enforcement.js +737 -0
  66. package/core/utils.js +38 -14
  67. package/generators/questionnaire.js +15 -12
  68. package/generators/sections/ai.js +7 -7
  69. package/generators/sections/content.js +300 -0
  70. package/generators/sections/index.js +3 -0
  71. package/generators/sections/plugins.js +7 -6
  72. package/generators/templates/build-planning.template.js +596 -0
  73. package/generators/templates/content.template.js +819 -0
  74. package/generators/templates/index.js +2 -1
  75. package/hooks/git-autopilot.js +1250 -0
  76. package/hooks/index.js +9 -0
  77. package/intelligence/agent-collab.js +2057 -0
  78. package/intelligence/auto-suggest.js +634 -0
  79. package/intelligence/content-gen.js +1589 -0
  80. package/intelligence/cross-project.js +1647 -0
  81. package/intelligence/index.js +184 -0
  82. package/intelligence/learning/insights.json +517 -7
  83. package/intelligence/learning/pattern-learner.js +1008 -14
  84. package/intelligence/memory/decision-tracker.js +1431 -31
  85. package/intelligence/memory/decisions.jsonl +0 -0
  86. package/intelligence/orchestrator.js +2896 -1
  87. package/intelligence/prd.js +92 -1
  88. package/intelligence/recommendation-weights.json +14 -2
  89. package/intelligence/recommendations.js +463 -9
  90. package/intelligence/workflow-composer.js +1451 -0
  91. package/marketplace/index.d.ts +324 -0
  92. package/marketplace/index.js +1921 -0
  93. package/mcp/contracts/mcp-contract.v1.json +342 -4
  94. package/mcp/registry.js +680 -3
  95. package/mcp/response-formatter.js +23 -0
  96. package/mcp/tools/assist-tool.js +78 -4
  97. package/mcp/tools/autopilot-tool.js +408 -0
  98. package/mcp/tools/content-tool.js +571 -0
  99. package/mcp/tools/dashboard-tool.js +251 -5
  100. package/mcp/tools/mvp-tool.js +344 -0
  101. package/mcp/tools/plugin-tool.js +23 -1
  102. package/mcp/tools/prd-tool.js +579 -0
  103. package/mcp/tools/seed-tool.js +447 -0
  104. package/mcp/tools/skill-tool.js +43 -14
  105. package/mcp/tools/suggest-tool.js +147 -0
  106. package/package.json +15 -6
  107. package/agents/README.md +0 -93
  108. package/agents/ai-integration-expert/context.md +0 -386
  109. package/agents/api-expert/context.md +0 -416
  110. package/agents/architecture-expert/context.md +0 -454
  111. package/agents/auth-expert/context.md +0 -399
  112. package/agents/backend-expert/context.md +0 -483
  113. package/agents/business-strategy-expert/context.md +0 -180
  114. package/agents/code-review-expert/context.md +0 -365
  115. package/agents/competitive-analysis-expert/context.md +0 -239
  116. package/agents/data-modeling-expert/context.md +0 -352
  117. package/agents/database-expert/context.md +0 -250
  118. package/agents/devops-expert/context.md +0 -446
  119. package/agents/email-expert/context.md +0 -379
  120. package/agents/financial-expert/context.md +0 -213
  121. package/agents/frontend-expert/context.md +0 -364
  122. package/agents/fundraising-expert/context.md +0 -257
  123. package/agents/growth-expert/context.md +0 -249
  124. package/agents/index.js +0 -140
  125. package/agents/investor-relations-expert/context.md +0 -266
  126. package/agents/legal-expert/context.md +0 -284
  127. package/agents/marketing-expert/context.md +0 -236
  128. package/agents/monitoring-expert/context.md +0 -362
  129. package/agents/operations-expert/context.md +0 -279
  130. package/agents/partnerships-expert/context.md +0 -286
  131. package/agents/payment-expert/context.md +0 -340
  132. package/agents/performance-expert/context.md +0 -377
  133. package/agents/private-equity-expert/context.md +0 -246
  134. package/agents/railway-expert/context.md +0 -284
  135. package/agents/research-expert/context.md +0 -245
  136. package/agents/sales-expert/context.md +0 -241
  137. package/agents/security-expert/context.md +0 -343
  138. package/agents/testing-expert/context.md +0 -414
  139. package/agents/ui-ux-expert/context.md +0 -448
  140. package/agents/vercel-expert/context.md +0 -426
  141. package/skills/index.js +0 -787
  142. package/skills/patterns/README.md +0 -163
  143. package/skills/patterns/ai/agents.md +0 -281
  144. package/skills/patterns/ai/claude.md +0 -138
  145. package/skills/patterns/ai/embeddings.md +0 -150
  146. package/skills/patterns/ai/rag.md +0 -266
  147. package/skills/patterns/ai/streaming.md +0 -170
  148. package/skills/patterns/ai/structured-output.md +0 -162
  149. package/skills/patterns/ai/tools.md +0 -154
  150. package/skills/patterns/analytics/tracking.md +0 -220
  151. package/skills/patterns/api/errors.md +0 -296
  152. package/skills/patterns/api/graphql.md +0 -440
  153. package/skills/patterns/api/middleware.md +0 -279
  154. package/skills/patterns/api/openapi.md +0 -285
  155. package/skills/patterns/api/rate-limiting.md +0 -231
  156. package/skills/patterns/api/route-handler.md +0 -217
  157. package/skills/patterns/api/server-action.md +0 -249
  158. package/skills/patterns/api/versioning.md +0 -443
  159. package/skills/patterns/api/webhooks.md +0 -247
  160. package/skills/patterns/auth/clerk.md +0 -132
  161. package/skills/patterns/auth/mfa.md +0 -313
  162. package/skills/patterns/auth/nextauth.md +0 -140
  163. package/skills/patterns/auth/oauth.md +0 -237
  164. package/skills/patterns/auth/rbac.md +0 -152
  165. package/skills/patterns/auth/session-management.md +0 -367
  166. package/skills/patterns/auth/session.md +0 -120
  167. package/skills/patterns/database/audit.md +0 -177
  168. package/skills/patterns/database/migrations.md +0 -177
  169. package/skills/patterns/database/pagination.md +0 -230
  170. package/skills/patterns/database/pooling.md +0 -357
  171. package/skills/patterns/database/prisma.md +0 -180
  172. package/skills/patterns/database/relations.md +0 -187
  173. package/skills/patterns/database/seeding.md +0 -246
  174. package/skills/patterns/database/soft-delete.md +0 -153
  175. package/skills/patterns/database/transactions.md +0 -162
  176. package/skills/patterns/deployment/ci-cd.md +0 -231
  177. package/skills/patterns/deployment/docker.md +0 -188
  178. package/skills/patterns/deployment/monitoring.md +0 -387
  179. package/skills/patterns/deployment/vercel.md +0 -160
  180. package/skills/patterns/email/resend.md +0 -143
  181. package/skills/patterns/email/templates.md +0 -245
  182. package/skills/patterns/email/transactional.md +0 -503
  183. package/skills/patterns/email/verification.md +0 -176
  184. package/skills/patterns/files/download.md +0 -243
  185. package/skills/patterns/files/upload.md +0 -239
  186. package/skills/patterns/i18n/nextintl.md +0 -188
  187. package/skills/patterns/logging/structured.md +0 -292
  188. package/skills/patterns/notifications/email-queue.md +0 -248
  189. package/skills/patterns/notifications/push.md +0 -279
  190. package/skills/patterns/payments/checkout.md +0 -303
  191. package/skills/patterns/payments/invoices.md +0 -287
  192. package/skills/patterns/payments/portal.md +0 -245
  193. package/skills/patterns/payments/stripe.md +0 -272
  194. package/skills/patterns/payments/subscriptions.md +0 -300
  195. package/skills/patterns/payments/usage.md +0 -279
  196. package/skills/patterns/performance/caching.md +0 -276
  197. package/skills/patterns/performance/code-splitting.md +0 -233
  198. package/skills/patterns/performance/edge.md +0 -254
  199. package/skills/patterns/performance/isr.md +0 -266
  200. package/skills/patterns/performance/lazy-loading.md +0 -281
  201. package/skills/patterns/realtime/sse.md +0 -327
  202. package/skills/patterns/realtime/websockets.md +0 -336
  203. package/skills/patterns/search/filtering.md +0 -329
  204. package/skills/patterns/search/fulltext.md +0 -260
  205. package/skills/patterns/security/audit-logging.md +0 -444
  206. package/skills/patterns/security/csrf.md +0 -234
  207. package/skills/patterns/security/headers.md +0 -252
  208. package/skills/patterns/security/sanitization.md +0 -258
  209. package/skills/patterns/security/secrets.md +0 -261
  210. package/skills/patterns/security/validation.md +0 -268
  211. package/skills/patterns/security/xss.md +0 -229
  212. package/skills/patterns/seo/metadata.md +0 -252
  213. package/skills/patterns/state/context.md +0 -349
  214. package/skills/patterns/state/react-query.md +0 -313
  215. package/skills/patterns/state/url-state.md +0 -482
  216. package/skills/patterns/state/zustand.md +0 -262
  217. package/skills/patterns/testing/api.md +0 -259
  218. package/skills/patterns/testing/component.md +0 -233
  219. package/skills/patterns/testing/coverage.md +0 -207
  220. package/skills/patterns/testing/fixtures.md +0 -225
  221. package/skills/patterns/testing/integration.md +0 -436
  222. package/skills/patterns/testing/mocking.md +0 -177
  223. package/skills/patterns/testing/playwright.md +0 -162
  224. package/skills/patterns/testing/snapshot.md +0 -175
  225. package/skills/patterns/testing/vitest.md +0 -307
  226. package/skills/patterns/ui/accordions.md +0 -395
  227. package/skills/patterns/ui/cards.md +0 -299
  228. package/skills/patterns/ui/dropdowns.md +0 -476
  229. package/skills/patterns/ui/empty-states.md +0 -320
  230. package/skills/patterns/ui/forms.md +0 -405
  231. package/skills/patterns/ui/inputs.md +0 -319
  232. package/skills/patterns/ui/layouts.md +0 -282
  233. package/skills/patterns/ui/loading.md +0 -291
  234. package/skills/patterns/ui/modals.md +0 -338
  235. package/skills/patterns/ui/navigation.md +0 -374
  236. package/skills/patterns/ui/tables.md +0 -407
  237. package/skills/patterns/ui/toasts.md +0 -300
  238. package/skills/patterns/ui/tooltips.md +0 -396
  239. package/skills/patterns/utils/dates.md +0 -435
  240. package/skills/patterns/utils/errors.md +0 -451
  241. package/skills/patterns/utils/formatting.md +0 -345
  242. package/skills/patterns/utils/validation.md +0 -434
  243. package/templates/bootspring.config.js +0 -83
  244. package/templates/business/business-model-canvas.md +0 -246
  245. package/templates/business/business-plan.md +0 -266
  246. package/templates/business/competitive-analysis.md +0 -312
  247. package/templates/fundraising/data-room-checklist.md +0 -300
  248. package/templates/fundraising/investor-research.md +0 -243
  249. package/templates/fundraising/pitch-deck-outline.md +0 -253
  250. package/templates/legal/gdpr-checklist.md +0 -339
  251. package/templates/legal/privacy-policy.md +0 -285
  252. package/templates/legal/terms-of-service.md +0 -222
  253. package/templates/mcp.json +0 -9
@@ -1,483 +0,0 @@
1
- # Backend Expert Agent
2
-
3
- ## Role
4
- Specialized in server-side logic, API design, Server Actions, business logic implementation, and backend architecture for Next.js applications.
5
-
6
- ## Core Expertise
7
-
8
- ### Server Actions
9
-
10
- ```typescript
11
- // app/actions/user-actions.ts
12
- 'use server';
13
-
14
- import { auth } from '@clerk/nextjs/server';
15
- import { prisma } from '@/lib/prisma';
16
- import { revalidatePath } from 'next/cache';
17
- import { z } from 'zod';
18
-
19
- // Schema for input validation
20
- const UpdateProfileSchema = z.object({
21
- name: z.string().min(1).max(100),
22
- bio: z.string().max(500).optional(),
23
- });
24
-
25
- // Type-safe action with error handling
26
- export async function updateProfile(formData: FormData) {
27
- // 1. Authenticate
28
- const { userId } = await auth();
29
- if (!userId) {
30
- return { error: 'Unauthorized' };
31
- }
32
-
33
- // 2. Validate input
34
- const result = UpdateProfileSchema.safeParse({
35
- name: formData.get('name'),
36
- bio: formData.get('bio'),
37
- });
38
-
39
- if (!result.success) {
40
- return { error: 'Invalid input', details: result.error.flatten() };
41
- }
42
-
43
- // 3. Execute business logic
44
- try {
45
- const user = await prisma.user.update({
46
- where: { clerkId: userId },
47
- data: result.data,
48
- });
49
-
50
- // 4. Revalidate affected paths
51
- revalidatePath('/profile');
52
- revalidatePath('/settings');
53
-
54
- return { success: true, user };
55
- } catch (error) {
56
- console.error('Failed to update profile:', error);
57
- return { error: 'Failed to update profile' };
58
- }
59
- }
60
-
61
- // Action with optimistic updates support
62
- export async function toggleFavorite(itemId: string) {
63
- const { userId } = await auth();
64
- if (!userId) throw new Error('Unauthorized');
65
-
66
- const existing = await prisma.favorite.findUnique({
67
- where: {
68
- userId_itemId: { userId, itemId }
69
- }
70
- });
71
-
72
- if (existing) {
73
- await prisma.favorite.delete({
74
- where: { id: existing.id }
75
- });
76
- return { favorited: false };
77
- } else {
78
- await prisma.favorite.create({
79
- data: { userId, itemId }
80
- });
81
- return { favorited: true };
82
- }
83
- }
84
- ```
85
-
86
- ### Route Handlers (API Routes)
87
-
88
- ```typescript
89
- // app/api/users/route.ts
90
- import { NextRequest, NextResponse } from 'next/server';
91
- import { auth } from '@clerk/nextjs/server';
92
- import { prisma } from '@/lib/prisma';
93
- import { z } from 'zod';
94
-
95
- // GET: List users with pagination
96
- export async function GET(request: NextRequest) {
97
- const { searchParams } = new URL(request.url);
98
- const page = parseInt(searchParams.get('page') ?? '1');
99
- const limit = parseInt(searchParams.get('limit') ?? '10');
100
-
101
- const [users, total] = await Promise.all([
102
- prisma.user.findMany({
103
- skip: (page - 1) * limit,
104
- take: limit,
105
- orderBy: { createdAt: 'desc' },
106
- select: {
107
- id: true,
108
- name: true,
109
- email: true,
110
- createdAt: true,
111
- },
112
- }),
113
- prisma.user.count(),
114
- ]);
115
-
116
- return NextResponse.json({
117
- data: users,
118
- pagination: {
119
- page,
120
- limit,
121
- total,
122
- pages: Math.ceil(total / limit),
123
- },
124
- });
125
- }
126
-
127
- // POST: Create user
128
- const CreateUserSchema = z.object({
129
- email: z.string().email(),
130
- name: z.string().min(1).max(100),
131
- });
132
-
133
- export async function POST(request: NextRequest) {
134
- const { userId } = await auth();
135
- if (!userId) {
136
- return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
137
- }
138
-
139
- const body = await request.json();
140
- const result = CreateUserSchema.safeParse(body);
141
-
142
- if (!result.success) {
143
- return NextResponse.json(
144
- { error: 'Validation failed', details: result.error.flatten() },
145
- { status: 400 }
146
- );
147
- }
148
-
149
- try {
150
- const user = await prisma.user.create({
151
- data: result.data,
152
- });
153
- return NextResponse.json(user, { status: 201 });
154
- } catch (error) {
155
- if (error.code === 'P2002') {
156
- return NextResponse.json(
157
- { error: 'Email already exists' },
158
- { status: 409 }
159
- );
160
- }
161
- throw error;
162
- }
163
- }
164
-
165
- // app/api/users/[id]/route.ts
166
- // Dynamic route handlers
167
- export async function GET(
168
- request: NextRequest,
169
- { params }: { params: Promise<{ id: string }> }
170
- ) {
171
- const { id } = await params;
172
-
173
- const user = await prisma.user.findUnique({
174
- where: { id },
175
- });
176
-
177
- if (!user) {
178
- return NextResponse.json({ error: 'Not found' }, { status: 404 });
179
- }
180
-
181
- return NextResponse.json(user);
182
- }
183
-
184
- export async function PATCH(
185
- request: NextRequest,
186
- { params }: { params: Promise<{ id: string }> }
187
- ) {
188
- const { id } = await params;
189
- const { userId } = await auth();
190
- if (!userId) {
191
- return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
192
- }
193
-
194
- const body = await request.json();
195
- // Validate and update...
196
- }
197
-
198
- export async function DELETE(
199
- request: NextRequest,
200
- { params }: { params: Promise<{ id: string }> }
201
- ) {
202
- const { id } = await params;
203
- const { userId } = await auth();
204
- if (!userId) {
205
- return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
206
- }
207
-
208
- await prisma.user.delete({ where: { id } });
209
- return new NextResponse(null, { status: 204 });
210
- }
211
- ```
212
-
213
- ### Service Layer Pattern
214
-
215
- ```typescript
216
- // lib/services/user-service.ts
217
- import { prisma } from '@/lib/prisma';
218
- import { Prisma } from '@prisma/client';
219
-
220
- export class UserService {
221
- async findById(id: string) {
222
- return prisma.user.findUnique({
223
- where: { id },
224
- include: {
225
- profile: true,
226
- subscription: true,
227
- },
228
- });
229
- }
230
-
231
- async findByEmail(email: string) {
232
- return prisma.user.findUnique({ where: { email } });
233
- }
234
-
235
- async create(data: Prisma.UserCreateInput) {
236
- return prisma.user.create({ data });
237
- }
238
-
239
- async update(id: string, data: Prisma.UserUpdateInput) {
240
- return prisma.user.update({
241
- where: { id },
242
- data: {
243
- ...data,
244
- updatedAt: new Date(),
245
- },
246
- });
247
- }
248
-
249
- async softDelete(id: string) {
250
- return prisma.user.update({
251
- where: { id },
252
- data: { deletedAt: new Date() },
253
- });
254
- }
255
-
256
- async getWithStats(id: string) {
257
- const user = await prisma.user.findUnique({
258
- where: { id },
259
- include: {
260
- _count: {
261
- select: {
262
- posts: true,
263
- comments: true,
264
- followers: true,
265
- },
266
- },
267
- },
268
- });
269
- return user;
270
- }
271
- }
272
-
273
- export const userService = new UserService();
274
- ```
275
-
276
- ### Webhook Handling
277
-
278
- ```typescript
279
- // app/api/webhooks/stripe/route.ts
280
- import { NextRequest, NextResponse } from 'next/server';
281
- import Stripe from 'stripe';
282
- import { prisma } from '@/lib/prisma';
283
-
284
- const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
285
- const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET!;
286
-
287
- export async function POST(request: NextRequest) {
288
- const body = await request.text();
289
- const signature = request.headers.get('stripe-signature')!;
290
-
291
- let event: Stripe.Event;
292
-
293
- // 1. Verify webhook signature
294
- try {
295
- event = stripe.webhooks.constructEvent(body, signature, webhookSecret);
296
- } catch (err) {
297
- console.error('Webhook signature verification failed:', err);
298
- return NextResponse.json({ error: 'Invalid signature' }, { status: 400 });
299
- }
300
-
301
- // 2. Handle event types
302
- try {
303
- switch (event.type) {
304
- case 'checkout.session.completed': {
305
- const session = event.data.object as Stripe.Checkout.Session;
306
- await handleCheckoutComplete(session);
307
- break;
308
- }
309
-
310
- case 'customer.subscription.updated': {
311
- const subscription = event.data.object as Stripe.Subscription;
312
- await handleSubscriptionUpdate(subscription);
313
- break;
314
- }
315
-
316
- case 'customer.subscription.deleted': {
317
- const subscription = event.data.object as Stripe.Subscription;
318
- await handleSubscriptionCanceled(subscription);
319
- break;
320
- }
321
-
322
- case 'invoice.payment_failed': {
323
- const invoice = event.data.object as Stripe.Invoice;
324
- await handlePaymentFailed(invoice);
325
- break;
326
- }
327
-
328
- default:
329
- console.log(`Unhandled event type: ${event.type}`);
330
- }
331
-
332
- return NextResponse.json({ received: true });
333
- } catch (error) {
334
- console.error('Webhook handler error:', error);
335
- return NextResponse.json(
336
- { error: 'Webhook handler failed' },
337
- { status: 500 }
338
- );
339
- }
340
- }
341
-
342
- async function handleCheckoutComplete(session: Stripe.Checkout.Session) {
343
- const userId = session.metadata?.userId;
344
- if (!userId) throw new Error('Missing userId in metadata');
345
-
346
- await prisma.user.update({
347
- where: { id: userId },
348
- data: {
349
- stripeCustomerId: session.customer as string,
350
- subscriptionStatus: 'active',
351
- },
352
- });
353
- }
354
-
355
- async function handleSubscriptionUpdate(subscription: Stripe.Subscription) {
356
- await prisma.subscription.upsert({
357
- where: { stripeSubscriptionId: subscription.id },
358
- update: {
359
- status: subscription.status,
360
- currentPeriodEnd: new Date(subscription.current_period_end * 1000),
361
- cancelAtPeriodEnd: subscription.cancel_at_period_end,
362
- },
363
- create: {
364
- stripeSubscriptionId: subscription.id,
365
- stripeCustomerId: subscription.customer as string,
366
- status: subscription.status,
367
- currentPeriodEnd: new Date(subscription.current_period_end * 1000),
368
- },
369
- });
370
- }
371
- ```
372
-
373
- ### Background Jobs Pattern
374
-
375
- ```typescript
376
- // lib/jobs/email-job.ts
377
- import { Resend } from 'resend';
378
-
379
- const resend = new Resend(process.env.RESEND_API_KEY);
380
-
381
- export async function sendWelcomeEmail(userId: string, email: string) {
382
- try {
383
- await resend.emails.send({
384
- from: 'welcome@yourapp.com',
385
- to: email,
386
- subject: 'Welcome to Our App!',
387
- react: WelcomeEmailTemplate({ userId }),
388
- });
389
-
390
- // Log successful send
391
- await prisma.emailLog.create({
392
- data: {
393
- userId,
394
- type: 'welcome',
395
- status: 'sent',
396
- sentAt: new Date(),
397
- },
398
- });
399
- } catch (error) {
400
- console.error('Failed to send welcome email:', error);
401
- // Queue for retry
402
- await prisma.emailLog.create({
403
- data: {
404
- userId,
405
- type: 'welcome',
406
- status: 'failed',
407
- error: error.message,
408
- },
409
- });
410
- }
411
- }
412
- ```
413
-
414
- ### Error Handling
415
-
416
- ```typescript
417
- // lib/errors.ts
418
- export class AppError extends Error {
419
- constructor(
420
- message: string,
421
- public code: string,
422
- public statusCode: number = 400
423
- ) {
424
- super(message);
425
- this.name = 'AppError';
426
- }
427
- }
428
-
429
- export class NotFoundError extends AppError {
430
- constructor(resource: string) {
431
- super(`${resource} not found`, 'NOT_FOUND', 404);
432
- }
433
- }
434
-
435
- export class UnauthorizedError extends AppError {
436
- constructor(message = 'Unauthorized') {
437
- super(message, 'UNAUTHORIZED', 401);
438
- }
439
- }
440
-
441
- export class ValidationError extends AppError {
442
- constructor(public details: Record<string, string[]>) {
443
- super('Validation failed', 'VALIDATION_ERROR', 400);
444
- }
445
- }
446
-
447
- // Usage in route handler
448
- export async function GET(request: NextRequest) {
449
- try {
450
- const user = await userService.findById(id);
451
- if (!user) throw new NotFoundError('User');
452
- return NextResponse.json(user);
453
- } catch (error) {
454
- if (error instanceof AppError) {
455
- return NextResponse.json(
456
- { error: error.message, code: error.code },
457
- { status: error.statusCode }
458
- );
459
- }
460
- console.error('Unexpected error:', error);
461
- return NextResponse.json(
462
- { error: 'Internal server error' },
463
- { status: 500 }
464
- );
465
- }
466
- }
467
- ```
468
-
469
- ## Backend Checklist
470
-
471
- - [ ] Input validated with Zod schemas
472
- - [ ] Authentication checked before mutations
473
- - [ ] Authorization verified for resource access
474
- - [ ] Errors handled gracefully
475
- - [ ] Database operations optimized
476
- - [ ] Webhook signatures verified
477
- - [ ] Sensitive data not logged
478
- - [ ] Rate limiting on public endpoints
479
- - [ ] Proper HTTP status codes used
480
- - [ ] Transactions used for related operations
481
-
482
- ## Trigger Keywords
483
- api, server action, route handler, backend, business logic, service, webhook, endpoint, post, get, patch, delete, mutation, query, authentication, authorization, middleware
@@ -1,180 +0,0 @@
1
- # Business Strategy Expert Agent
2
-
3
- ## Role
4
- Specialized in business strategy, market positioning, competitive analysis, and strategic planning for startups and growing companies.
5
-
6
- ## Core Expertise
7
-
8
- ### Business Model Canvas
9
-
10
- ```markdown
11
- ## Business Model Canvas Template
12
-
13
- ### 1. Value Proposition
14
- - What problem do we solve?
15
- - What value do we deliver?
16
- - What needs do we satisfy?
17
-
18
- ### 2. Customer Segments
19
- - Who are our most important customers?
20
- - Mass market, niche, segmented, or diversified?
21
- - B2B, B2C, or B2B2C?
22
-
23
- ### 3. Channels
24
- - How do we reach customers?
25
- - Sales, marketing, distribution channels
26
- - Direct vs. indirect
27
-
28
- ### 4. Customer Relationships
29
- - What type of relationship?
30
- - Self-service, personal assistance, automated
31
- - Community, co-creation
32
-
33
- ### 5. Revenue Streams
34
- - What are customers willing to pay for?
35
- - Pricing models: subscription, usage, licensing
36
- - One-time vs. recurring
37
-
38
- ### 6. Key Resources
39
- - Physical, intellectual, human, financial
40
- - What do we need to deliver value?
41
-
42
- ### 7. Key Activities
43
- - Production, problem-solving, platform/network
44
- - What activities are critical?
45
-
46
- ### 8. Key Partnerships
47
- - Suppliers, strategic alliances
48
- - Who helps us deliver value?
49
-
50
- ### 9. Cost Structure
51
- - Fixed vs. variable costs
52
- - Economies of scale
53
- - Cost-driven vs. value-driven
54
- ```
55
-
56
- ### Market Positioning Framework
57
-
58
- ```markdown
59
- ## Positioning Statement
60
-
61
- FOR [target customer]
62
- WHO [statement of need/opportunity]
63
- [Product name] IS A [product category]
64
- THAT [key benefit/reason to buy]
65
- UNLIKE [primary competitive alternative]
66
- OUR PRODUCT [primary differentiation]
67
-
68
- ## Example
69
-
70
- FOR modern development teams
71
- WHO need to ship faster with AI assistance
72
- Bootspring IS A developer productivity platform
73
- THAT provides intelligent scaffolding and context management
74
- UNLIKE traditional boilerplate generators
75
- OUR PRODUCT learns your project and provides specialized AI agents
76
- ```
77
-
78
- ### Competitive Analysis Template
79
-
80
- ```markdown
81
- ## Competitive Landscape
82
-
83
- ### Direct Competitors
84
- | Competitor | Strengths | Weaknesses | Our Advantage |
85
- |------------|-----------|------------|---------------|
86
- | Competitor A | Feature X | Missing Y | Our feature Z |
87
-
88
- ### Indirect Competitors
89
- - Alternative solutions
90
- - Manual processes
91
- - Status quo
92
-
93
- ### Competitive Moats
94
- 1. **Network Effects**: Value increases with users
95
- 2. **Data Moats**: Proprietary data advantage
96
- 3. **Switching Costs**: Integration depth
97
- 4. **Brand**: Recognition and trust
98
- 5. **Technology**: Proprietary innovation
99
- ```
100
-
101
- ### Strategic Planning
102
-
103
- ```markdown
104
- ## OKR Framework (Objectives and Key Results)
105
-
106
- ### Q1 Objectives
107
-
108
- **Objective 1: Achieve Product-Market Fit**
109
- - KR1: Reach 100 paying customers
110
- - KR2: Achieve 40% week-over-week retention
111
- - KR3: NPS score above 50
112
-
113
- **Objective 2: Build Scalable Foundation**
114
- - KR1: 99.9% uptime
115
- - KR2: < 200ms API response time
116
- - KR3: Zero critical security vulnerabilities
117
-
118
- **Objective 3: Establish Market Presence**
119
- - KR1: 10,000 website visitors/month
120
- - KR2: 50 organic signups/week
121
- - KR3: 5 customer case studies
122
- ```
123
-
124
- ### Go-to-Market Strategy
125
-
126
- ```markdown
127
- ## GTM Framework
128
-
129
- ### Phase 1: Foundation (Month 1-3)
130
- - [ ] Define ICP (Ideal Customer Profile)
131
- - [ ] Create positioning and messaging
132
- - [ ] Build landing page and waitlist
133
- - [ ] Establish metrics baseline
134
-
135
- ### Phase 2: Validation (Month 4-6)
136
- - [ ] Launch beta program
137
- - [ ] Conduct customer interviews
138
- - [ ] Iterate on product
139
- - [ ] Document case studies
140
-
141
- ### Phase 3: Growth (Month 7-12)
142
- - [ ] Launch pricing and billing
143
- - [ ] Scale acquisition channels
144
- - [ ] Build sales playbook
145
- - [ ] Expand team
146
- ```
147
-
148
- ### Unit Economics
149
-
150
- ```markdown
151
- ## SaaS Metrics Framework
152
-
153
- ### Customer Acquisition
154
- - **CAC** (Customer Acquisition Cost): Total sales & marketing / New customers
155
- - **Payback Period**: CAC / Monthly gross margin per customer
156
-
157
- ### Customer Value
158
- - **ARPU** (Average Revenue Per User): MRR / Active customers
159
- - **LTV** (Lifetime Value): ARPU × Average customer lifespan
160
- - **LTV:CAC Ratio**: Target 3:1 or higher
161
-
162
- ### Retention
163
- - **Churn Rate**: Customers lost / Starting customers
164
- - **Net Revenue Retention**: (Starting MRR + Expansion - Contraction - Churn) / Starting MRR
165
- - **Target NRR**: 100%+ (revenue grows even without new customers)
166
- ```
167
-
168
- ## Strategy Checklist
169
-
170
- - [ ] Value proposition clearly defined
171
- - [ ] Target customer identified and validated
172
- - [ ] Competitive landscape mapped
173
- - [ ] Business model documented
174
- - [ ] Pricing strategy established
175
- - [ ] Go-to-market plan created
176
- - [ ] Key metrics defined
177
- - [ ] OKRs set for quarter
178
-
179
- ## Trigger Keywords
180
- strategy, business model, positioning, competitive, market, GTM, go-to-market, pricing, OKR, roadmap, planning, vision, mission, moat, differentiation