@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.
- package/README.md +107 -14
- package/bin/bootspring.js +166 -27
- package/cli/agent.js +189 -17
- package/cli/analyze.js +499 -0
- package/cli/audit.js +557 -0
- package/cli/auth.js +495 -38
- package/cli/billing.js +302 -0
- package/cli/build.js +695 -0
- package/cli/business.js +109 -26
- package/cli/checkpoint-utils.js +168 -0
- package/cli/checkpoint.js +639 -0
- package/cli/cloud-sync.js +447 -0
- package/cli/content.js +198 -0
- package/cli/context.js +1 -1
- package/cli/deploy.js +543 -0
- package/cli/fundraise.js +112 -50
- package/cli/github-cmd.js +435 -0
- package/cli/health.js +477 -0
- package/cli/init.js +84 -13
- package/cli/legal.js +107 -95
- package/cli/log.js +2 -2
- package/cli/loop.js +976 -73
- package/cli/manager.js +711 -0
- package/cli/metrics.js +480 -0
- package/cli/monitor.js +812 -0
- package/cli/onboard.js +521 -0
- package/cli/orchestrator.js +12 -24
- package/cli/prd.js +594 -0
- package/cli/preseed-start.js +1483 -0
- package/cli/preseed.js +2302 -0
- package/cli/project.js +436 -0
- package/cli/quality.js +233 -0
- package/cli/security.js +913 -0
- package/cli/seed.js +1441 -5
- package/cli/skill.js +273 -211
- package/cli/suggest.js +989 -0
- package/cli/switch.js +453 -0
- package/cli/visualize.js +527 -0
- package/cli/watch.js +769 -0
- package/cli/workspace.js +607 -0
- package/core/analyze-workflow.js +1134 -0
- package/core/api-client.js +535 -22
- package/core/audit-workflow.js +1350 -0
- package/core/build-orchestrator.js +480 -0
- package/core/build-state.js +577 -0
- package/core/checkpoint-engine.js +408 -0
- package/core/config.js +1109 -26
- package/core/context-loader.js +21 -1
- package/core/deploy-workflow.js +836 -0
- package/core/entitlements.js +93 -22
- package/core/github-sync.js +610 -0
- package/core/index.js +8 -1
- package/core/ingest.js +1111 -0
- package/core/metrics-engine.js +768 -0
- package/core/onboard-workflow.js +1007 -0
- package/core/preseed-workflow.js +934 -0
- package/core/preseed.js +1617 -0
- package/core/project-context.js +325 -0
- package/core/project-state.js +694 -0
- package/core/r2-sync.js +583 -0
- package/core/scaffold.js +525 -7
- package/core/session.js +258 -0
- package/core/task-extractor.js +758 -0
- package/core/telemetry.js +28 -6
- package/core/tier-enforcement.js +737 -0
- package/core/utils.js +38 -14
- package/generators/questionnaire.js +15 -12
- package/generators/sections/ai.js +7 -7
- package/generators/sections/content.js +300 -0
- package/generators/sections/index.js +3 -0
- package/generators/sections/plugins.js +7 -6
- package/generators/templates/build-planning.template.js +596 -0
- package/generators/templates/content.template.js +819 -0
- package/generators/templates/index.js +2 -1
- package/hooks/git-autopilot.js +1250 -0
- package/hooks/index.js +9 -0
- package/intelligence/agent-collab.js +2057 -0
- package/intelligence/auto-suggest.js +634 -0
- package/intelligence/content-gen.js +1589 -0
- package/intelligence/cross-project.js +1647 -0
- package/intelligence/index.js +184 -0
- package/intelligence/learning/insights.json +517 -7
- package/intelligence/learning/pattern-learner.js +1008 -14
- package/intelligence/memory/decision-tracker.js +1431 -31
- package/intelligence/memory/decisions.jsonl +0 -0
- package/intelligence/orchestrator.js +2896 -1
- package/intelligence/prd.js +92 -1
- package/intelligence/recommendation-weights.json +14 -2
- package/intelligence/recommendations.js +463 -9
- package/intelligence/workflow-composer.js +1451 -0
- package/marketplace/index.d.ts +324 -0
- package/marketplace/index.js +1921 -0
- package/mcp/contracts/mcp-contract.v1.json +342 -4
- package/mcp/registry.js +680 -3
- package/mcp/response-formatter.js +23 -0
- package/mcp/tools/assist-tool.js +78 -4
- package/mcp/tools/autopilot-tool.js +408 -0
- package/mcp/tools/content-tool.js +571 -0
- package/mcp/tools/dashboard-tool.js +251 -5
- package/mcp/tools/mvp-tool.js +344 -0
- package/mcp/tools/plugin-tool.js +23 -1
- package/mcp/tools/prd-tool.js +579 -0
- package/mcp/tools/seed-tool.js +447 -0
- package/mcp/tools/skill-tool.js +43 -14
- package/mcp/tools/suggest-tool.js +147 -0
- package/package.json +15 -6
- package/agents/README.md +0 -93
- package/agents/ai-integration-expert/context.md +0 -386
- package/agents/api-expert/context.md +0 -416
- package/agents/architecture-expert/context.md +0 -454
- package/agents/auth-expert/context.md +0 -399
- package/agents/backend-expert/context.md +0 -483
- package/agents/business-strategy-expert/context.md +0 -180
- package/agents/code-review-expert/context.md +0 -365
- package/agents/competitive-analysis-expert/context.md +0 -239
- package/agents/data-modeling-expert/context.md +0 -352
- package/agents/database-expert/context.md +0 -250
- package/agents/devops-expert/context.md +0 -446
- package/agents/email-expert/context.md +0 -379
- package/agents/financial-expert/context.md +0 -213
- package/agents/frontend-expert/context.md +0 -364
- package/agents/fundraising-expert/context.md +0 -257
- package/agents/growth-expert/context.md +0 -249
- package/agents/index.js +0 -140
- package/agents/investor-relations-expert/context.md +0 -266
- package/agents/legal-expert/context.md +0 -284
- package/agents/marketing-expert/context.md +0 -236
- package/agents/monitoring-expert/context.md +0 -362
- package/agents/operations-expert/context.md +0 -279
- package/agents/partnerships-expert/context.md +0 -286
- package/agents/payment-expert/context.md +0 -340
- package/agents/performance-expert/context.md +0 -377
- package/agents/private-equity-expert/context.md +0 -246
- package/agents/railway-expert/context.md +0 -284
- package/agents/research-expert/context.md +0 -245
- package/agents/sales-expert/context.md +0 -241
- package/agents/security-expert/context.md +0 -343
- package/agents/testing-expert/context.md +0 -414
- package/agents/ui-ux-expert/context.md +0 -448
- package/agents/vercel-expert/context.md +0 -426
- package/skills/index.js +0 -787
- package/skills/patterns/README.md +0 -163
- package/skills/patterns/ai/agents.md +0 -281
- package/skills/patterns/ai/claude.md +0 -138
- package/skills/patterns/ai/embeddings.md +0 -150
- package/skills/patterns/ai/rag.md +0 -266
- package/skills/patterns/ai/streaming.md +0 -170
- package/skills/patterns/ai/structured-output.md +0 -162
- package/skills/patterns/ai/tools.md +0 -154
- package/skills/patterns/analytics/tracking.md +0 -220
- package/skills/patterns/api/errors.md +0 -296
- package/skills/patterns/api/graphql.md +0 -440
- package/skills/patterns/api/middleware.md +0 -279
- package/skills/patterns/api/openapi.md +0 -285
- package/skills/patterns/api/rate-limiting.md +0 -231
- package/skills/patterns/api/route-handler.md +0 -217
- package/skills/patterns/api/server-action.md +0 -249
- package/skills/patterns/api/versioning.md +0 -443
- package/skills/patterns/api/webhooks.md +0 -247
- package/skills/patterns/auth/clerk.md +0 -132
- package/skills/patterns/auth/mfa.md +0 -313
- package/skills/patterns/auth/nextauth.md +0 -140
- package/skills/patterns/auth/oauth.md +0 -237
- package/skills/patterns/auth/rbac.md +0 -152
- package/skills/patterns/auth/session-management.md +0 -367
- package/skills/patterns/auth/session.md +0 -120
- package/skills/patterns/database/audit.md +0 -177
- package/skills/patterns/database/migrations.md +0 -177
- package/skills/patterns/database/pagination.md +0 -230
- package/skills/patterns/database/pooling.md +0 -357
- package/skills/patterns/database/prisma.md +0 -180
- package/skills/patterns/database/relations.md +0 -187
- package/skills/patterns/database/seeding.md +0 -246
- package/skills/patterns/database/soft-delete.md +0 -153
- package/skills/patterns/database/transactions.md +0 -162
- package/skills/patterns/deployment/ci-cd.md +0 -231
- package/skills/patterns/deployment/docker.md +0 -188
- package/skills/patterns/deployment/monitoring.md +0 -387
- package/skills/patterns/deployment/vercel.md +0 -160
- package/skills/patterns/email/resend.md +0 -143
- package/skills/patterns/email/templates.md +0 -245
- package/skills/patterns/email/transactional.md +0 -503
- package/skills/patterns/email/verification.md +0 -176
- package/skills/patterns/files/download.md +0 -243
- package/skills/patterns/files/upload.md +0 -239
- package/skills/patterns/i18n/nextintl.md +0 -188
- package/skills/patterns/logging/structured.md +0 -292
- package/skills/patterns/notifications/email-queue.md +0 -248
- package/skills/patterns/notifications/push.md +0 -279
- package/skills/patterns/payments/checkout.md +0 -303
- package/skills/patterns/payments/invoices.md +0 -287
- package/skills/patterns/payments/portal.md +0 -245
- package/skills/patterns/payments/stripe.md +0 -272
- package/skills/patterns/payments/subscriptions.md +0 -300
- package/skills/patterns/payments/usage.md +0 -279
- package/skills/patterns/performance/caching.md +0 -276
- package/skills/patterns/performance/code-splitting.md +0 -233
- package/skills/patterns/performance/edge.md +0 -254
- package/skills/patterns/performance/isr.md +0 -266
- package/skills/patterns/performance/lazy-loading.md +0 -281
- package/skills/patterns/realtime/sse.md +0 -327
- package/skills/patterns/realtime/websockets.md +0 -336
- package/skills/patterns/search/filtering.md +0 -329
- package/skills/patterns/search/fulltext.md +0 -260
- package/skills/patterns/security/audit-logging.md +0 -444
- package/skills/patterns/security/csrf.md +0 -234
- package/skills/patterns/security/headers.md +0 -252
- package/skills/patterns/security/sanitization.md +0 -258
- package/skills/patterns/security/secrets.md +0 -261
- package/skills/patterns/security/validation.md +0 -268
- package/skills/patterns/security/xss.md +0 -229
- package/skills/patterns/seo/metadata.md +0 -252
- package/skills/patterns/state/context.md +0 -349
- package/skills/patterns/state/react-query.md +0 -313
- package/skills/patterns/state/url-state.md +0 -482
- package/skills/patterns/state/zustand.md +0 -262
- package/skills/patterns/testing/api.md +0 -259
- package/skills/patterns/testing/component.md +0 -233
- package/skills/patterns/testing/coverage.md +0 -207
- package/skills/patterns/testing/fixtures.md +0 -225
- package/skills/patterns/testing/integration.md +0 -436
- package/skills/patterns/testing/mocking.md +0 -177
- package/skills/patterns/testing/playwright.md +0 -162
- package/skills/patterns/testing/snapshot.md +0 -175
- package/skills/patterns/testing/vitest.md +0 -307
- package/skills/patterns/ui/accordions.md +0 -395
- package/skills/patterns/ui/cards.md +0 -299
- package/skills/patterns/ui/dropdowns.md +0 -476
- package/skills/patterns/ui/empty-states.md +0 -320
- package/skills/patterns/ui/forms.md +0 -405
- package/skills/patterns/ui/inputs.md +0 -319
- package/skills/patterns/ui/layouts.md +0 -282
- package/skills/patterns/ui/loading.md +0 -291
- package/skills/patterns/ui/modals.md +0 -338
- package/skills/patterns/ui/navigation.md +0 -374
- package/skills/patterns/ui/tables.md +0 -407
- package/skills/patterns/ui/toasts.md +0 -300
- package/skills/patterns/ui/tooltips.md +0 -396
- package/skills/patterns/utils/dates.md +0 -435
- package/skills/patterns/utils/errors.md +0 -451
- package/skills/patterns/utils/formatting.md +0 -345
- package/skills/patterns/utils/validation.md +0 -434
- package/templates/bootspring.config.js +0 -83
- package/templates/business/business-model-canvas.md +0 -246
- package/templates/business/business-plan.md +0 -266
- package/templates/business/competitive-analysis.md +0 -312
- package/templates/fundraising/data-room-checklist.md +0 -300
- package/templates/fundraising/investor-research.md +0 -243
- package/templates/fundraising/pitch-deck-outline.md +0 -253
- package/templates/legal/gdpr-checklist.md +0 -339
- package/templates/legal/privacy-policy.md +0 -285
- package/templates/legal/terms-of-service.md +0 -222
- package/templates/mcp.json +0 -9
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
# Sales Expert Agent
|
|
2
|
-
|
|
3
|
-
## Role
|
|
4
|
-
Specialized in B2B sales strategy, sales processes, pricing, demos, and building scalable sales motions for startups.
|
|
5
|
-
|
|
6
|
-
## Core Expertise
|
|
7
|
-
|
|
8
|
-
### Sales Process Framework
|
|
9
|
-
|
|
10
|
-
```markdown
|
|
11
|
-
## B2B SaaS Sales Process
|
|
12
|
-
|
|
13
|
-
### Stage 1: Lead Generation
|
|
14
|
-
- Inbound: Content, SEO, ads, referrals
|
|
15
|
-
- Outbound: Cold email, LinkedIn, events
|
|
16
|
-
- Product-led: Free trials, freemium conversions
|
|
17
|
-
|
|
18
|
-
### Stage 2: Qualification (BANT)
|
|
19
|
-
- **Budget**: Can they afford it?
|
|
20
|
-
- **Authority**: Are they decision makers?
|
|
21
|
-
- **Need**: Do they have the problem we solve?
|
|
22
|
-
- **Timeline**: When do they need a solution?
|
|
23
|
-
|
|
24
|
-
### Stage 3: Discovery Call
|
|
25
|
-
- Understand current situation
|
|
26
|
-
- Identify pain points
|
|
27
|
-
- Quantify impact of problems
|
|
28
|
-
- Determine decision criteria
|
|
29
|
-
|
|
30
|
-
### Stage 4: Demo
|
|
31
|
-
- Customize to their use case
|
|
32
|
-
- Focus on outcomes, not features
|
|
33
|
-
- Show relevant examples
|
|
34
|
-
- Address objections
|
|
35
|
-
|
|
36
|
-
### Stage 5: Proposal
|
|
37
|
-
- Summarize needs and solution
|
|
38
|
-
- Present pricing options
|
|
39
|
-
- Include ROI analysis
|
|
40
|
-
- Define next steps
|
|
41
|
-
|
|
42
|
-
### Stage 6: Negotiation
|
|
43
|
-
- Handle objections
|
|
44
|
-
- Discuss terms
|
|
45
|
-
- Create urgency
|
|
46
|
-
- Agree on timeline
|
|
47
|
-
|
|
48
|
-
### Stage 7: Close
|
|
49
|
-
- Send contract
|
|
50
|
-
- Facilitate signature
|
|
51
|
-
- Handoff to onboarding
|
|
52
|
-
- Celebrate!
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Discovery Call Framework
|
|
56
|
-
|
|
57
|
-
```markdown
|
|
58
|
-
## SPIN Selling Questions
|
|
59
|
-
|
|
60
|
-
### Situation Questions
|
|
61
|
-
- "Walk me through your current process for X?"
|
|
62
|
-
- "What tools are you currently using?"
|
|
63
|
-
- "How many people are involved in this process?"
|
|
64
|
-
- "How long have you been doing it this way?"
|
|
65
|
-
|
|
66
|
-
### Problem Questions
|
|
67
|
-
- "What challenges are you facing with X?"
|
|
68
|
-
- "What happens when Y goes wrong?"
|
|
69
|
-
- "How much time do you spend on Z?"
|
|
70
|
-
- "What frustrates you most about the current approach?"
|
|
71
|
-
|
|
72
|
-
### Implication Questions
|
|
73
|
-
- "What impact does this have on your team?"
|
|
74
|
-
- "How does this affect your ability to achieve [goal]?"
|
|
75
|
-
- "What happens if this problem isn't solved?"
|
|
76
|
-
- "What opportunities are you missing because of this?"
|
|
77
|
-
|
|
78
|
-
### Need-Payoff Questions
|
|
79
|
-
- "How would it help if you could [benefit]?"
|
|
80
|
-
- "What would it mean to your team to save X hours/week?"
|
|
81
|
-
- "How would solving this impact your [KPI]?"
|
|
82
|
-
- "What would you do with the time/money saved?"
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Demo Best Practices
|
|
86
|
-
|
|
87
|
-
```markdown
|
|
88
|
-
## Demo Structure (30 minutes)
|
|
89
|
-
|
|
90
|
-
### Opening (5 min)
|
|
91
|
-
- Recap their situation and goals
|
|
92
|
-
- Set agenda for the call
|
|
93
|
-
- Confirm time and attendees
|
|
94
|
-
|
|
95
|
-
### Discovery Recap (3 min)
|
|
96
|
-
- "Last time we discussed..."
|
|
97
|
-
- "Your main challenges are..."
|
|
98
|
-
- "You're looking to achieve..."
|
|
99
|
-
|
|
100
|
-
### Demo (15 min)
|
|
101
|
-
- Start with their #1 use case
|
|
102
|
-
- Show the "aha moment" early
|
|
103
|
-
- Use their terminology
|
|
104
|
-
- Pause for questions
|
|
105
|
-
- Show relevant integrations
|
|
106
|
-
|
|
107
|
-
### ROI Discussion (5 min)
|
|
108
|
-
- Quantify the impact
|
|
109
|
-
- Compare to current costs
|
|
110
|
-
- Show payback period
|
|
111
|
-
|
|
112
|
-
### Close (2 min)
|
|
113
|
-
- "Based on what you've seen..."
|
|
114
|
-
- Propose next steps
|
|
115
|
-
- Schedule follow-up
|
|
116
|
-
- Send summary email
|
|
117
|
-
|
|
118
|
-
## Demo Don'ts
|
|
119
|
-
- Don't feature dump
|
|
120
|
-
- Don't go over time
|
|
121
|
-
- Don't skip their questions
|
|
122
|
-
- Don't forget to close
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Objection Handling
|
|
126
|
-
|
|
127
|
-
```markdown
|
|
128
|
-
## Common Objections and Responses
|
|
129
|
-
|
|
130
|
-
### "It's too expensive"
|
|
131
|
-
1. Understand context: "Compared to what?"
|
|
132
|
-
2. Reframe: "What's the cost of not solving this?"
|
|
133
|
-
3. Break down: "That's just $X per user/day"
|
|
134
|
-
4. Offer: "Would a quarterly plan help?"
|
|
135
|
-
|
|
136
|
-
### "We need to think about it"
|
|
137
|
-
1. Probe: "What specifically needs more thought?"
|
|
138
|
-
2. Identify concerns: "What's holding you back?"
|
|
139
|
-
3. Offer help: "What information would help?"
|
|
140
|
-
4. Create timeline: "When should we reconnect?"
|
|
141
|
-
|
|
142
|
-
### "We're using [Competitor]"
|
|
143
|
-
1. Acknowledge: "Great tool for X"
|
|
144
|
-
2. Differentiate: "Where we differ is..."
|
|
145
|
-
3. Quantify: "Our customers who switched saw..."
|
|
146
|
-
4. Offer: "Happy to show you the differences"
|
|
147
|
-
|
|
148
|
-
### "Not the right time"
|
|
149
|
-
1. Understand: "What's happening right now?"
|
|
150
|
-
2. Impact: "What's the cost of waiting?"
|
|
151
|
-
3. Plant seed: "When would be better?"
|
|
152
|
-
4. Stay in touch: "Can I send relevant content?"
|
|
153
|
-
|
|
154
|
-
### "I need to check with [Someone]"
|
|
155
|
-
1. Support: "Happy to join that conversation"
|
|
156
|
-
2. Equip: "What would help you present this?"
|
|
157
|
-
3. Direct: "Would it help if we scheduled a call together?"
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
### Pricing Strategies
|
|
161
|
-
|
|
162
|
-
```markdown
|
|
163
|
-
## Pricing Presentation
|
|
164
|
-
|
|
165
|
-
### Good-Better-Best Structure
|
|
166
|
-
| Plan | Price | Target | Position |
|
|
167
|
-
|------|-------|--------|----------|
|
|
168
|
-
| Basic | $29/mo | Entry | Foot in door |
|
|
169
|
-
| Pro | $79/mo | Main | Most popular |
|
|
170
|
-
| Enterprise | Custom | Large | High touch |
|
|
171
|
-
|
|
172
|
-
### Pricing Psychology
|
|
173
|
-
- **Anchor high**: Show enterprise first
|
|
174
|
-
- **Highlight value**: "Most popular" badge
|
|
175
|
-
- **Annual incentive**: 15-25% discount
|
|
176
|
-
- **Feature comparison**: Clear table
|
|
177
|
-
|
|
178
|
-
### Negotiation Tactics
|
|
179
|
-
- Never discount without getting something
|
|
180
|
-
- Offer annual commitment for discount
|
|
181
|
-
- Add value instead of reducing price
|
|
182
|
-
- Create deadline for pricing
|
|
183
|
-
- Bundle features vs. discount
|
|
184
|
-
|
|
185
|
-
### What NOT to Do
|
|
186
|
-
- Don't give discount on first ask
|
|
187
|
-
- Don't negotiate against yourself
|
|
188
|
-
- Don't cave on timeline
|
|
189
|
-
- Don't give pricing without context
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### Sales Metrics
|
|
193
|
-
|
|
194
|
-
```markdown
|
|
195
|
-
## Key Sales Metrics
|
|
196
|
-
|
|
197
|
-
### Activity Metrics
|
|
198
|
-
- Calls made
|
|
199
|
-
- Emails sent
|
|
200
|
-
- Meetings booked
|
|
201
|
-
- Demos delivered
|
|
202
|
-
|
|
203
|
-
### Pipeline Metrics
|
|
204
|
-
- Leads generated
|
|
205
|
-
- SQL (Sales Qualified Leads)
|
|
206
|
-
- Pipeline value
|
|
207
|
-
- Pipeline coverage (3x target)
|
|
208
|
-
|
|
209
|
-
### Efficiency Metrics
|
|
210
|
-
- Lead to SQL conversion
|
|
211
|
-
- SQL to opportunity
|
|
212
|
-
- Opportunity to close (win rate)
|
|
213
|
-
- Sales cycle length
|
|
214
|
-
- Average deal size
|
|
215
|
-
|
|
216
|
-
### Revenue Metrics
|
|
217
|
-
- Quota attainment
|
|
218
|
-
- MRR/ARR added
|
|
219
|
-
- Expansion revenue
|
|
220
|
-
- Churn
|
|
221
|
-
|
|
222
|
-
## Ideal Metrics
|
|
223
|
-
- Win rate: 20-30%
|
|
224
|
-
- Sales cycle: < 30 days (SMB), < 90 days (Mid-Market)
|
|
225
|
-
- Pipeline coverage: 3-4x quota
|
|
226
|
-
- Demo to close: 25-40%
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
## Sales Checklist
|
|
230
|
-
|
|
231
|
-
- [ ] ICP (Ideal Customer Profile) defined
|
|
232
|
-
- [ ] Sales process documented
|
|
233
|
-
- [ ] Discovery questions prepared
|
|
234
|
-
- [ ] Demo script created
|
|
235
|
-
- [ ] Objection responses ready
|
|
236
|
-
- [ ] Pricing strategy set
|
|
237
|
-
- [ ] CRM configured
|
|
238
|
-
- [ ] Metrics tracked
|
|
239
|
-
|
|
240
|
-
## Trigger Keywords
|
|
241
|
-
sales, demo, pricing, objection, close, deal, pipeline, quota, B2B, enterprise, negotiation, proposal, discovery, qualification, CRM
|
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
# Security Expert Agent
|
|
2
|
-
|
|
3
|
-
## Role
|
|
4
|
-
Specialized in application security, authentication, authorization, and protecting against common vulnerabilities. Expert in OWASP guidelines and secure coding practices.
|
|
5
|
-
|
|
6
|
-
## Core Expertise
|
|
7
|
-
|
|
8
|
-
### Authentication Patterns
|
|
9
|
-
|
|
10
|
-
#### Clerk Integration
|
|
11
|
-
```typescript
|
|
12
|
-
// Middleware setup
|
|
13
|
-
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
|
|
14
|
-
|
|
15
|
-
const isPublicRoute = createRouteMatcher([
|
|
16
|
-
'/',
|
|
17
|
-
'/sign-in(.*)',
|
|
18
|
-
'/sign-up(.*)',
|
|
19
|
-
'/api/webhooks(.*)',
|
|
20
|
-
]);
|
|
21
|
-
|
|
22
|
-
export default clerkMiddleware((auth, req) => {
|
|
23
|
-
if (!isPublicRoute(req)) {
|
|
24
|
-
auth().protect();
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// Server Component auth check
|
|
29
|
-
import { auth } from '@clerk/nextjs/server';
|
|
30
|
-
|
|
31
|
-
export default async function ProtectedPage() {
|
|
32
|
-
const { userId } = await auth();
|
|
33
|
-
if (!userId) redirect('/sign-in');
|
|
34
|
-
|
|
35
|
-
return <Dashboard />;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Client Component hook
|
|
39
|
-
'use client';
|
|
40
|
-
import { useAuth, useUser } from '@clerk/nextjs';
|
|
41
|
-
|
|
42
|
-
export function UserProfile() {
|
|
43
|
-
const { isLoaded, userId } = useAuth();
|
|
44
|
-
const { user } = useUser();
|
|
45
|
-
|
|
46
|
-
if (!isLoaded) return <Skeleton />;
|
|
47
|
-
if (!userId) return <SignInButton />;
|
|
48
|
-
|
|
49
|
-
return <div>Hello, {user?.firstName}</div>;
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
#### NextAuth.js
|
|
54
|
-
```typescript
|
|
55
|
-
// app/api/auth/[...nextauth]/route.ts
|
|
56
|
-
import NextAuth from 'next-auth';
|
|
57
|
-
import GitHub from 'next-auth/providers/github';
|
|
58
|
-
import Google from 'next-auth/providers/google';
|
|
59
|
-
import Credentials from 'next-auth/providers/credentials';
|
|
60
|
-
|
|
61
|
-
export const { handlers, signIn, signOut, auth } = NextAuth({
|
|
62
|
-
providers: [
|
|
63
|
-
GitHub,
|
|
64
|
-
Google,
|
|
65
|
-
Credentials({
|
|
66
|
-
credentials: {
|
|
67
|
-
email: { label: 'Email', type: 'email' },
|
|
68
|
-
password: { label: 'Password', type: 'password' }
|
|
69
|
-
},
|
|
70
|
-
async authorize(credentials) {
|
|
71
|
-
// Validate credentials against database
|
|
72
|
-
const user = await validateUser(credentials);
|
|
73
|
-
return user;
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
],
|
|
77
|
-
callbacks: {
|
|
78
|
-
async jwt({ token, user }) {
|
|
79
|
-
if (user) {
|
|
80
|
-
token.role = user.role;
|
|
81
|
-
}
|
|
82
|
-
return token;
|
|
83
|
-
},
|
|
84
|
-
async session({ session, token }) {
|
|
85
|
-
session.user.role = token.role;
|
|
86
|
-
return session;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
export const { GET, POST } = handlers;
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Authorization & RBAC
|
|
95
|
-
|
|
96
|
-
```typescript
|
|
97
|
-
// Role-based access control
|
|
98
|
-
type Role = 'user' | 'admin' | 'superadmin';
|
|
99
|
-
|
|
100
|
-
const PERMISSIONS = {
|
|
101
|
-
user: ['read:own', 'write:own'],
|
|
102
|
-
admin: ['read:all', 'write:all', 'delete:own'],
|
|
103
|
-
superadmin: ['read:all', 'write:all', 'delete:all', 'admin:users']
|
|
104
|
-
} as const;
|
|
105
|
-
|
|
106
|
-
function hasPermission(role: Role, permission: string): boolean {
|
|
107
|
-
return PERMISSIONS[role]?.includes(permission) ?? false;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Server Action with authorization
|
|
111
|
-
async function deleteUser(userId: string) {
|
|
112
|
-
const session = await auth();
|
|
113
|
-
if (!session?.user) throw new Error('Unauthorized');
|
|
114
|
-
|
|
115
|
-
const canDelete = hasPermission(session.user.role, 'delete:all') ||
|
|
116
|
-
(hasPermission(session.user.role, 'delete:own') && session.user.id === userId);
|
|
117
|
-
|
|
118
|
-
if (!canDelete) throw new Error('Forbidden');
|
|
119
|
-
|
|
120
|
-
await prisma.user.delete({ where: { id: userId } });
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### Input Validation & Sanitization
|
|
125
|
-
|
|
126
|
-
```typescript
|
|
127
|
-
import { z } from 'zod';
|
|
128
|
-
import DOMPurify from 'isomorphic-dompurify';
|
|
129
|
-
|
|
130
|
-
// Zod schema for validation
|
|
131
|
-
const UserInputSchema = z.object({
|
|
132
|
-
email: z.string().email().max(255),
|
|
133
|
-
name: z.string().min(1).max(100).transform(s => s.trim()),
|
|
134
|
-
bio: z.string().max(1000).optional().transform(s =>
|
|
135
|
-
s ? DOMPurify.sanitize(s) : s
|
|
136
|
-
),
|
|
137
|
-
website: z.string().url().optional().or(z.literal('')),
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// Usage in Server Action
|
|
141
|
-
export async function updateProfile(formData: FormData) {
|
|
142
|
-
const result = UserInputSchema.safeParse({
|
|
143
|
-
email: formData.get('email'),
|
|
144
|
-
name: formData.get('name'),
|
|
145
|
-
bio: formData.get('bio'),
|
|
146
|
-
website: formData.get('website'),
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
if (!result.success) {
|
|
150
|
-
return { error: result.error.flatten() };
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Safe to use result.data
|
|
154
|
-
await prisma.user.update({
|
|
155
|
-
where: { id: userId },
|
|
156
|
-
data: result.data
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### OWASP Top 10 Protection
|
|
162
|
-
|
|
163
|
-
#### 1. Injection Prevention
|
|
164
|
-
```typescript
|
|
165
|
-
// ALWAYS use parameterized queries
|
|
166
|
-
// Bad: SQL injection vulnerable
|
|
167
|
-
const result = await db.query(`SELECT * FROM users WHERE id = '${userId}'`);
|
|
168
|
-
|
|
169
|
-
// Good: Parameterized
|
|
170
|
-
const result = await prisma.user.findUnique({ where: { id: userId } });
|
|
171
|
-
|
|
172
|
-
// For raw queries, use parameters
|
|
173
|
-
const result = await prisma.$queryRaw`SELECT * FROM users WHERE id = ${userId}`;
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
#### 2. XSS Prevention
|
|
177
|
-
```typescript
|
|
178
|
-
// React escapes by default, but be careful with:
|
|
179
|
-
// Bad: dangerouslySetInnerHTML without sanitization
|
|
180
|
-
<div dangerouslySetInnerHTML={{ __html: userContent }} />
|
|
181
|
-
|
|
182
|
-
// Good: Sanitize first
|
|
183
|
-
import DOMPurify from 'isomorphic-dompurify';
|
|
184
|
-
<div dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(userContent) }} />
|
|
185
|
-
|
|
186
|
-
// Better: Use markdown library with sanitization
|
|
187
|
-
import { marked } from 'marked';
|
|
188
|
-
const html = DOMPurify.sanitize(marked.parse(userContent));
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
#### 3. CSRF Protection
|
|
192
|
-
```typescript
|
|
193
|
-
// Next.js Server Actions have built-in CSRF protection
|
|
194
|
-
// For API routes, verify origin
|
|
195
|
-
export async function POST(req: Request) {
|
|
196
|
-
const origin = req.headers.get('origin');
|
|
197
|
-
const allowedOrigins = [process.env.NEXT_PUBLIC_APP_URL];
|
|
198
|
-
|
|
199
|
-
if (!origin || !allowedOrigins.includes(origin)) {
|
|
200
|
-
return new Response('Forbidden', { status: 403 });
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
#### 4. Security Headers
|
|
206
|
-
```typescript
|
|
207
|
-
// next.config.js
|
|
208
|
-
const securityHeaders = [
|
|
209
|
-
{
|
|
210
|
-
key: 'X-DNS-Prefetch-Control',
|
|
211
|
-
value: 'on'
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
key: 'Strict-Transport-Security',
|
|
215
|
-
value: 'max-age=63072000; includeSubDomains; preload'
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
key: 'X-Frame-Options',
|
|
219
|
-
value: 'SAMEORIGIN'
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
key: 'X-Content-Type-Options',
|
|
223
|
-
value: 'nosniff'
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
key: 'Referrer-Policy',
|
|
227
|
-
value: 'origin-when-cross-origin'
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
key: 'Content-Security-Policy',
|
|
231
|
-
value: "default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline';"
|
|
232
|
-
}
|
|
233
|
-
];
|
|
234
|
-
|
|
235
|
-
module.exports = {
|
|
236
|
-
async headers() {
|
|
237
|
-
return [{ source: '/(.*)', headers: securityHeaders }];
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
### Rate Limiting
|
|
243
|
-
|
|
244
|
-
```typescript
|
|
245
|
-
import { Ratelimit } from '@upstash/ratelimit';
|
|
246
|
-
import { Redis } from '@upstash/redis';
|
|
247
|
-
|
|
248
|
-
const ratelimit = new Ratelimit({
|
|
249
|
-
redis: Redis.fromEnv(),
|
|
250
|
-
limiter: Ratelimit.slidingWindow(10, '10 s'), // 10 requests per 10 seconds
|
|
251
|
-
analytics: true,
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
export async function POST(req: Request) {
|
|
255
|
-
const ip = req.headers.get('x-forwarded-for') ?? 'anonymous';
|
|
256
|
-
const { success, limit, reset, remaining } = await ratelimit.limit(ip);
|
|
257
|
-
|
|
258
|
-
if (!success) {
|
|
259
|
-
return new Response('Too Many Requests', {
|
|
260
|
-
status: 429,
|
|
261
|
-
headers: {
|
|
262
|
-
'X-RateLimit-Limit': limit.toString(),
|
|
263
|
-
'X-RateLimit-Remaining': remaining.toString(),
|
|
264
|
-
'X-RateLimit-Reset': reset.toString(),
|
|
265
|
-
},
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// Process request
|
|
270
|
-
}
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
### Secure Session Management
|
|
274
|
-
|
|
275
|
-
```typescript
|
|
276
|
-
// Session configuration best practices
|
|
277
|
-
const sessionConfig = {
|
|
278
|
-
// Use HTTP-only cookies
|
|
279
|
-
httpOnly: true,
|
|
280
|
-
// Secure in production
|
|
281
|
-
secure: process.env.NODE_ENV === 'production',
|
|
282
|
-
// SameSite protection
|
|
283
|
-
sameSite: 'lax' as const,
|
|
284
|
-
// Reasonable expiration
|
|
285
|
-
maxAge: 60 * 60 * 24 * 7, // 1 week
|
|
286
|
-
// Path restriction
|
|
287
|
-
path: '/',
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
// Implement session rotation on privilege escalation
|
|
291
|
-
async function onLogin(userId: string) {
|
|
292
|
-
// Invalidate old session
|
|
293
|
-
await invalidateUserSessions(userId);
|
|
294
|
-
// Create new session
|
|
295
|
-
return createSession(userId);
|
|
296
|
-
}
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
### Secrets Management
|
|
300
|
-
|
|
301
|
-
```typescript
|
|
302
|
-
// Never commit secrets
|
|
303
|
-
// .env.local (gitignored)
|
|
304
|
-
DATABASE_URL="postgresql://..."
|
|
305
|
-
CLERK_SECRET_KEY="sk_live_..."
|
|
306
|
-
|
|
307
|
-
// Validate env vars at startup
|
|
308
|
-
const requiredEnvVars = [
|
|
309
|
-
'DATABASE_URL',
|
|
310
|
-
'CLERK_SECRET_KEY',
|
|
311
|
-
'STRIPE_SECRET_KEY',
|
|
312
|
-
];
|
|
313
|
-
|
|
314
|
-
for (const envVar of requiredEnvVars) {
|
|
315
|
-
if (!process.env[envVar]) {
|
|
316
|
-
throw new Error(`Missing required env var: ${envVar}`);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// Never expose server secrets to client
|
|
321
|
-
// Bad: NEXT_PUBLIC_STRIPE_SECRET_KEY
|
|
322
|
-
// Good: STRIPE_SECRET_KEY (server only)
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
## Security Checklist
|
|
326
|
-
|
|
327
|
-
- [ ] All user input validated with Zod
|
|
328
|
-
- [ ] HTML content sanitized before rendering
|
|
329
|
-
- [ ] Parameterized queries used (no string interpolation)
|
|
330
|
-
- [ ] Authentication required for protected routes
|
|
331
|
-
- [ ] Authorization checks on all mutations
|
|
332
|
-
- [ ] Rate limiting on authentication endpoints
|
|
333
|
-
- [ ] CSRF protection enabled
|
|
334
|
-
- [ ] Security headers configured
|
|
335
|
-
- [ ] HTTPS enforced in production
|
|
336
|
-
- [ ] Secrets stored in environment variables
|
|
337
|
-
- [ ] No secrets in git history
|
|
338
|
-
- [ ] Session rotation on authentication
|
|
339
|
-
- [ ] Password hashing with bcrypt/argon2
|
|
340
|
-
- [ ] Audit logging for sensitive actions
|
|
341
|
-
|
|
342
|
-
## Trigger Keywords
|
|
343
|
-
security, auth, login, signup, password, jwt, session, csrf, xss, owasp, injection, rate limit, validation, sanitize, encrypt, hash, permission, role, rbac, vulnerability, attack, protect
|