workos 0.4.5 → 0.5.1

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 (147) hide show
  1. package/dist/bin.js +32 -3
  2. package/dist/bin.js.map +1 -1
  3. package/dist/commands/doctor.d.ts +10 -0
  4. package/dist/commands/doctor.js +30 -0
  5. package/dist/commands/doctor.js.map +1 -0
  6. package/dist/doctor/checks/connectivity.d.ts +2 -0
  7. package/dist/doctor/checks/connectivity.js +35 -0
  8. package/dist/doctor/checks/connectivity.js.map +1 -0
  9. package/dist/doctor/checks/dashboard.d.ts +3 -0
  10. package/dist/doctor/checks/dashboard.js +123 -0
  11. package/dist/doctor/checks/dashboard.js.map +1 -0
  12. package/dist/doctor/checks/environment.d.ts +2 -0
  13. package/dist/doctor/checks/environment.js +68 -0
  14. package/dist/doctor/checks/environment.js.map +1 -0
  15. package/dist/doctor/checks/framework.d.ts +2 -0
  16. package/dist/doctor/checks/framework.js +75 -0
  17. package/dist/doctor/checks/framework.js.map +1 -0
  18. package/dist/doctor/checks/runtime.d.ts +2 -0
  19. package/dist/doctor/checks/runtime.js +20 -0
  20. package/dist/doctor/checks/runtime.js.map +1 -0
  21. package/dist/doctor/checks/sdk.d.ts +2 -0
  22. package/dist/doctor/checks/sdk.js +111 -0
  23. package/dist/doctor/checks/sdk.js.map +1 -0
  24. package/dist/doctor/clipboard.d.ts +1 -0
  25. package/dist/doctor/clipboard.js +43 -0
  26. package/dist/doctor/clipboard.js.map +1 -0
  27. package/dist/doctor/index.d.ts +6 -0
  28. package/dist/doctor/index.js +94 -0
  29. package/dist/doctor/index.js.map +1 -0
  30. package/dist/doctor/issues.d.ts +58 -0
  31. package/dist/doctor/issues.js +134 -0
  32. package/dist/doctor/issues.js.map +1 -0
  33. package/dist/doctor/json-output.d.ts +2 -0
  34. package/dist/doctor/json-output.js +4 -0
  35. package/dist/doctor/json-output.js.map +1 -0
  36. package/dist/doctor/output.d.ts +5 -0
  37. package/dist/doctor/output.js +149 -0
  38. package/dist/doctor/output.js.map +1 -0
  39. package/dist/doctor/types.d.ts +105 -0
  40. package/dist/doctor/types.js +2 -0
  41. package/dist/doctor/types.js.map +1 -0
  42. package/dist/integrations/dotnet/index.d.ts +8 -0
  43. package/dist/integrations/dotnet/index.js +163 -0
  44. package/dist/integrations/dotnet/index.js.map +1 -0
  45. package/dist/integrations/elixir/index.d.ts +8 -0
  46. package/dist/integrations/elixir/index.js +152 -0
  47. package/dist/integrations/elixir/index.js.map +1 -0
  48. package/dist/integrations/go/index.d.ts +11 -0
  49. package/dist/integrations/go/index.js +220 -0
  50. package/dist/integrations/go/index.js.map +1 -0
  51. package/dist/integrations/kotlin/index.d.ts +4 -0
  52. package/dist/integrations/kotlin/index.js +53 -0
  53. package/dist/integrations/kotlin/index.js.map +1 -0
  54. package/dist/integrations/nextjs/index.d.ts +4 -0
  55. package/dist/integrations/nextjs/index.js +90 -0
  56. package/dist/integrations/nextjs/index.js.map +1 -0
  57. package/dist/integrations/nextjs/utils.d.ts +8 -0
  58. package/dist/integrations/nextjs/utils.js +53 -0
  59. package/dist/integrations/nextjs/utils.js.map +1 -0
  60. package/dist/integrations/node/index.d.ts +4 -0
  61. package/dist/integrations/node/index.js +52 -0
  62. package/dist/integrations/node/index.js.map +1 -0
  63. package/dist/integrations/php/index.d.ts +4 -0
  64. package/dist/integrations/php/index.js +51 -0
  65. package/dist/integrations/php/index.js.map +1 -0
  66. package/dist/integrations/php-laravel/index.d.ts +4 -0
  67. package/dist/integrations/php-laravel/index.js +51 -0
  68. package/dist/integrations/php-laravel/index.js.map +1 -0
  69. package/dist/integrations/python/index.d.ts +9 -0
  70. package/dist/integrations/python/index.js +254 -0
  71. package/dist/integrations/python/index.js.map +1 -0
  72. package/dist/integrations/react/index.d.ts +4 -0
  73. package/dist/integrations/react/index.js +49 -0
  74. package/dist/integrations/react/index.js.map +1 -0
  75. package/dist/integrations/react-router/index.d.ts +4 -0
  76. package/dist/integrations/react-router/index.js +94 -0
  77. package/dist/integrations/react-router/index.js.map +1 -0
  78. package/dist/integrations/react-router/utils.d.ts +10 -0
  79. package/dist/integrations/react-router/utils.js +146 -0
  80. package/dist/integrations/react-router/utils.js.map +1 -0
  81. package/dist/integrations/ruby/index.d.ts +8 -0
  82. package/dist/integrations/ruby/index.js +142 -0
  83. package/dist/integrations/ruby/index.js.map +1 -0
  84. package/dist/integrations/sveltekit/index.d.ts +4 -0
  85. package/dist/integrations/sveltekit/index.js +50 -0
  86. package/dist/integrations/sveltekit/index.js.map +1 -0
  87. package/dist/integrations/tanstack-start/index.d.ts +4 -0
  88. package/dist/integrations/tanstack-start/index.js +51 -0
  89. package/dist/integrations/tanstack-start/index.js.map +1 -0
  90. package/dist/integrations/vanilla-js/index.d.ts +4 -0
  91. package/dist/integrations/vanilla-js/index.js +49 -0
  92. package/dist/integrations/vanilla-js/index.js.map +1 -0
  93. package/dist/lib/agent-interface.js +66 -1
  94. package/dist/lib/agent-interface.js.map +1 -1
  95. package/dist/lib/config.d.ts +32 -58
  96. package/dist/lib/config.js +19 -70
  97. package/dist/lib/config.js.map +1 -1
  98. package/dist/lib/constants.d.ts +17 -14
  99. package/dist/lib/constants.js +12 -31
  100. package/dist/lib/constants.js.map +1 -1
  101. package/dist/lib/framework-config.d.ts +13 -4
  102. package/dist/lib/framework-config.js.map +1 -1
  103. package/dist/lib/language-detection.d.ts +20 -0
  104. package/dist/lib/language-detection.js +96 -0
  105. package/dist/lib/language-detection.js.map +1 -0
  106. package/dist/lib/port-detection.js +4 -2
  107. package/dist/lib/port-detection.js.map +1 -1
  108. package/dist/lib/registry.d.ts +43 -0
  109. package/dist/lib/registry.js +96 -0
  110. package/dist/lib/registry.js.map +1 -0
  111. package/dist/lib/run-with-core.js +70 -26
  112. package/dist/lib/run-with-core.js.map +1 -1
  113. package/dist/lib/validation/validator.js +43 -13
  114. package/dist/lib/validation/validator.js.map +1 -1
  115. package/dist/nextjs/nextjs-installer-agent.d.ts +3 -4
  116. package/dist/nextjs/nextjs-installer-agent.js +3 -94
  117. package/dist/nextjs/nextjs-installer-agent.js.map +1 -1
  118. package/dist/nextjs/utils.d.ts +4 -8
  119. package/dist/nextjs/utils.js +4 -52
  120. package/dist/nextjs/utils.js.map +1 -1
  121. package/dist/react/react-installer-agent.d.ts +4 -2
  122. package/dist/react/react-installer-agent.js +4 -46
  123. package/dist/react/react-installer-agent.js.map +1 -1
  124. package/dist/react-router/react-router-installer-agent.d.ts +2 -4
  125. package/dist/react-router/react-router-installer-agent.js +2 -100
  126. package/dist/react-router/react-router-installer-agent.js.map +1 -1
  127. package/dist/react-router/utils.d.ts +2 -17
  128. package/dist/react-router/utils.js +2 -207
  129. package/dist/react-router/utils.js.map +1 -1
  130. package/dist/tanstack-start/tanstack-start-installer-agent.d.ts +4 -2
  131. package/dist/tanstack-start/tanstack-start-installer-agent.js +4 -48
  132. package/dist/tanstack-start/tanstack-start-installer-agent.js.map +1 -1
  133. package/dist/vanilla-js/vanilla-js-installer-agent.d.ts +4 -2
  134. package/dist/vanilla-js/vanilla-js-installer-agent.js +4 -46
  135. package/dist/vanilla-js/vanilla-js-installer-agent.js.map +1 -1
  136. package/package.json +6 -5
  137. package/skills/workos-authkit-nextjs/SKILL.md +41 -11
  138. package/skills/workos-authkit-sveltekit/SKILL.md +160 -0
  139. package/skills/workos-dotnet/SKILL.md +163 -0
  140. package/skills/workos-elixir/SKILL.md +194 -0
  141. package/skills/workos-go/SKILL.md +191 -0
  142. package/skills/workos-kotlin/SKILL.md +161 -0
  143. package/skills/workos-node/SKILL.md +164 -0
  144. package/skills/workos-php/SKILL.md +127 -0
  145. package/skills/workos-php-laravel/SKILL.md +147 -0
  146. package/skills/workos-python/SKILL.md +159 -0
  147. package/skills/workos-ruby/SKILL.md +163 -0
@@ -1,47 +1,5 @@
1
- import { enableDebugLogs } from '../utils/debug.js';
2
- import { runAgentInstaller } from '../lib/agent-runner.js';
3
- import { Integration } from '../lib/constants.js';
4
- const VANILLA_JS_AGENT_CONFIG = {
5
- metadata: {
6
- name: 'Vanilla JavaScript',
7
- integration: Integration.vanillaJs,
8
- docsUrl: 'https://workos.com/docs/user-management/authkit/javascript',
9
- unsupportedVersionDocsUrl: 'https://workos.com/docs/user-management/authkit/javascript',
10
- skillName: 'workos-authkit-vanilla-js',
11
- },
12
- detection: {
13
- packageName: 'workos',
14
- packageDisplayName: 'Vanilla JavaScript',
15
- getVersion: () => undefined,
16
- },
17
- environment: {
18
- uploadToHosting: false,
19
- requiresApiKey: false, // Client-only
20
- getEnvVars: (apiKey, clientId) => ({
21
- WORKOS_CLIENT_ID: clientId, // Only client ID needed
22
- }),
23
- },
24
- analytics: {
25
- getTags: () => ({}),
26
- },
27
- prompts: {},
28
- ui: {
29
- successMessage: 'WorkOS AuthKit integration complete',
30
- getOutroChanges: () => [
31
- 'Created WorkOS AuthKit integration',
32
- 'Added authentication to your JavaScript application',
33
- 'Set up login/logout functionality',
34
- ],
35
- getOutroNextSteps: () => [
36
- 'Start your development server to test authentication',
37
- 'Visit the WorkOS Dashboard to manage users and settings',
38
- ],
39
- },
40
- };
41
- export async function runVanillaJsInstallerAgent(options) {
42
- if (options.debug) {
43
- enableDebugLogs();
44
- }
45
- return runAgentInstaller(VANILLA_JS_AGENT_CONFIG, options);
46
- }
1
+ /**
2
+ * @deprecated Import from 'src/integrations/vanilla-js/index.js' instead.
3
+ */
4
+ export { run as runVanillaJsInstallerAgent, config as VANILLA_JS_AGENT_CONFIG, } from '../integrations/vanilla-js/index.js';
47
5
  //# sourceMappingURL=vanilla-js-installer-agent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vanilla-js-installer-agent.js","sourceRoot":"","sources":["../../src/vanilla-js/vanilla-js-installer-agent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,uBAAuB,GAAoB;IAC/C,QAAQ,EAAE;QACR,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,WAAW,CAAC,SAAS;QAClC,OAAO,EAAE,4DAA4D;QACrE,yBAAyB,EAAE,4DAA4D;QACvF,SAAS,EAAE,2BAA2B;KACvC;IAED,SAAS,EAAE;QACT,WAAW,EAAE,QAAQ;QACrB,kBAAkB,EAAE,oBAAoB;QACxC,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;KAC5B;IAED,WAAW,EAAE;QACX,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,KAAK,EAAE,cAAc;QACrC,UAAU,EAAE,CAAC,MAAc,EAAE,QAAgB,EAAE,EAAE,CAAC,CAAC;YACjD,gBAAgB,EAAE,QAAQ,EAAE,wBAAwB;SACrD,CAAC;KACH;IAED,SAAS,EAAE;QACT,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;KACpB;IAED,OAAO,EAAE,EAAE;IAEX,EAAE,EAAE;QACF,cAAc,EAAE,qCAAqC;QACrD,eAAe,EAAE,GAAG,EAAE,CAAC;YACrB,oCAAoC;YACpC,qDAAqD;YACrD,mCAAmC;SACpC;QACD,iBAAiB,EAAE,GAAG,EAAE,CAAC;YACvB,sDAAsD;YACtD,yDAAyD;SAC1D;KACF;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,OAAyB;IACxE,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,eAAe,EAAE,CAAC;IACpB,CAAC;IAED,OAAO,iBAAiB,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["/* Vanilla JS wizard using Claude Agent SDK */\nimport type { InstallerOptions } from '../utils/types.js';\nimport type { FrameworkConfig } from '../lib/framework-config.js';\nimport { enableDebugLogs } from '../utils/debug.js';\nimport { runAgentInstaller } from '../lib/agent-runner.js';\nimport { Integration } from '../lib/constants.js';\n\nconst VANILLA_JS_AGENT_CONFIG: FrameworkConfig = {\n metadata: {\n name: 'Vanilla JavaScript',\n integration: Integration.vanillaJs,\n docsUrl: 'https://workos.com/docs/user-management/authkit/javascript',\n unsupportedVersionDocsUrl: 'https://workos.com/docs/user-management/authkit/javascript',\n skillName: 'workos-authkit-vanilla-js',\n },\n\n detection: {\n packageName: 'workos',\n packageDisplayName: 'Vanilla JavaScript',\n getVersion: () => undefined,\n },\n\n environment: {\n uploadToHosting: false,\n requiresApiKey: false, // Client-only\n getEnvVars: (apiKey: string, clientId: string) => ({\n WORKOS_CLIENT_ID: clientId, // Only client ID needed\n }),\n },\n\n analytics: {\n getTags: () => ({}),\n },\n\n prompts: {},\n\n ui: {\n successMessage: 'WorkOS AuthKit integration complete',\n getOutroChanges: () => [\n 'Created WorkOS AuthKit integration',\n 'Added authentication to your JavaScript application',\n 'Set up login/logout functionality',\n ],\n getOutroNextSteps: () => [\n 'Start your development server to test authentication',\n 'Visit the WorkOS Dashboard to manage users and settings',\n ],\n },\n};\n\nexport async function runVanillaJsInstallerAgent(options: InstallerOptions): Promise<string> {\n if (options.debug) {\n enableDebugLogs();\n }\n\n return runAgentInstaller(VANILLA_JS_AGENT_CONFIG, options);\n}\n"]}
1
+ {"version":3,"file":"vanilla-js-installer-agent.js","sourceRoot":"","sources":["../../src/vanilla-js/vanilla-js-installer-agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,GAAG,IAAI,0BAA0B,EACjC,MAAM,IAAI,uBAAuB,GAClC,MAAM,qCAAqC,CAAC","sourcesContent":["/**\n * @deprecated Import from 'src/integrations/vanilla-js/index.js' instead.\n */\nexport {\n run as runVanillaJsInstallerAgent,\n config as VANILLA_JS_AGENT_CONFIG,\n} from '../integrations/vanilla-js/index.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workos",
3
- "version": "0.4.5",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "description": "The Official Workos CLI",
6
6
  "repository": {
@@ -73,8 +73,7 @@
73
73
  "engines": {
74
74
  "node": ">=20.20"
75
75
  },
76
- "author": "WorkOS",
77
- "license": "MIT",
76
+ "packageManager": "pnpm@10.28.2",
78
77
  "scripts": {
79
78
  "clean": "rm -rf ./dist",
80
79
  "prebuild": "pnpm clean",
@@ -95,5 +94,7 @@
95
94
  "eval:prune": "tsx tests/evals/index.ts prune",
96
95
  "eval:logs": "tsx tests/evals/index.ts logs",
97
96
  "eval:show": "tsx tests/evals/index.ts show"
98
- }
99
- }
97
+ },
98
+ "author": "WorkOS",
99
+ "license": "MIT"
100
+ }
@@ -35,21 +35,39 @@ Detect package manager, install SDK package from README.
35
35
 
36
36
  **Verify:** SDK package exists in node_modules before continuing.
37
37
 
38
- ## Step 4: Version Detection (Decision Tree)
38
+ ## Step 4: Locate the app/ directory (BLOCKING)
39
+
40
+ **STOP. Do this before creating any files.**
41
+
42
+ Determine where the `app/` directory lives:
43
+
44
+ ```bash
45
+ # Check for src/app/ first, then root app/
46
+ ls src/app/ 2>/dev/null && echo "APP_DIR=src" || (ls app/ 2>/dev/null && echo "APP_DIR=root")
47
+ ```
48
+
49
+ Set `APP_DIR` for all subsequent steps. All middleware/proxy files MUST be created in `APP_DIR`:
50
+
51
+ - If `APP_DIR=src` → create files in `src/` (e.g., `src/proxy.ts`)
52
+ - If `APP_DIR=root` → create files at project root (e.g., `proxy.ts`)
53
+
54
+ Next.js only discovers middleware/proxy files in the parent directory of `app/`. A file at the wrong level is **silently ignored** — no error, just doesn't run.
55
+
56
+ ## Step 5: Version Detection (Decision Tree)
39
57
 
40
58
  Read Next.js version from `package.json`:
41
59
 
42
60
  ```
43
61
  Next.js version?
44
62
  |
45
- +-- 16+ --> Create proxy.ts at project root
63
+ +-- 16+ --> Create {APP_DIR}/proxy.ts
46
64
  |
47
- +-- 15 --> Create middleware.ts (cookies() is async - handlers must await)
65
+ +-- 15 --> Create {APP_DIR}/middleware.ts (cookies() is async)
48
66
  |
49
- +-- 13-14 --> Create middleware.ts (cookies() is sync)
67
+ +-- 13-14 --> Create {APP_DIR}/middleware.ts (cookies() is sync)
50
68
  ```
51
69
 
52
- **Critical:** File MUST be at project root (or `src/` if using src directory). Never in `app/`.
70
+ **Next.js 16+ proxy.ts:** `proxy.ts` is the preferred convention. `middleware.ts` still works but shows a deprecation warning. Next.js 16 throws **error E900** if both files exist at the same level.
53
71
 
54
72
  **Next.js 15+ async note:** All route handlers and middleware accessing cookies must be async and properly await cookie operations. This is a breaking change from Next.js 14.
55
73
 
@@ -95,14 +113,14 @@ export default async function middleware(request: NextRequest) {
95
113
 
96
114
  **Critical:** Always return via `handleAuthkitHeaders()` to ensure `withAuth()` works in pages.
97
115
 
98
- ## Step 5: Create Callback Route
116
+ ## Step 6: Create Callback Route
99
117
 
100
118
  Parse `NEXT_PUBLIC_WORKOS_REDIRECT_URI` to determine route path:
101
119
 
102
120
  ```
103
- URI path --> Route location
104
- /auth/callback --> app/auth/callback/route.ts
105
- /callback --> app/callback/route.ts
121
+ URI path --> Route location (use APP_DIR from Step 4)
122
+ /auth/callback --> {APP_DIR}/app/auth/callback/route.ts
123
+ /callback --> {APP_DIR}/app/callback/route.ts
106
124
  ```
107
125
 
108
126
  Use `handleAuth()` from SDK. Do not write custom OAuth logic.
@@ -118,7 +136,7 @@ export const GET = handleAuth();
118
136
 
119
137
  Check README for exact usage. If build fails with "cookies outside request scope", the handler is likely missing async/await.
120
138
 
121
- ## Step 6: Provider Setup (REQUIRED)
139
+ ## Step 7: Provider Setup (REQUIRED)
122
140
 
123
141
  **CRITICAL:** You MUST wrap the app in `AuthKitProvider` in `app/layout.tsx`.
124
142
 
@@ -147,7 +165,7 @@ Check README for exact import path - it may be a subpath export like `@workos-in
147
165
 
148
166
  **Do NOT skip this step** even if using server-side auth patterns elsewhere.
149
167
 
150
- ## Step 7: UI Integration
168
+ ## Step 8: UI Integration
151
169
 
152
170
  Add auth UI to `app/page.tsx` using SDK functions. See README for `getUser`, `getSignInUrl`, `signOut` usage.
153
171
 
@@ -191,6 +209,18 @@ This error causes OAuth codes to expire ("invalid_grant"), so fix the handler fi
191
209
  - Check: File at project root or `src/`, not inside `app/`
192
210
  - Check: Filename matches Next.js version (proxy.ts for 16+, middleware.ts for 13-15)
193
211
 
212
+ ### "Both middleware file and proxy file are detected" (Next.js 16+)
213
+
214
+ - Next.js 16 throws error E900 if both `middleware.ts` and `proxy.ts` exist
215
+ - Delete `middleware.ts` and use only `proxy.ts`
216
+ - If `middleware.ts` has custom logic, migrate it into `proxy.ts`
217
+
218
+ ### "withAuth route not covered by middleware" but middleware/proxy file exists
219
+
220
+ - **Most common cause:** File is at the wrong level. Next.js only discovers middleware/proxy files in the parent directory of `app/`. For `src/app/` projects, the file must be in `src/`, not at the project root.
221
+ - Check: Is `app/` at `src/app/`? Then middleware/proxy must be at `src/middleware.ts` or `src/proxy.ts`
222
+ - Check: Matcher config must include the route path being accessed
223
+
194
224
  ### "Cannot use getUser in client component"
195
225
 
196
226
  - Check: Component has no `'use client'` directive, or
@@ -0,0 +1,160 @@
1
+ ---
2
+ name: workos-authkit-sveltekit
3
+ description: Integrate WorkOS AuthKit with SvelteKit. Server-side authentication with hooks and file-based routing.
4
+ ---
5
+
6
+ # WorkOS AuthKit for SvelteKit
7
+
8
+ ## Step 1: Fetch SDK Documentation (BLOCKING)
9
+
10
+ **STOP. Do not proceed until complete.**
11
+
12
+ WebFetch: `https://github.com/workos/authkit-sveltekit/blob/main/README.md`
13
+
14
+ The README is the source of truth. If this skill conflicts with README, follow README.
15
+
16
+ ## Step 2: Pre-Flight Validation
17
+
18
+ ### Project Structure
19
+
20
+ - Confirm `svelte.config.js` (or `svelte.config.ts`) exists
21
+ - Confirm `package.json` contains `@sveltejs/kit` dependency
22
+ - Confirm `src/routes/` directory exists
23
+
24
+ ### Environment Variables
25
+
26
+ Check `.env` or `.env.local` for:
27
+
28
+ - `WORKOS_API_KEY` - starts with `sk_`
29
+ - `WORKOS_CLIENT_ID` - starts with `client_`
30
+ - `WORKOS_REDIRECT_URI` - valid callback URL
31
+ - `WORKOS_COOKIE_PASSWORD` - 32+ characters
32
+
33
+ SvelteKit uses `$env/static/private` and `$env/dynamic/private` natively. The agent should write env vars to `.env` (SvelteKit's default) or `.env.local`.
34
+
35
+ ## Step 3: Install SDK
36
+
37
+ Detect package manager, install SDK package from README.
38
+
39
+ ```
40
+ pnpm-lock.yaml? → pnpm add @workos-inc/authkit-sveltekit
41
+ yarn.lock? → yarn add @workos-inc/authkit-sveltekit
42
+ bun.lockb? → bun add @workos-inc/authkit-sveltekit
43
+ else → npm install @workos-inc/authkit-sveltekit
44
+ ```
45
+
46
+ **Verify:** SDK package exists in node_modules before continuing.
47
+
48
+ ## Step 4: Configure Server Hooks
49
+
50
+ SvelteKit uses `src/hooks.server.ts` for server-side middleware. This is where the AuthKit handler is registered.
51
+
52
+ Create or update `src/hooks.server.ts` with the authkit handle function from the README.
53
+
54
+ ### Existing Hooks (IMPORTANT)
55
+
56
+ If `src/hooks.server.ts` already exists with custom logic, use SvelteKit's `sequence()` helper to compose hooks:
57
+
58
+ ```typescript
59
+ import { sequence } from '@sveltejs/kit/hooks';
60
+ import { authkitHandle } from '@workos-inc/authkit-sveltekit'; // Check README for exact export
61
+
62
+ export const handle = sequence(authkitHandle, yourExistingHandle);
63
+ ```
64
+
65
+ Check README for the exact export name and usage pattern.
66
+
67
+ ## Step 5: Create Callback Route
68
+
69
+ Parse `WORKOS_REDIRECT_URI` to determine route path:
70
+
71
+ ```
72
+ URI path --> Route location
73
+ /callback --> src/routes/callback/+server.ts
74
+ /auth/callback --> src/routes/auth/callback/+server.ts
75
+ ```
76
+
77
+ Use the SDK's callback handler from the README. Do not write custom OAuth logic.
78
+
79
+ **Critical:** SvelteKit uses `+server.ts` for API routes, not `+page.server.ts`.
80
+
81
+ ## Step 6: Layout Setup
82
+
83
+ Update `src/routes/+layout.server.ts` to load the auth session and pass it to all pages.
84
+
85
+ Check README for the exact pattern — typically a `load` function that returns the user session from locals.
86
+
87
+ ```typescript
88
+ // src/routes/+layout.server.ts
89
+ import type { LayoutServerLoad } from './$types';
90
+
91
+ export const load: LayoutServerLoad = async (event) => {
92
+ // Check README for exact API — session is typically on event.locals
93
+ return {
94
+ user: event.locals.user, // or similar from README
95
+ };
96
+ };
97
+ ```
98
+
99
+ ## Step 7: UI Integration
100
+
101
+ Add auth UI to `src/routes/+page.svelte` using the session data from the layout.
102
+
103
+ - Show user info when authenticated
104
+ - Show sign-in link/button when not authenticated
105
+ - Add sign-out functionality
106
+
107
+ Check README for sign-in URL generation and sign-out patterns.
108
+
109
+ ## Verification Checklist (ALL MUST PASS)
110
+
111
+ Run these commands to confirm integration. **Do not mark complete until all pass:**
112
+
113
+ ```bash
114
+ # 1. Check hooks.server.ts exists and has authkit
115
+ grep -i "workos\|authkit" src/hooks.server.ts || echo "FAIL: authkit missing from hooks.server.ts"
116
+
117
+ # 2. Check callback route exists
118
+ find src/routes -name "+server.ts" -path "*/callback/*"
119
+
120
+ # 3. Check layout loads auth session
121
+ grep -i "user\|auth\|session" src/routes/+layout.server.ts || echo "FAIL: auth session missing from layout"
122
+
123
+ # 4. Build succeeds
124
+ pnpm build || npm run build
125
+ ```
126
+
127
+ ## Error Recovery
128
+
129
+ ### "Cannot find module '@workos-inc/authkit-sveltekit'"
130
+
131
+ - Check: SDK installed before writing imports
132
+ - Check: SDK package directory exists in node_modules
133
+ - Re-run install if missing
134
+
135
+ ### hooks.server.ts not taking effect
136
+
137
+ - Check: File is at `src/hooks.server.ts`, not `src/hooks.ts` or elsewhere
138
+ - Check: Named export is `handle` (SvelteKit requirement)
139
+ - Check: If using `sequence()`, all handles are properly composed
140
+
141
+ ### Callback route not found (404)
142
+
143
+ - Check: File uses `+server.ts` (not `+page.server.ts`)
144
+ - Check: Route path matches `WORKOS_REDIRECT_URI` path exactly
145
+ - Check: Exports `GET` handler (SvelteKit convention)
146
+
147
+ ### "locals" type errors
148
+
149
+ - Check: App.Locals interface is augmented in `src/app.d.ts`
150
+ - Check README for TypeScript setup instructions
151
+
152
+ ### Cookie password error
153
+
154
+ - Verify `WORKOS_COOKIE_PASSWORD` is 32+ characters
155
+ - Generate new: `openssl rand -base64 32`
156
+
157
+ ### Auth state not available in pages
158
+
159
+ - Check: `+layout.server.ts` load function returns user data
160
+ - Check: Pages access data via `export let data` (Svelte 4) or `$page.data` (Svelte 5)
@@ -0,0 +1,163 @@
1
+ ---
2
+ name: workos-dotnet
3
+ description: Integrate WorkOS AuthKit with .NET (ASP.NET Core). Backend authentication with DI registration, auth endpoints, and appsettings configuration.
4
+ ---
5
+
6
+ # WorkOS AuthKit for .NET (ASP.NET Core)
7
+
8
+ ## Step 1: Fetch SDK Documentation (BLOCKING)
9
+
10
+ **STOP. Do not proceed until complete.**
11
+
12
+ WebFetch: `https://raw.githubusercontent.com/workos/workos-dotnet/main/README.md`
13
+
14
+ The README is the source of truth for SDK API usage. If this skill conflicts with README, follow README.
15
+
16
+ ## Step 2: Pre-Flight Validation
17
+
18
+ ### Project Structure
19
+
20
+ - Confirm a `*.csproj` file exists in the project root
21
+ - Detect project style:
22
+ - **Minimal API** (modern): `Program.cs` with `WebApplication.CreateBuilder()` — .NET 6+
23
+ - **Startup pattern** (older): `Startup.cs` with `ConfigureServices()` / `Configure()` — .NET 5 and earlier
24
+
25
+ This detection determines WHERE to register WorkOS services and middleware.
26
+
27
+ ### Environment Variables
28
+
29
+ Check `appsettings.Development.json` for:
30
+
31
+ - `WORKOS_API_KEY` — starts with `sk_`
32
+ - `WORKOS_CLIENT_ID` — starts with `client_`
33
+
34
+ ## Step 3: Install SDK
35
+
36
+ ```bash
37
+ dotnet add package WorkOS.net
38
+ ```
39
+
40
+ **Verify:** Check the `*.csproj` file contains a `<PackageReference Include="WorkOS.net"` entry.
41
+
42
+ If `dotnet` CLI is not available, stop and inform the user to install the .NET SDK.
43
+
44
+ ## Step 4: Configure WorkOS Client
45
+
46
+ ### Minimal API Pattern (Program.cs)
47
+
48
+ Add WorkOS configuration to `Program.cs`:
49
+
50
+ 1. Read WorkOS settings from `IConfiguration`
51
+ 2. Register the WorkOS client in the DI container
52
+ 3. The WorkOS client needs API key for initialization
53
+
54
+ ```csharp
55
+ // In Program.cs, after builder creation:
56
+ var workosApiKey = builder.Configuration["WorkOS:ApiKey"];
57
+ var workosClientId = builder.Configuration["WorkOS:ClientId"];
58
+ ```
59
+
60
+ ### Startup Pattern (Startup.cs)
61
+
62
+ Add to `ConfigureServices()`:
63
+
64
+ 1. Read WorkOS settings from `IConfiguration`
65
+ 2. Register services
66
+
67
+ Choose the pattern that matches the detected project structure.
68
+
69
+ ## Step 5: Create Authentication Endpoints
70
+
71
+ Create auth endpoints following the WorkOS AuthKit pattern. Use minimal API `app.MapGet()` for minimal API projects, or a Controller for Startup-pattern projects.
72
+
73
+ ### Required Endpoints
74
+
75
+ **GET /auth/login** — Redirect to WorkOS AuthKit:
76
+
77
+ - Use the WorkOS SDK to generate an authorization URL
78
+ - Include `clientId`, `redirectUri`, and `provider: "authkit"` parameters
79
+ - Redirect the user to the authorization URL
80
+
81
+ **GET /auth/callback** — Handle OAuth callback:
82
+
83
+ - Extract `code` from query parameters
84
+ - Exchange authorization code for user profile using the WorkOS SDK
85
+ - Store user info in session or cookie
86
+ - Redirect to home page
87
+
88
+ **GET /auth/logout** — Clear session:
89
+
90
+ - Clear the authentication session/cookie
91
+ - Redirect to home page
92
+
93
+ ### Session Management
94
+
95
+ Use ASP.NET Core's built-in session or cookie authentication:
96
+
97
+ ```csharp
98
+ // Enable session middleware in Program.cs
99
+ builder.Services.AddDistributedMemoryCache();
100
+ builder.Services.AddSession();
101
+ // ...
102
+ app.UseSession();
103
+ ```
104
+
105
+ ## Step 6: Environment Setup
106
+
107
+ Configure `appsettings.Development.json` with WorkOS credentials:
108
+
109
+ ```json
110
+ {
111
+ "WorkOS": {
112
+ "ApiKey": "<WORKOS_API_KEY value>",
113
+ "ClientId": "<WORKOS_CLIENT_ID value>",
114
+ "RedirectUri": "http://localhost:5000/auth/callback"
115
+ }
116
+ }
117
+ ```
118
+
119
+ Use the actual credential values provided in the environment context.
120
+
121
+ **Important:** Do NOT put secrets in `appsettings.json` (committed to git). Use `appsettings.Development.json` (gitignored) or `dotnet user-secrets`.
122
+
123
+ ## Step 7: Verification
124
+
125
+ Run these checks — **do not mark complete until all pass:**
126
+
127
+ ```bash
128
+ # 1. Check WorkOS.net is in csproj
129
+ grep -i "WorkOS" *.csproj
130
+
131
+ # 2. Check auth endpoints exist
132
+ grep -r "auth/login\|auth/callback\|auth/logout" *.cs
133
+
134
+ # 3. Build succeeds
135
+ dotnet build
136
+ ```
137
+
138
+ **If build fails:** Read the error output carefully. Common issues:
139
+
140
+ - Missing `using` statements for WorkOS namespaces
141
+ - Incorrect DI registration order
142
+ - Missing session/cookie middleware registration
143
+
144
+ ## Error Recovery
145
+
146
+ ### "dotnet: command not found"
147
+
148
+ - .NET SDK is not installed. Inform the user to install from https://dotnet.microsoft.com/download
149
+
150
+ ### NuGet restore failures
151
+
152
+ - Check internet connectivity
153
+ - Try `dotnet restore` explicitly before `dotnet build`
154
+
155
+ ### "No project file found"
156
+
157
+ - Ensure you're in the correct directory with a `*.csproj` file
158
+
159
+ ### Build errors after integration
160
+
161
+ - Check that all `using` statements are correct
162
+ - Verify DI registration order (services before middleware)
163
+ - Ensure `app.UseSession()` is called before mapping auth endpoints