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
@@ -0,0 +1,127 @@
1
+ ---
2
+ name: workos-php
3
+ description: Integrate WorkOS AuthKit with generic PHP applications. Uses the workos-php SDK directly with standalone auth endpoint files.
4
+ ---
5
+
6
+ # WorkOS AuthKit for PHP
7
+
8
+ ## Step 1: Fetch SDK Documentation (BLOCKING)
9
+
10
+ **STOP. Do not proceed until complete.**
11
+
12
+ WebFetch: `https://github.com/workos/workos-php/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 `composer.json` exists at project root
21
+ - If `composer.json` doesn't exist, create a minimal one with `composer init --no-interaction`
22
+
23
+ ### Environment Variables
24
+
25
+ Check for `.env` file with:
26
+
27
+ - `WORKOS_API_KEY` - starts with `sk_`
28
+ - `WORKOS_CLIENT_ID` - starts with `client_`
29
+ - `WORKOS_REDIRECT_URI` - valid callback URL (e.g., `http://localhost:8000/callback.php`)
30
+
31
+ If `.env` doesn't exist, create it with the required variables.
32
+
33
+ ## Step 3: Install SDK
34
+
35
+ ```bash
36
+ composer require workos/workos-php
37
+ ```
38
+
39
+ **Verify:** Check `composer.json` contains `workos/workos-php` in require section.
40
+
41
+ Also install a dotenv library if not present:
42
+
43
+ ```bash
44
+ composer require vlucas/phpdotenv
45
+ ```
46
+
47
+ ## Step 4: Create Bootstrap File
48
+
49
+ Create a bootstrap or config file (e.g., `config.php` or `bootstrap.php`) that:
50
+
51
+ 1. Requires Composer autoloader: `require_once __DIR__ . '/vendor/autoload.php';`
52
+ 2. Loads `.env` using phpdotenv
53
+ 3. Initializes the WorkOS SDK client with API key
54
+
55
+ Use SDK initialization from README. Do NOT hardcode credentials.
56
+
57
+ ## Step 5: Create Auth Endpoint Files
58
+
59
+ ### `login.php`
60
+
61
+ - Initialize WorkOS client (include bootstrap)
62
+ - Generate authorization URL using SDK
63
+ - Redirect user to WorkOS AuthKit
64
+
65
+ ### `callback.php`
66
+
67
+ - Initialize WorkOS client (include bootstrap)
68
+ - Exchange authorization code from `$_GET['code']` for user profile using SDK
69
+ - Start session, store user data
70
+ - Redirect to home/dashboard
71
+
72
+ ### `logout.php`
73
+
74
+ - Destroy session
75
+ - Redirect to home page
76
+
77
+ Use SDK methods from README for all WorkOS API calls. Do NOT construct OAuth URLs manually.
78
+
79
+ ## Step 6: Create Home Page
80
+
81
+ Create or update `index.php` to show:
82
+
83
+ - Sign in link (`login.php`) when no session
84
+ - User info and sign out link (`logout.php`) when session exists
85
+
86
+ ## Verification Checklist (ALL MUST PASS)
87
+
88
+ ```bash
89
+ # 1. SDK installed
90
+ composer show workos/workos-php
91
+
92
+ # 2. Auth files exist
93
+ ls login.php callback.php logout.php
94
+
95
+ # 3. No syntax errors
96
+ php -l login.php
97
+ php -l callback.php
98
+ php -l logout.php
99
+ php -l index.php
100
+
101
+ # 4. Autoloader exists
102
+ ls vendor/autoload.php
103
+ ```
104
+
105
+ ## Error Recovery
106
+
107
+ ### "Class WorkOS\WorkOS not found"
108
+
109
+ - Verify `composer require` completed successfully
110
+ - Check `vendor/autoload.php` is required in bootstrap
111
+ - Run `composer dump-autoload`
112
+
113
+ ### Session issues
114
+
115
+ - Ensure `session_start()` is called before any session access
116
+ - Check PHP session configuration (`session.save_path`)
117
+
118
+ ### Redirect URI mismatch
119
+
120
+ - Compare callback file path to `WORKOS_REDIRECT_URI` in `.env`
121
+ - URLs must match exactly (including trailing slash)
122
+
123
+ ### Environment variables not loading
124
+
125
+ - Verify `.env` file exists in project root
126
+ - Verify phpdotenv is installed and loaded in bootstrap
127
+ - Check file permissions on `.env`
@@ -0,0 +1,147 @@
1
+ ---
2
+ name: workos-php-laravel
3
+ description: Integrate WorkOS AuthKit with Laravel applications. Uses the dedicated workos-php-laravel SDK with service provider, middleware, and config publishing.
4
+ ---
5
+
6
+ # WorkOS AuthKit for Laravel
7
+
8
+ ## Step 1: Fetch SDK Documentation (BLOCKING)
9
+
10
+ **STOP. Do not proceed until complete.**
11
+
12
+ WebFetch: `https://github.com/workos/workos-php-laravel/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 `artisan` file exists at project root
21
+ - Confirm `composer.json` contains `laravel/framework` dependency
22
+ - Confirm `app/` and `routes/` directories exist
23
+
24
+ ### Environment Variables
25
+
26
+ Check `.env` for:
27
+
28
+ - `WORKOS_API_KEY` - starts with `sk_`
29
+ - `WORKOS_CLIENT_ID` - starts with `client_`
30
+ - `WORKOS_REDIRECT_URI` - valid callback URL (e.g., `http://localhost:8000/auth/callback`)
31
+
32
+ If `.env` exists but is missing these variables, append them. If `.env` doesn't exist, copy `.env.example` and add them.
33
+
34
+ ## Step 3: Install SDK
35
+
36
+ ```bash
37
+ composer require workos/workos-php-laravel
38
+ ```
39
+
40
+ **Verify:** Check `composer.json` contains `workos/workos-php-laravel` in require section before continuing.
41
+
42
+ ## Step 4: Publish Configuration
43
+
44
+ ```bash
45
+ php artisan vendor:publish --provider="WorkOS\Laravel\WorkOSServiceProvider"
46
+ ```
47
+
48
+ This creates `config/workos.php`. Verify the file exists after publishing.
49
+
50
+ If the artisan command fails, check README for the correct provider class name — it may differ.
51
+
52
+ ## Step 5: Configure Environment
53
+
54
+ Ensure `.env` contains:
55
+
56
+ ```
57
+ WORKOS_API_KEY=sk_...
58
+ WORKOS_CLIENT_ID=client_...
59
+ WORKOS_REDIRECT_URI=http://localhost:8000/auth/callback
60
+ ```
61
+
62
+ Also ensure `config/workos.php` reads these env vars correctly. Check README for exact config structure.
63
+
64
+ ## Step 6: Create Auth Controller
65
+
66
+ Create `app/Http/Controllers/AuthController.php` with methods for:
67
+
68
+ - `login()` — Redirect to WorkOS AuthKit authorization URL
69
+ - `callback()` — Handle OAuth callback, exchange code for user profile
70
+ - `logout()` — Clear session and redirect
71
+
72
+ Use SDK methods from README. Do NOT construct OAuth URLs manually.
73
+
74
+ ## Step 7: Add Routes
75
+
76
+ Add to `routes/web.php`:
77
+
78
+ ```php
79
+ use App\Http\Controllers\AuthController;
80
+
81
+ Route::get('/login', [AuthController::class, 'login'])->name('login');
82
+ Route::get('/auth/callback', [AuthController::class, 'callback']);
83
+ Route::get('/logout', [AuthController::class, 'logout'])->name('logout');
84
+ ```
85
+
86
+ Ensure the callback route path matches `WORKOS_REDIRECT_URI`.
87
+
88
+ ## Step 8: Add Middleware (if applicable)
89
+
90
+ Check README for any authentication middleware the SDK provides. If available:
91
+
92
+ 1. Register middleware in `app/Http/Kernel.php` or `bootstrap/app.php` (Laravel 11+)
93
+ 2. Apply to routes that require authentication
94
+
95
+ For Laravel 11+, middleware is registered in `bootstrap/app.php` instead of `Kernel.php`.
96
+
97
+ ## Step 9: Add UI Integration
98
+
99
+ Update the home page or dashboard view to show:
100
+
101
+ - Sign in link when user is not authenticated
102
+ - User info and sign out link when authenticated
103
+
104
+ Use Blade directives or SDK helpers from README.
105
+
106
+ ## Verification Checklist (ALL MUST PASS)
107
+
108
+ ```bash
109
+ # 1. Config file exists
110
+ ls config/workos.php
111
+
112
+ # 2. Controller exists
113
+ ls app/Http/Controllers/AuthController.php
114
+
115
+ # 3. Routes registered
116
+ php artisan route:list | grep -E "login|callback|logout"
117
+
118
+ # 4. SDK installed
119
+ composer show workos/workos-php-laravel
120
+
121
+ # 5. Lint check
122
+ php -l app/Http/Controllers/AuthController.php
123
+ ```
124
+
125
+ ## Error Recovery
126
+
127
+ ### "Class WorkOS\Laravel\WorkOSServiceProvider not found"
128
+
129
+ - Verify `composer require` completed successfully
130
+ - Run `composer dump-autoload`
131
+ - Check `vendor/workos/` directory exists
132
+
133
+ ### "Route not defined"
134
+
135
+ - Verify routes are in `routes/web.php`
136
+ - Run `php artisan route:clear && php artisan route:cache`
137
+
138
+ ### Config not loading
139
+
140
+ - Verify `config/workos.php` exists
141
+ - Run `php artisan config:clear`
142
+ - Check `.env` variables match config keys
143
+
144
+ ### Middleware issues (Laravel 11+)
145
+
146
+ - Laravel 11 removed `Kernel.php` — register middleware in `bootstrap/app.php`
147
+ - Check README for Laravel version-specific instructions
@@ -0,0 +1,159 @@
1
+ ---
2
+ name: workos-python
3
+ description: Integrate WorkOS AuthKit with Python applications. Adapts to Django, Flask, FastAPI, or vanilla Python. Server-side authentication with redirect-based OAuth flow.
4
+ ---
5
+
6
+ # WorkOS AuthKit for Python
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-python/main/README.md`
13
+
14
+ Also fetch the AuthKit quickstart for reference:
15
+ WebFetch: `https://workos.com/docs/authkit/vanilla/python`
16
+
17
+ The README is the source of truth for SDK API usage. If this skill conflicts with README, follow README.
18
+
19
+ ## Step 2: Detect Framework
20
+
21
+ Examine the project to determine which Python web framework is in use:
22
+
23
+ ```
24
+ manage.py exists? → Django
25
+ settings.py has django imports? → Confirmed Django
26
+
27
+ Gemfile/requirements has 'fastapi'? → FastAPI
28
+ main.py has FastAPI() instance? → Confirmed FastAPI
29
+
30
+ requirements has 'flask'? → Flask
31
+ server.py/app.py has Flask() instance? → Confirmed Flask
32
+
33
+ None of the above? → Vanilla Python (use Flask quickstart pattern)
34
+ ```
35
+
36
+ **Adapt all subsequent steps to the detected framework.** Do not force one framework onto another.
37
+
38
+ ## Step 3: Pre-Flight Validation
39
+
40
+ ### Package Manager Detection
41
+
42
+ ```
43
+ uv.lock exists? → uv add
44
+ pyproject.toml has [tool.poetry]? → poetry add
45
+ Pipfile exists? → pipenv install
46
+ requirements.txt exists? → pip install (+ append to requirements.txt)
47
+ else → pip install
48
+ ```
49
+
50
+ ### Environment Variables
51
+
52
+ Check `.env` for:
53
+
54
+ - `WORKOS_API_KEY` - starts with `sk_`
55
+ - `WORKOS_CLIENT_ID` - starts with `client_`
56
+
57
+ ## Step 4: Install SDK
58
+
59
+ Install using the detected package manager:
60
+
61
+ ```bash
62
+ # uv
63
+ uv add workos python-dotenv
64
+
65
+ # poetry
66
+ poetry add workos python-dotenv
67
+
68
+ # pip
69
+ pip install workos python-dotenv
70
+ ```
71
+
72
+ If using `requirements.txt`, also append `workos` and `python-dotenv` to it.
73
+
74
+ **Verify:** `python -c "import workos; print('OK')"`
75
+
76
+ ## Step 5: Integrate Authentication
77
+
78
+ ### If Django
79
+
80
+ 1. **Configure settings.py** — add `import os` + `from dotenv import load_dotenv` + `load_dotenv()` at top. Add `WORKOS_API_KEY` and `WORKOS_CLIENT_ID` from `os.environ.get()`.
81
+ 2. **Create auth views** — create `auth_views.py` (or add to existing views):
82
+ - `login_view`: call SDK's `get_authorization_url()` with `provider='authkit'`, redirect
83
+ - `callback_view`: call `authenticate_with_code()` with the code param, store user in `request.session`
84
+ - `logout_view`: flush session, redirect
85
+ 3. **Add URL patterns** — add `auth/login/`, `auth/callback/`, `auth/logout/` to `urls.py`
86
+ 4. **Update templates** — add login/logout links using `{% url %}` tags
87
+
88
+ ### If Flask
89
+
90
+ Follow the quickstart pattern exactly:
91
+
92
+ 1. **Initialize WorkOS client** in `server.py` / `app.py`:
93
+ ```python
94
+ from workos import WorkOSClient
95
+ workos = WorkOSClient(api_key=os.getenv("WORKOS_API_KEY"), client_id=os.getenv("WORKOS_CLIENT_ID"))
96
+ ```
97
+ 2. **Create `/login` route** — call `workos.user_management.get_authorization_url(provider="authkit", redirect_uri="...")`, redirect
98
+ 3. **Create `/callback` route** — call `workos.user_management.authenticate_with_code(code=code)`, set session cookie
99
+ 4. **Create `/logout` route** — clear session, redirect
100
+ 5. **Update home route** — show user info if session exists
101
+
102
+ ### If FastAPI
103
+
104
+ 1. **Initialize WorkOS client** in main app file
105
+ 2. **Create `/login` endpoint** — generate auth URL, return `RedirectResponse`
106
+ 3. **Create `/callback` endpoint** — exchange code, store in session/cookie
107
+ 4. **Create `/logout` endpoint** — clear session
108
+ 5. Use `Depends()` for auth middleware on protected routes
109
+
110
+ ### If Vanilla Python (no framework detected)
111
+
112
+ Install Flask and follow the Flask pattern above. This matches the official quickstart.
113
+
114
+ ## Step 6: Environment Setup
115
+
116
+ Create/update `.env` with WorkOS credentials. Do NOT overwrite existing values.
117
+
118
+ ```
119
+ WORKOS_API_KEY=sk_...
120
+ WORKOS_CLIENT_ID=client_...
121
+ ```
122
+
123
+ ## Step 7: Verification Checklist
124
+
125
+ ```bash
126
+ # 1. SDK importable
127
+ python -c "import workos; print('OK')"
128
+
129
+ # 2. Credentials configured
130
+ python -c "
131
+ from dotenv import load_dotenv; import os; load_dotenv()
132
+ assert os.environ.get('WORKOS_API_KEY','').startswith('sk_'), 'Missing WORKOS_API_KEY'
133
+ assert os.environ.get('WORKOS_CLIENT_ID','').startswith('client_'), 'Missing WORKOS_CLIENT_ID'
134
+ print('Credentials OK')
135
+ "
136
+
137
+ # 3. Framework-specific check
138
+ # Django: python manage.py check
139
+ # Flask: python -m py_compile server.py
140
+ # FastAPI: python -m py_compile main.py
141
+ ```
142
+
143
+ ## Error Recovery
144
+
145
+ ### "ModuleNotFoundError: No module named 'workos'"
146
+
147
+ Re-run the install command for the detected package manager.
148
+
149
+ ### Django: "CSRF verification failed"
150
+
151
+ Auth callback receives GET requests from WorkOS. Ensure callback view uses GET, not POST. Or add `@csrf_exempt`.
152
+
153
+ ### Flask: Session not persisting
154
+
155
+ Ensure `app.secret_key` is set (required for Flask sessions).
156
+
157
+ ### Virtual environment not active
158
+
159
+ Check for `.venv/`, `venv/`, or poetry-managed environments. Activate before running install.
@@ -0,0 +1,163 @@
1
+ ---
2
+ name: workos-ruby
3
+ description: Integrate WorkOS AuthKit with Ruby applications. Adapts to Rails, Sinatra, or vanilla Ruby. Server-side authentication with redirect-based OAuth flow.
4
+ ---
5
+
6
+ # WorkOS AuthKit for Ruby
7
+
8
+ ## Step 1: Fetch SDK Documentation (BLOCKING)
9
+
10
+ **STOP — Do not proceed until this fetch is complete.**
11
+
12
+ WebFetch: `https://raw.githubusercontent.com/workos/workos-ruby/main/README.md`
13
+
14
+ Also fetch the AuthKit quickstart for reference:
15
+ WebFetch: `https://workos.com/docs/authkit/vanilla/ruby`
16
+
17
+ The README is the **source of truth** for gem API usage. If this skill conflicts with the README, **follow the README**.
18
+
19
+ ## Step 2: Detect Framework
20
+
21
+ Examine the project to determine which Ruby web framework is in use:
22
+
23
+ ```
24
+ config/routes.rb exists? → Rails
25
+ Gemfile has 'rails' gem? → Confirmed Rails
26
+
27
+ Gemfile has 'sinatra' gem? → Sinatra
28
+ server.rb/app.rb has Sinatra routes? → Confirmed Sinatra
29
+
30
+ None of the above? → Vanilla Ruby (use Sinatra quickstart pattern)
31
+ ```
32
+
33
+ **Adapt all subsequent steps to the detected framework.** Do not force Rails on a Sinatra project or vice versa.
34
+
35
+ ## Step 3: Install WorkOS Gem
36
+
37
+ ```bash
38
+ bundle add workos
39
+ ```
40
+
41
+ If `dotenv` is not in the Gemfile:
42
+
43
+ ```bash
44
+ # Rails
45
+ bundle add dotenv-rails --group development,test
46
+
47
+ # Sinatra / other
48
+ bundle add dotenv
49
+ ```
50
+
51
+ **Verify:** `bundle show workos`
52
+
53
+ ## Step 4: Integrate Authentication
54
+
55
+ ### If Rails
56
+
57
+ 1. **Create initializer** — `config/initializers/workos.rb`:
58
+
59
+ ```ruby
60
+ WorkOS.configure do |config|
61
+ config.api_key = ENV.fetch("WORKOS_API_KEY")
62
+ config.client_id = ENV.fetch("WORKOS_CLIENT_ID")
63
+ end
64
+ ```
65
+
66
+ 2. **Create AuthController** — `app/controllers/auth_controller.rb`:
67
+ - `login` action: call `WorkOS::UserManagement.get_authorization_url(provider: "authkit", redirect_uri: ...)`, redirect
68
+ - `callback` action: call `WorkOS::UserManagement.authenticate_with_code(code: params[:code])`, store user in session
69
+ - `logout` action: clear session, redirect
70
+
71
+ 3. **Add routes** to `config/routes.rb`:
72
+
73
+ ```ruby
74
+ get "/auth/login", to: "auth#login"
75
+ get "/auth/callback", to: "auth#callback"
76
+ get "/auth/logout", to: "auth#logout"
77
+ ```
78
+
79
+ 4. **Add current_user helper** to `ApplicationController` (optional):
80
+
81
+ ```ruby
82
+ helper_method :current_user
83
+ def current_user
84
+ @current_user ||= session[:user] && JSON.parse(session[:user])
85
+ end
86
+ ```
87
+
88
+ 5. **Verify:** `bundle exec rails routes | grep auth`
89
+
90
+ ### If Sinatra
91
+
92
+ Follow the quickstart pattern exactly:
93
+
94
+ 1. **Configure WorkOS** in `server.rb`:
95
+
96
+ ```ruby
97
+ require "dotenv/load"
98
+ require "workos"
99
+ require "sinatra"
100
+
101
+ WorkOS.configure do |config|
102
+ config.key = ENV["WORKOS_API_KEY"]
103
+ end
104
+ ```
105
+
106
+ 2. **Create `/login` route** — call `WorkOS::UserManagement.authorization_url(provider: "authkit", client_id: ..., redirect_uri: ...)`, redirect
107
+
108
+ 3. **Create `/callback` route** — call `WorkOS::UserManagement.authenticate_with_code(client_id: ..., code: ...)`, store in session cookie
109
+
110
+ 4. **Create `/logout` route** — clear session cookie, redirect
111
+
112
+ 5. **Update home route** — read session, show user info if present
113
+
114
+ 6. **Verify:** `ruby -c server.rb`
115
+
116
+ ### If Vanilla Ruby (no framework detected)
117
+
118
+ Install Sinatra and follow the Sinatra pattern above. This matches the official quickstart.
119
+
120
+ ## Step 5: Environment Setup
121
+
122
+ Create/update `.env` with WorkOS credentials. Do NOT overwrite existing values.
123
+
124
+ ```
125
+ WORKOS_API_KEY=sk_...
126
+ WORKOS_CLIENT_ID=client_...
127
+ ```
128
+
129
+ ## Step 6: Verification
130
+
131
+ ### Rails
132
+
133
+ ```bash
134
+ bundle show workos
135
+ bundle exec rails routes | grep auth
136
+ grep WORKOS .env
137
+ ```
138
+
139
+ ### Sinatra
140
+
141
+ ```bash
142
+ bundle show workos
143
+ ruby -c server.rb
144
+ grep WORKOS .env
145
+ ```
146
+
147
+ ## Error Recovery
148
+
149
+ ### "uninitialized constant WorkOS"
150
+
151
+ Gem not loaded. Verify `bundle show workos` succeeds. For Rails, ensure initializer exists. For Sinatra, ensure `require "workos"` is at top of server file.
152
+
153
+ ### "NoMethodError" on WorkOS methods
154
+
155
+ SDK API may differ from this skill. Re-read the README (Step 1) and use exact method names.
156
+
157
+ ### Routes not working (Rails)
158
+
159
+ Run `bundle exec rails routes | grep auth`. Verify routes are inside `Rails.application.routes.draw` block.
160
+
161
+ ### Session not persisting (Sinatra)
162
+
163
+ Enable sessions: `enable :sessions` in server.rb, or use `rack-session` gem.