@smicolon/ai-kit 0.3.1 → 0.4.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.
Files changed (156) hide show
  1. package/README.md +73 -40
  2. package/dist/index.js +260 -126
  3. package/package.json +5 -5
  4. package/.claude-plugin/marketplace.json +0 -373
  5. package/packs/architect/CHANGELOG.md +0 -17
  6. package/packs/architect/README.md +0 -58
  7. package/packs/architect/agents/system-architect.md +0 -768
  8. package/packs/architect/commands/diagram-create.md +0 -300
  9. package/packs/better-auth/.mcp.json +0 -14
  10. package/packs/better-auth/CHANGELOG.md +0 -26
  11. package/packs/better-auth/README.md +0 -125
  12. package/packs/better-auth/agents/auth-architect.md +0 -278
  13. package/packs/better-auth/commands/auth-provider-add.md +0 -265
  14. package/packs/better-auth/commands/auth-setup.md +0 -298
  15. package/packs/better-auth/skills/auth-security/SKILL.md +0 -425
  16. package/packs/better-auth/skills/better-auth-patterns/SKILL.md +0 -455
  17. package/packs/dev-loop/CHANGELOG.md +0 -69
  18. package/packs/dev-loop/README.md +0 -155
  19. package/packs/dev-loop/commands/cancel-dev.md +0 -21
  20. package/packs/dev-loop/commands/dev-loop.md +0 -72
  21. package/packs/dev-loop/commands/dev-plan.md +0 -351
  22. package/packs/dev-loop/hooks/hooks.json +0 -15
  23. package/packs/dev-loop/hooks/stop-hook.sh +0 -178
  24. package/packs/dev-loop/scripts/setup-dev-loop.sh +0 -194
  25. package/packs/dev-loop/skills/tdd-planner/SKILL.md +0 -249
  26. package/packs/dev-loop/skills/tdd-planner/references/framework-patterns.md +0 -874
  27. package/packs/dev-loop/skills/tdd-planner/references/good-example.md +0 -260
  28. package/packs/dev-loop/skills/tdd-planner/references/plan-template.md +0 -275
  29. package/packs/django/CHANGELOG.md +0 -39
  30. package/packs/django/README.md +0 -92
  31. package/packs/django/agents/django-architect.md +0 -182
  32. package/packs/django/agents/django-builder.md +0 -250
  33. package/packs/django/agents/django-feature-based.md +0 -420
  34. package/packs/django/agents/django-reviewer.md +0 -253
  35. package/packs/django/agents/django-tester.md +0 -230
  36. package/packs/django/commands/api-endpoint.md +0 -285
  37. package/packs/django/commands/model-create.md +0 -178
  38. package/packs/django/commands/test-generate.md +0 -325
  39. package/packs/django/rules/migrations.md +0 -138
  40. package/packs/django/rules/models.md +0 -167
  41. package/packs/django/rules/serializers.md +0 -126
  42. package/packs/django/rules/services.md +0 -131
  43. package/packs/django/rules/tests.md +0 -140
  44. package/packs/django/rules/views.md +0 -102
  45. package/packs/django/skills/import-convention-enforcer/SKILL.md +0 -226
  46. package/packs/django/skills/import-convention-enforcer/patterns/django-imports.md +0 -343
  47. package/packs/django/skills/migration-safety-checker/SKILL.md +0 -375
  48. package/packs/django/skills/model-entity-validator/SKILL.md +0 -298
  49. package/packs/django/skills/performance-optimizer/SKILL.md +0 -447
  50. package/packs/django/skills/red-phase-verifier/SKILL.md +0 -180
  51. package/packs/django/skills/security-first-validator/SKILL.md +0 -435
  52. package/packs/django/skills/test-coverage-advisor/SKILL.md +0 -394
  53. package/packs/django/skills/test-validity-checker/SKILL.md +0 -194
  54. package/packs/failure-log/CHANGELOG.md +0 -20
  55. package/packs/failure-log/README.md +0 -168
  56. package/packs/failure-log/commands/failure-add.md +0 -106
  57. package/packs/failure-log/commands/failure-list.md +0 -89
  58. package/packs/failure-log/hooks/hooks.json +0 -16
  59. package/packs/failure-log/hooks/scripts/inject-failures.sh +0 -64
  60. package/packs/failure-log/skills/failure-log-manager/SKILL.md +0 -164
  61. package/packs/flutter/CHANGELOG.md +0 -19
  62. package/packs/flutter/README.md +0 -170
  63. package/packs/flutter/agents/flutter-architect.md +0 -166
  64. package/packs/flutter/agents/flutter-builder.md +0 -303
  65. package/packs/flutter/agents/release-manager.md +0 -355
  66. package/packs/flutter/commands/fastlane-setup.md +0 -188
  67. package/packs/flutter/commands/flutter-build.md +0 -90
  68. package/packs/flutter/commands/flutter-deploy.md +0 -133
  69. package/packs/flutter/commands/flutter-test.md +0 -117
  70. package/packs/flutter/commands/signing-setup.md +0 -209
  71. package/packs/flutter/hooks/hooks.json +0 -17
  72. package/packs/flutter/skills/fastlane-knowledge/SKILL.md +0 -193
  73. package/packs/flutter/skills/flutter-architecture/SKILL.md +0 -127
  74. package/packs/flutter/skills/store-publishing/SKILL.md +0 -163
  75. package/packs/hono/CHANGELOG.md +0 -19
  76. package/packs/hono/README.md +0 -143
  77. package/packs/hono/agents/hono-architect.md +0 -240
  78. package/packs/hono/agents/hono-builder.md +0 -285
  79. package/packs/hono/agents/hono-reviewer.md +0 -279
  80. package/packs/hono/agents/hono-tester.md +0 -346
  81. package/packs/hono/commands/middleware-create.md +0 -223
  82. package/packs/hono/commands/project-init.md +0 -306
  83. package/packs/hono/commands/route-create.md +0 -153
  84. package/packs/hono/commands/rpc-client.md +0 -263
  85. package/packs/hono/hooks/hooks.json +0 -4
  86. package/packs/hono/skills/cloudflare-bindings/SKILL.md +0 -408
  87. package/packs/hono/skills/hono-patterns/SKILL.md +0 -309
  88. package/packs/hono/skills/rpc-typesafe/SKILL.md +0 -388
  89. package/packs/hono/skills/zod-validation/SKILL.md +0 -332
  90. package/packs/nestjs/CHANGELOG.md +0 -29
  91. package/packs/nestjs/README.md +0 -75
  92. package/packs/nestjs/agents/nestjs-architect.md +0 -402
  93. package/packs/nestjs/agents/nestjs-builder.md +0 -301
  94. package/packs/nestjs/agents/nestjs-tester.md +0 -437
  95. package/packs/nestjs/commands/module-create.md +0 -369
  96. package/packs/nestjs/rules/controllers.md +0 -92
  97. package/packs/nestjs/rules/dto.md +0 -124
  98. package/packs/nestjs/rules/entities.md +0 -102
  99. package/packs/nestjs/rules/services.md +0 -106
  100. package/packs/nestjs/skills/barrel-export-manager/SKILL.md +0 -389
  101. package/packs/nestjs/skills/import-convention-enforcer/SKILL.md +0 -365
  102. package/packs/nextjs/CHANGELOG.md +0 -36
  103. package/packs/nextjs/README.md +0 -76
  104. package/packs/nextjs/agents/frontend-tester.md +0 -680
  105. package/packs/nextjs/agents/frontend-visual.md +0 -820
  106. package/packs/nextjs/agents/nextjs-architect.md +0 -331
  107. package/packs/nextjs/agents/nextjs-modular.md +0 -433
  108. package/packs/nextjs/commands/component-create.md +0 -398
  109. package/packs/nextjs/rules/api-routes.md +0 -129
  110. package/packs/nextjs/rules/components.md +0 -106
  111. package/packs/nextjs/rules/hooks.md +0 -132
  112. package/packs/nextjs/skills/accessibility-validator/SKILL.md +0 -445
  113. package/packs/nextjs/skills/import-convention-enforcer/SKILL.md +0 -399
  114. package/packs/nextjs/skills/react-form-validator/SKILL.md +0 -569
  115. package/packs/nuxtjs/CHANGELOG.md +0 -30
  116. package/packs/nuxtjs/README.md +0 -56
  117. package/packs/nuxtjs/agents/frontend-tester.md +0 -680
  118. package/packs/nuxtjs/agents/frontend-visual.md +0 -820
  119. package/packs/nuxtjs/agents/nuxtjs-architect.md +0 -537
  120. package/packs/nuxtjs/commands/component-create.md +0 -223
  121. package/packs/nuxtjs/rules/components.md +0 -101
  122. package/packs/nuxtjs/rules/composables.md +0 -118
  123. package/packs/nuxtjs/rules/server-routes.md +0 -127
  124. package/packs/nuxtjs/skills/accessibility-validator/SKILL.md +0 -183
  125. package/packs/nuxtjs/skills/import-convention-enforcer/SKILL.md +0 -196
  126. package/packs/nuxtjs/skills/veevalidate-form-validator/SKILL.md +0 -190
  127. package/packs/onboard/CHANGELOG.md +0 -22
  128. package/packs/onboard/README.md +0 -103
  129. package/packs/onboard/agents/onboard-guide.md +0 -118
  130. package/packs/onboard/commands/onboard.md +0 -313
  131. package/packs/onboard/skills/onboard-context-provider/SKILL.md +0 -98
  132. package/packs/tanstack-router/CHANGELOG.md +0 -30
  133. package/packs/tanstack-router/README.md +0 -113
  134. package/packs/tanstack-router/agents/tanstack-architect.md +0 -173
  135. package/packs/tanstack-router/agents/tanstack-builder.md +0 -360
  136. package/packs/tanstack-router/agents/tanstack-tester.md +0 -454
  137. package/packs/tanstack-router/commands/form-create.md +0 -313
  138. package/packs/tanstack-router/commands/query-create.md +0 -263
  139. package/packs/tanstack-router/commands/route-create.md +0 -190
  140. package/packs/tanstack-router/commands/table-create.md +0 -413
  141. package/packs/tanstack-router/skills/ai-patterns/SKILL.md +0 -370
  142. package/packs/tanstack-router/skills/db-patterns/SKILL.md +0 -346
  143. package/packs/tanstack-router/skills/devtools-patterns/SKILL.md +0 -415
  144. package/packs/tanstack-router/skills/form-patterns/SKILL.md +0 -425
  145. package/packs/tanstack-router/skills/pacer-patterns/SKILL.md +0 -341
  146. package/packs/tanstack-router/skills/query-patterns/SKILL.md +0 -359
  147. package/packs/tanstack-router/skills/router-patterns/SKILL.md +0 -285
  148. package/packs/tanstack-router/skills/store-patterns/SKILL.md +0 -351
  149. package/packs/tanstack-router/skills/table-patterns/SKILL.md +0 -531
  150. package/packs/tanstack-router/skills/tanstack-conventions/SKILL.md +0 -428
  151. package/packs/tanstack-router/skills/virtual-patterns/SKILL.md +0 -490
  152. package/packs/worktree/CHANGELOG.md +0 -45
  153. package/packs/worktree/README.md +0 -219
  154. package/packs/worktree/commands/wt.md +0 -93
  155. package/packs/worktree/scripts/wt.sh +0 -957
  156. package/packs/worktree/skills/worktree-manager/SKILL.md +0 -113
@@ -1,278 +0,0 @@
1
- ---
2
- description: >-
3
- Authentication architect for designing Better Auth implementations. Use for
4
- auth architecture, provider setup, security flows, and enterprise auth patterns.
5
- tools: ["Read", "Glob", "Grep", "WebFetch", "WebSearch", "Write", "Edit", "Bash", "Task", "TodoWrite"]
6
- ---
7
-
8
- # Auth Architect
9
-
10
- You are a senior authentication architect specializing in Better Auth implementations. Design secure, scalable authentication systems for React applications.
11
-
12
- ## Better Auth Overview
13
-
14
- Better Auth is a framework-agnostic TypeScript authentication library that provides:
15
-
16
- - **Core Authentication**: Email/password, sessions, password reset
17
- - **Social Providers**: OAuth 2.0/OIDC (Google, GitHub, Discord, etc.)
18
- - **Advanced Security**: 2FA, passkeys/WebAuthn, rate limiting
19
- - **Enterprise**: Multi-tenancy, SSO, organization management
20
-
21
- ## Architecture Patterns
22
-
23
- ### Basic Setup Structure
24
- ```
25
- src/
26
- ├── lib/
27
- │ └── auth.ts # Better Auth server instance
28
- ├── auth/
29
- │ ├── client.ts # Auth client for React
30
- │ └── hooks.ts # Custom auth hooks
31
- ├── routes/
32
- │ ├── __root.tsx # Auth context in router
33
- │ ├── _auth.tsx # Protected route layout
34
- │ ├── _auth.dashboard.tsx # Protected pages
35
- │ ├── login.tsx
36
- │ ├── register.tsx
37
- │ └── forgot-password.tsx
38
- └── features/
39
- └── auth/
40
- ├── components/
41
- │ ├── LoginForm.tsx
42
- │ ├── RegisterForm.tsx
43
- │ ├── SocialLoginButtons.tsx
44
- │ └── TwoFactorForm.tsx
45
- └── types.ts
46
- ```
47
-
48
- ### Server Configuration
49
- ```typescript
50
- // lib/auth.ts
51
- import { betterAuth } from 'better-auth'
52
- import { prismaAdapter } from 'better-auth/adapters/prisma'
53
- import { twoFactor } from 'better-auth/plugins/two-factor'
54
- import { passkey } from 'better-auth/plugins/passkey'
55
- import { organization } from 'better-auth/plugins/organization'
56
- import { prisma } from './prisma'
57
-
58
- export const auth = betterAuth({
59
- database: prismaAdapter(prisma, {
60
- provider: 'postgresql',
61
- }),
62
-
63
- emailAndPassword: {
64
- enabled: true,
65
- requireEmailVerification: true,
66
- sendResetPasswordToken: async (user, url) => {
67
- await sendEmail({
68
- to: user.email,
69
- subject: 'Reset your password',
70
- html: `<a href="${url}">Reset password</a>`,
71
- })
72
- },
73
- },
74
-
75
- session: {
76
- expiresIn: 60 * 60 * 24 * 7, // 7 days
77
- updateAge: 60 * 60 * 24, // 1 day
78
- cookieCache: {
79
- enabled: true,
80
- maxAge: 60 * 5, // 5 minutes
81
- },
82
- },
83
-
84
- socialProviders: {
85
- google: {
86
- clientId: process.env.GOOGLE_CLIENT_ID!,
87
- clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
88
- },
89
- github: {
90
- clientId: process.env.GITHUB_CLIENT_ID!,
91
- clientSecret: process.env.GITHUB_CLIENT_SECRET!,
92
- },
93
- },
94
-
95
- plugins: [
96
- twoFactor({
97
- issuer: 'MyApp',
98
- }),
99
- passkey(),
100
- organization(),
101
- ],
102
- })
103
-
104
- export type Auth = typeof auth
105
- ```
106
-
107
- ### Client Configuration
108
- ```typescript
109
- // auth/client.ts
110
- import { createAuthClient } from 'better-auth/react'
111
- import type { Auth } from '@/lib/auth'
112
-
113
- export const authClient = createAuthClient<Auth>({
114
- baseURL: import.meta.env.VITE_API_URL,
115
- })
116
-
117
- export const {
118
- signIn,
119
- signUp,
120
- signOut,
121
- useSession,
122
- getSession,
123
- // Social providers
124
- signInWithGoogle,
125
- signInWithGithub,
126
- // 2FA
127
- enable2FA,
128
- verify2FA,
129
- // Passkeys
130
- registerPasskey,
131
- signInWithPasskey,
132
- // Organization
133
- createOrganization,
134
- inviteMember,
135
- } = authClient
136
- ```
137
-
138
- ### Router Integration
139
- ```typescript
140
- // routes/__root.tsx
141
- import { createRootRouteWithContext, Outlet } from '@tanstack/react-router'
142
- import { getSession } from '@/auth/client'
143
- import type { QueryClient } from '@tanstack/react-query'
144
-
145
- interface RouterContext {
146
- queryClient: QueryClient
147
- session: Awaited<ReturnType<typeof getSession>> | null
148
- }
149
-
150
- export const Route = createRootRouteWithContext<RouterContext>()({
151
- beforeLoad: async () => {
152
- const session = await getSession()
153
- return { session }
154
- },
155
- component: RootComponent,
156
- })
157
- ```
158
-
159
- ### Protected Routes
160
- ```typescript
161
- // routes/_auth.tsx
162
- import { createFileRoute, Outlet, redirect } from '@tanstack/react-router'
163
-
164
- export const Route = createFileRoute('/_auth')({
165
- beforeLoad: async ({ context }) => {
166
- if (!context.session) {
167
- throw redirect({
168
- to: '/login',
169
- search: { redirect: location.pathname },
170
- })
171
- }
172
- },
173
- component: () => <Outlet />,
174
- })
175
- ```
176
-
177
- ## Security Considerations
178
-
179
- ### Password Requirements
180
- ```typescript
181
- emailAndPassword: {
182
- enabled: true,
183
- password: {
184
- minLength: 12,
185
- maxLength: 128,
186
- requireLowercase: true,
187
- requireUppercase: true,
188
- requireNumber: true,
189
- requireSpecialChar: true,
190
- },
191
- }
192
- ```
193
-
194
- ### Rate Limiting
195
- ```typescript
196
- import { rateLimit } from 'better-auth/plugins/rate-limit'
197
-
198
- plugins: [
199
- rateLimit({
200
- window: 60, // 1 minute
201
- max: 10, // 10 requests
202
- endpoints: {
203
- 'sign-in': { window: 300, max: 5 },
204
- 'sign-up': { window: 3600, max: 3 },
205
- },
206
- }),
207
- ]
208
- ```
209
-
210
- ### Session Security
211
- ```typescript
212
- session: {
213
- expiresIn: 60 * 60 * 24 * 7, // 7 days
214
- updateAge: 60 * 60 * 24, // Extend daily
215
- cookieCache: {
216
- enabled: true,
217
- maxAge: 60 * 5, // Cache for 5 minutes
218
- },
219
- // Require re-auth for sensitive operations
220
- freshAge: 60 * 10, // 10 minutes
221
- }
222
- ```
223
-
224
- ## Enterprise Patterns
225
-
226
- ### Multi-Tenancy
227
- ```typescript
228
- import { organization } from 'better-auth/plugins/organization'
229
-
230
- plugins: [
231
- organization({
232
- roles: ['owner', 'admin', 'member'],
233
- permissions: {
234
- owner: ['*'],
235
- admin: ['read', 'write', 'invite'],
236
- member: ['read'],
237
- },
238
- inviteOnly: true,
239
- maxOrganizations: 5,
240
- }),
241
- ]
242
- ```
243
-
244
- ### SSO with SAML
245
- ```typescript
246
- import { samlSSO } from 'better-auth/plugins/saml'
247
-
248
- plugins: [
249
- samlSSO({
250
- certificate: process.env.SAML_CERTIFICATE,
251
- privateKey: process.env.SAML_PRIVATE_KEY,
252
- issuer: 'https://myapp.com',
253
- callbackUrl: 'https://myapp.com/auth/saml/callback',
254
- }),
255
- ]
256
- ```
257
-
258
- ## Design Deliverables
259
-
260
- When designing auth architecture, provide:
261
-
262
- 1. **Auth Configuration** - Complete Better Auth config
263
- 2. **Provider Setup** - Social provider configurations
264
- 3. **Route Structure** - Protected and public routes
265
- 4. **Component Hierarchy** - Auth forms and flows
266
- 5. **Security Measures** - Rate limiting, 2FA, session config
267
- 6. **Database Schema** - Auth-related tables
268
-
269
- ## Questions to Ask
270
-
271
- Before designing, clarify:
272
-
273
- 1. What authentication methods are needed? (email, social, SSO)
274
- 2. Is 2FA or passkey support required?
275
- 3. Multi-tenancy or organization support?
276
- 4. Session duration and refresh strategy?
277
- 5. Email verification requirements?
278
- 6. Password policy requirements?
@@ -1,265 +0,0 @@
1
- ---
2
- name: auth-provider-add
3
- description: Add a new authentication provider to Better Auth
4
- args:
5
- - name: provider
6
- description: Provider name (google, github, discord, apple, microsoft, etc.)
7
- required: false
8
- - name: scopes
9
- description: Comma-separated OAuth scopes (e.g., "user:email,read:org")
10
- required: false
11
- ---
12
-
13
- # Add Authentication Provider
14
-
15
- Add a new social/OAuth provider to your Better Auth configuration.
16
-
17
- ## Supported Providers
18
-
19
- - **google** - Google OAuth 2.0
20
- - **github** - GitHub OAuth
21
- - **discord** - Discord OAuth
22
- - **apple** - Apple Sign In
23
- - **microsoft** - Microsoft Identity
24
- - **twitter** - Twitter/X OAuth 2.0
25
- - **facebook** - Facebook Login
26
- - **linkedin** - LinkedIn OAuth
27
- - **gitlab** - GitLab OAuth
28
- - **slack** - Slack OAuth
29
-
30
- ## Instructions
31
-
32
- 1. **Get Provider Credentials**:
33
-
34
- **Google**:
35
- - Go to [Google Cloud Console](https://console.cloud.google.com/)
36
- - Create OAuth 2.0 credentials
37
- - Add authorized redirect URI: `{YOUR_API_URL}/api/auth/callback/google`
38
-
39
- **GitHub**:
40
- - Go to [GitHub Developer Settings](https://github.com/settings/developers)
41
- - Create new OAuth App
42
- - Set callback URL: `{YOUR_API_URL}/api/auth/callback/github`
43
-
44
- **Discord**:
45
- - Go to [Discord Developer Portal](https://discord.com/developers/applications)
46
- - Create application, get OAuth2 credentials
47
- - Add redirect: `{YOUR_API_URL}/api/auth/callback/discord`
48
-
49
- **Apple**:
50
- - Go to [Apple Developer](https://developer.apple.com/)
51
- - Create Service ID with Sign In with Apple capability
52
- - Configure return URL: `{YOUR_API_URL}/api/auth/callback/apple`
53
-
54
- **Microsoft**:
55
- - Go to [Azure Portal](https://portal.azure.com/)
56
- - Register application in Azure AD
57
- - Add redirect URI: `{YOUR_API_URL}/api/auth/callback/microsoft`
58
-
59
- 2. **Add Environment Variables** to `.env`:
60
- ```bash
61
- # Google
62
- GOOGLE_CLIENT_ID=your-client-id
63
- GOOGLE_CLIENT_SECRET=your-client-secret
64
-
65
- # GitHub
66
- GITHUB_CLIENT_ID=your-client-id
67
- GITHUB_CLIENT_SECRET=your-client-secret
68
-
69
- # Discord
70
- DISCORD_CLIENT_ID=your-client-id
71
- DISCORD_CLIENT_SECRET=your-client-secret
72
-
73
- # Apple
74
- APPLE_CLIENT_ID=your-service-id
75
- APPLE_CLIENT_SECRET=your-client-secret
76
- APPLE_TEAM_ID=your-team-id
77
- APPLE_KEY_ID=your-key-id
78
-
79
- # Microsoft
80
- MICROSOFT_CLIENT_ID=your-client-id
81
- MICROSOFT_CLIENT_SECRET=your-client-secret
82
- MICROSOFT_TENANT_ID=your-tenant-id
83
- ```
84
-
85
- 3. **Update Server Configuration** in `src/lib/auth.ts`:
86
-
87
- **Google**:
88
- ```typescript
89
- socialProviders: {
90
- google: {
91
- clientId: process.env.GOOGLE_CLIENT_ID!,
92
- clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
93
- scopes: ['email', 'profile'],
94
- // Optional: Force account selection
95
- prompt: 'select_account',
96
- },
97
- }
98
- ```
99
-
100
- **GitHub**:
101
- ```typescript
102
- socialProviders: {
103
- github: {
104
- clientId: process.env.GITHUB_CLIENT_ID!,
105
- clientSecret: process.env.GITHUB_CLIENT_SECRET!,
106
- scopes: ['user:email', 'read:user'],
107
- // Optional: Request additional scopes
108
- // scopes: ['user:email', 'read:user', 'read:org'],
109
- },
110
- }
111
- ```
112
-
113
- **Discord**:
114
- ```typescript
115
- socialProviders: {
116
- discord: {
117
- clientId: process.env.DISCORD_CLIENT_ID!,
118
- clientSecret: process.env.DISCORD_CLIENT_SECRET!,
119
- scopes: ['identify', 'email'],
120
- // Optional: Guild-specific
121
- // scopes: ['identify', 'email', 'guilds'],
122
- },
123
- }
124
- ```
125
-
126
- **Apple**:
127
- ```typescript
128
- socialProviders: {
129
- apple: {
130
- clientId: process.env.APPLE_CLIENT_ID!,
131
- clientSecret: process.env.APPLE_CLIENT_SECRET!,
132
- teamId: process.env.APPLE_TEAM_ID!,
133
- keyId: process.env.APPLE_KEY_ID!,
134
- },
135
- }
136
- ```
137
-
138
- **Microsoft**:
139
- ```typescript
140
- socialProviders: {
141
- microsoft: {
142
- clientId: process.env.MICROSOFT_CLIENT_ID!,
143
- clientSecret: process.env.MICROSOFT_CLIENT_SECRET!,
144
- tenantId: process.env.MICROSOFT_TENANT_ID!, // or 'common' for multi-tenant
145
- scopes: ['openid', 'profile', 'email'],
146
- },
147
- }
148
- ```
149
-
150
- 4. **Update Auth Client** in `src/auth/client.ts`:
151
- ```typescript
152
- export const {
153
- // ... existing exports
154
- signInWithGoogle,
155
- signInWithGithub,
156
- signInWithDiscord,
157
- signInWithApple,
158
- signInWithMicrosoft,
159
- } = authClient
160
- ```
161
-
162
- 5. **Create/Update Social Login Buttons** in `src/features/auth/components/SocialLoginButtons.tsx`:
163
- ```typescript
164
- import {
165
- signInWithGoogle,
166
- signInWithGithub,
167
- signInWithDiscord,
168
- } from '@/auth/client'
169
-
170
- interface SocialLoginButtonsProps {
171
- callbackURL?: string
172
- }
173
-
174
- export function SocialLoginButtons({ callbackURL = '/dashboard' }: SocialLoginButtonsProps) {
175
- const handleGoogle = async () => {
176
- await signInWithGoogle({ callbackURL })
177
- }
178
-
179
- const handleGithub = async () => {
180
- await signInWithGithub({ callbackURL })
181
- }
182
-
183
- const handleDiscord = async () => {
184
- await signInWithDiscord({ callbackURL })
185
- }
186
-
187
- return (
188
- <div className="flex flex-col gap-3">
189
- <button
190
- onClick={handleGoogle}
191
- className="flex items-center justify-center gap-2 w-full p-3 border rounded-lg hover:bg-gray-50"
192
- >
193
- <svg className="w-5 h-5" viewBox="0 0 24 24">
194
- {/* Google icon SVG */}
195
- </svg>
196
- Continue with Google
197
- </button>
198
-
199
- <button
200
- onClick={handleGithub}
201
- className="flex items-center justify-center gap-2 w-full p-3 border rounded-lg hover:bg-gray-50"
202
- >
203
- <svg className="w-5 h-5" viewBox="0 0 24 24">
204
- {/* GitHub icon SVG */}
205
- </svg>
206
- Continue with GitHub
207
- </button>
208
-
209
- <button
210
- onClick={handleDiscord}
211
- className="flex items-center justify-center gap-2 w-full p-3 border rounded-lg hover:bg-gray-50"
212
- >
213
- <svg className="w-5 h-5" viewBox="0 0 24 24">
214
- {/* Discord icon SVG */}
215
- </svg>
216
- Continue with Discord
217
- </button>
218
- </div>
219
- )
220
- }
221
- ```
222
-
223
- 6. **Handle Provider Callback** (if custom handling needed):
224
- ```typescript
225
- // In your server/API routes
226
- export const auth = betterAuth({
227
- socialProviders: {
228
- google: {
229
- // ...config
230
- onUserCreated: async (user, account) => {
231
- // Custom logic when user signs up via Google
232
- await sendWelcomeEmail(user.email)
233
- },
234
- onSignIn: async (user, account) => {
235
- // Custom logic on each sign in
236
- await updateLastLogin(user.id)
237
- },
238
- },
239
- },
240
- })
241
- ```
242
-
243
- ## Common Scopes Reference
244
-
245
- | Provider | Common Scopes |
246
- |----------|--------------|
247
- | Google | `email`, `profile`, `openid` |
248
- | GitHub | `user:email`, `read:user`, `read:org` |
249
- | Discord | `identify`, `email`, `guilds` |
250
- | Apple | (automatic: email, name) |
251
- | Microsoft | `openid`, `profile`, `email`, `User.Read` |
252
- | Twitter | `users.read`, `tweet.read` |
253
- | Facebook | `email`, `public_profile` |
254
- | LinkedIn | `r_emailaddress`, `r_liteprofile` |
255
-
256
- ## Quality Checklist
257
-
258
- - [ ] Provider credentials obtained from developer portal
259
- - [ ] Environment variables added to `.env`
260
- - [ ] Callback URL configured in provider dashboard
261
- - [ ] Provider added to `socialProviders` config
262
- - [ ] Client export added for `signInWith{Provider}`
263
- - [ ] Button added to SocialLoginButtons component
264
- - [ ] Scopes appropriate for app needs
265
- - [ ] Tested sign-in flow works correctly