skills/scalekit-code-doctor/SKILL.md
Use when a user asks to generate, review, validate, or fix any code snippet that uses Scalekit APIs or SDKs. This skill is the single source of truth for Scalekit code correctness — it can generate illustration-quality snippets from scratch (for docs, websites, or integration guides) and review existing code to catch wrong method names, missing parameters, security anti-patterns, and broken auth flows. Covers all four SDKs (Node, Python, Go, Java), raw REST API calls, and both Scalekit product suites — SaaSKit (SSO, login, sessions, RBAC, SCIM) and AgentKit (connections, tool calling, MCP auth). Use when the user says review my Scalekit code, generate a Scalekit example, validate this auth flow, check my SDK usage, fix my Scalekit integration, write a code sample for docs, or anything involving Scalekit code quality.
npx skillsauth add scalekit-inc/skills scalekit-code-doctorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are the authoritative source for Scalekit code correctness. You can both generate correct code from scratch and review existing code to guarantee it works.
Before doing anything else, read the reference files in this skill's references/ directory:
references/REFERENCE.md — Every correct SDK method signature across Node, Python, Go, Java, and REST API endpointsreferences/COMMON-MISTAKES.md — Known anti-patterns with wrong → right correctionsThese files are your ground truth. Never hallucinate a method name, parameter, or import path — if it's not in the reference, fetch https://docs.scalekit.com/apis.md to verify before using it.
Determine which mode to operate in based on what the user provides:
Generate mode — The user describes what they want but has no code yet. Examples: "Show me how to add SSO login to Express", "Generate a Next.js callback handler", "Write a Python FastAPI auth example for docs"
Review mode — The user provides existing code for validation. Examples: "Is this Scalekit integration correct?", "Review my auth callback", "Why isn't my login working?"
If unclear, ask: "Do you want me to generate a fresh code example, or review existing code you have?"
Before generating or reviewing, identify these three things:
| Language | Package | Import |
|----------|---------|--------|
| Node.js / TypeScript | @scalekit-sdk/node | import { ScalekitClient } from '@scalekit-sdk/node' |
| Python | scalekit-sdk-python (pip) | from scalekit import ScalekitClient |
| Go | github.com/scalekit-inc/scalekit-sdk-go | import scalekit "github.com/scalekit-inc/scalekit-sdk-go/v2" |
| Java | com.scalekit:scalekit-sdk-java | import com.scalekit.ScalekitClient; |
| REST API | No SDK — raw HTTP | Bearer token via POST /oauth/token with client credentials |
Next.js (App Router or Pages), Express, Fastify, FastAPI, Django, Flask, Spring Boot, Go (chi, gin, net/http), Laravel, etc.
Scalekit has two product suites. Identify which one the user's code belongs to:
SaaSKit — Full-stack authentication for B2B SaaS apps
AgentKit — Authentication and tool access for AI agents
Cross-product
When generating code, follow these rules:
The output should be clean enough to publish directly on docs.scalekit.com or a marketing landing page. This means:
'https://yourapp.com/auth/callback' not 'http://localhost:3000/test'Cross-reference every SDK call against references/REFERENCE.md:
SaaSKit — Login, SSO, and sessions
state for CSRFstate, exchange code, store sessiongetLogoutUrl() with idTokenHintoffline_access scope is used)SaaSKit — SCIM provisioning
AgentKit — Connections and tool calling
AgentKit — MCP Authentication
Webhooks — Always include signature verification:
verifyWebhookPayload(secret, headers, rawBody)When reviewing code, systematically check these categories in order:
For every Scalekit SDK call in the code, verify against references/REFERENCE.md:
envUrl, clientId, clientSecretstate parameter (CSRF protection)getLogoutUrl() — not just clearing local sessionoffline_access or refresh_token is usedidp_initiated_login parameterhttpOnly: true, secure: true (in production), sameSite: 'lax' (never 'strict' — breaks OAuth redirects)state parameter uses cryptographically random values, not predictable stringsnext/returnTo params (prevents open redirect)Cache-Control: no-store on authenticated pages (prevents back-button cache leak)SCALEKIT_ENV_URL (not SCALEKIT_URL or SCALEKIT_ENVIRONMENT_URL in code — though SCALEKIT_ENVIRONMENT_URL is used in REST API docs)SCALEKIT_CLIENT_IDSCALEKIT_CLIENT_SECREThttps://<subdomain>.scalekit.com (production) or https://<subdomain>.scalekit.dev (development)window.location.href used for OAuth redirects (not router.push or client-side navigation)For each finding, report:
If everything is correct, say so explicitly: "This code is correct. All SDK calls, auth flow, security patterns, and configuration match the current Scalekit API."
The references/REFERENCE.md in this skill is a point-in-time snapshot. Scalekit SDKs evolve — new methods are added, parameters change, and new product areas launch. When the embedded reference doesn't cover what you need, use the live sources below.
Each SDK repo has a maintained REFERENCE.md with full, current method signatures. Fetch the one you need:
| SDK | Live reference URL |
|-----|-------------------|
| Node.js | https://raw.githubusercontent.com/scalekit-inc/scalekit-sdk-node/main/REFERENCE.md |
| Python | https://raw.githubusercontent.com/scalekit-inc/scalekit-sdk-python/main/REFERENCE.md |
| Go | https://raw.githubusercontent.com/scalekit-inc/scalekit-sdk-go/main/REFERENCE.md |
| Java | https://raw.githubusercontent.com/scalekit-inc/scalekit-sdk-java/main/REFERENCE.md |
| REST API | https://docs.scalekit.com/apis.md |
references/REFERENCE.md first (fastest, no network)https://docs.scalekit.com/apis.md for REST endpointsNever output code containing an unverified method call.
When the user's code makes raw HTTP calls (fetch, axios, requests, http.Client) to Scalekit endpoints, validate:
https://<subdomain>.scalekit.com or https://<subdomain>.scalekit.devPOST /oauth/token with client_credentials grantreferences/REFERENCE.md for the endpoint list)application/json for most endpoints, application/x-www-form-urlencoded for token endpoint)page_token and page_size parameters where applicable| SDK | REFERENCE.md (raw) | Repo |
|-----|--------------------|----|
| Node.js | https://raw.githubusercontent.com/scalekit-inc/scalekit-sdk-node/main/REFERENCE.md | scalekit-sdk-node |
| Python | https://raw.githubusercontent.com/scalekit-inc/scalekit-sdk-python/main/REFERENCE.md | scalekit-sdk-python |
| Go | https://raw.githubusercontent.com/scalekit-inc/scalekit-sdk-go/main/REFERENCE.md | scalekit-sdk-go |
| Java | https://raw.githubusercontent.com/scalekit-inc/scalekit-sdk-java/main/REFERENCE.md | scalekit-sdk-java |
| Resource | URL | When to use |
|----------|-----|-------------|
| REST API reference | https://docs.scalekit.com/apis.md | Full endpoint schemas, request/response details |
| LLM doc index | https://docs.scalekit.com/llms.txt | Find the right docs page for a specific product area |
| SaaSKit docs | https://docs.scalekit.com/_llms-txt/saaskit-complete.txt | Full SaaSKit reference (users, orgs, sessions, RBAC, SSO, SCIM) |
| AgentKit docs | https://docs.scalekit.com/_llms-txt/agentkit.txt | Full AgentKit reference (agents, OAuth vault, tool calling, connectors) |
| AgentKit frameworks | https://docs.scalekit.com/_llms-txt/agentkit-frameworks.txt | Framework-specific guides (LangChain, Vercel AI, Anthropic, OpenAI, Google ADK, Mastra) |
| MCP Authentication docs | https://docs.scalekit.com/_llms-txt/mcp-authentication.txt | MCP server OAuth 2.1, Dynamic Client Registration |
When generating or reviewing framework-specific code, fetch the matching repo for real, tested patterns. Repos are from scalekit-inc and scalekit-developers GitHub orgs.
SaaSKit — Auth examples by framework
| Framework | Repo | What it shows | |-----------|------|---------------| | Next.js (App Router) | scalekit-nextjs-auth-example | SSO, sessions, protected routes, TypeScript | | Next.js (Pages) | nextjs-example-apps | React SSO integration flows | | Next.js + Auth.js | scalekit-authjs-example | Enterprise SSO with next-auth v5 | | Express.js | scalekit-express-auth-example | Node SDK, EJS frontend, sessions | | Express.js | scalekit-express-example | SSO with session management, middleware | | FastAPI | scalekit-fastapi-auth-example | Python SDK, OAuth 2.0, protected routes | | FastAPI | scalekit-fastapi-example | Async auth, Pydantic models | | Django | scalekit-django-auth-example | Python SDK, Django auth integration | | Flask | scalekit-flask-auth-example | Python SDK, Flask sessions | | Spring Boot | scalekit-springboot-auth-example | Java, Spring Security, OIDC | | Spring Boot | scalekit-springboot-example | Java SDK, enterprise SSO | | Go (Gin) | scalekit-go-example | Go SDK, Gin framework, SSO | | Laravel | scalekit-laravel-auth-example | REST API calls, Laravel HTTPS | | Astro | astro-scalekit-auth-example | Auth, SSO, social login, protected routes | | .NET | dotnet-example-apps | ASP.NET Core, SAML/OIDC | | Expo (mobile) | expo-scalekit-sample | OAuth 2.0 + PKCE for mobile |
SaaSKit — Integration examples
| Integration | Repo | What it shows | |-------------|------|---------------| | AWS Cognito | scalekit-cognito-sso | OIDC SSO with Cognito user pools | | Firebase | scalekit-firebase-sso | SAML/OIDC SSO with Firebase Auth | | Supabase | scalekit-supabase-example | Supabase + Scalekit auth | | Multi-app SSO | multiapp-demo | Seamless SSO across multiple apps | | Org switcher | Nextjs-Django-Org-Switcher-Example | Next.js frontend + Django backend, org switching | | OIDC/SAML/SCIM | oidc-saml-scim-examples | Google, Okta integration patterns | | Passwordless | passwordless-auth-demos | Passwordless authentication flows | | Managed login | managed-loginbox-expressjs-demo | Hosted login UI with Express | | Full demo app | coffee-desk-demo | Workspace creation, user provisioning, RBAC, SSO |
AgentKit — Agent and MCP examples
| Framework / Pattern | Repo | What it shows | |---------------------|------|---------------| | LangChain | sample-langchain-agent | Python LangChain agent with Scalekit auth | | Google ADK | google-adk-agent-example | Google ADK agent with authenticated tools | | Vercel AI SDK | vercel-ai-agent-toolkit | Vercel AI SDK + Scalekit connectors | | Apify Actor | agentkit-apify-actor-example | OAuth auth, YouTube → Notion agent | | LiteLLM | litellm-agentkit-inbox-triage | Inbox triage with Gmail, GitHub, Slack | | MCP Auth (multi-framework) | mcp-auth-demos | MCP OAuth 2.1 demos | | MCP + FastMCP | fastmcp-scalekit-example | FastMCP server with Scalekit auth | | MCP + BYOA | byoa-demo-mcp | Bring your own auth + MCP | | MCP + Coffee Desk | coffee-desk-mcp | Demo MCP server with roles/permissions | | Python connections | python-connect-demos | Python connection and identity workflows | | Agent auth examples | agent-auth-examples | Official AgentKit examples collection | | Node.js agents | agent-node-demos | TypeScript agent demos | | Workflow agents | workflow-agents-demos | Multi-step agent workflows | | Render deploy kit | render-ai-agent-deploykit | Render Workflows + Scalekit + Claude |
Developer tools
| Tool | Repo | Purpose | |------|------|---------| | Dryrun CLI | scalekit-dryrun | Test auth flows without writing code | | Scalekit MCP server | scalekit-mcp-server | Manage orgs, users, connections via AI assistants | | API collections | api-collections | Postman/Bruno collections for Scalekit endpoints | | Documentation source | developer-docs | Docs site source (MDX) |
Frontend SDKs
| SDK | Repo | Purpose | |-----|------|---------| | React SDK | scalekit-react-sdk | React OIDC authentication | | Vue SDK | scalekit-vue-sdk | Vue OIDC authentication | | Expo SDK | scalekit-expo-sdk | Expo/React Native OAuth 2.0 + PKCE |
When generating code for a specific framework, fetch the matching repo's source to see real, tested patterns before writing. When reviewing, compare the user's code against the closest matching example repo.
tools
Create or review Scalekit custom providers/connectors for proxy-only usage, including MCP providers. Use this skill when the task is to gather API docs, infer whether a connector is OAuth, Basic, Bearer, or API Key, determine if it is an MCP provider, determine required tracked fields like domain or version, generate provider JSON, check for existing custom providers, show update diffs, run approved create or update curls, and print resolved delete curls.
tools
Use when a developer is new to Scalekit and needs guidance on where to start, doesn't know which auth plugin or skill to choose, wants to connect an AI agent or agentic workflow to third-party services (Gmail, Slack, Notion, Google Calendar), needs OAuth or tool-calling auth for agents, wants to add authentication to a project but hasn't chosen an approach yet, or needs to install the Scalekit plugin for their AI coding tool (Claude Code, Codex, Copilot CLI, Cursor, or other agents).
development
Walks through a structured production readiness checklist for Scalekit SSO implementations. Use when the user says they are going live, launching to production, doing a pre-launch review, hardening their SSO setup, or wants to verify their Scalekit implementation is production-ready.
development
Walks through a structured production readiness checklist for Scalekit SCIM provisioning implementations. Use when the user says they are going live, launching to production, doing a pre-launch review, or wants to verify their SCIM directory sync implementation is production-ready.