/saaskit:add-api-authfrom saaskit
Adds API key or client-credentials auth so an agent can protect an API. Use when the user wants an API key or client credentials. It does not put OAuth 2.1 on an MCP server (that's `add-mcp-oauth`) or write SaaSKit login (that's `implement-saaskit`).
Ships in saaskit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Add an API key or client credentials to protect an API. Then stop.
SCALEKIT_ENVIRONMENT_URL, SCALEKIT_CLIENT_ID, SCALEKIT_CLIENT_SECRET from env. MUST NOT hardcode them.token / plainSecret once from the create path. Store tokenId for list and invalidate. MUST NOT log or commit the secret.createToken on that path.SCALEKIT_ENV_URL. Do not prepend https:// if the env URL already has a scheme.org_… values.scalekit.token.validateToken is for opaque keys. scalekit.validateToken is for JWTs. Do not mix them.@scalekit-sdk/node only when the repo has no Scalekit SDK yet./oauth/token → open references/client-credentials.md. Stay on that file.Print this checklist. Ask the human to write missing SCALEKIT_ENVIRONMENT_URL, SCALEKIT_CLIENT_ID, SCALEKIT_CLIENT_SECRET, and the organization ID into .env. Then write create, validate, list, and invalidate. Do not wait.
org_… values.Done when: this skill is the right path, the three env names exist, and the organization ID is named as a dashboard copy.
Install @scalekit-sdk/node only when the repo has no Scalekit SDK yet.
import { ScalekitClient, ScalekitValidateTokenFailureException } from '@scalekit-sdk/node';
const scalekit = new ScalekitClient(
process.env.SCALEKIT_ENVIRONMENT_URL,
process.env.SCALEKIT_CLIENT_ID,
process.env.SCALEKIT_CLIENT_SECRET
);
Done when: the client initializes from those env vars.
organizationId is the dashboard value from Step 1.
const response = await scalekit.token.createToken(organizationId, {
description: 'CI/CD pipeline token',
});
const opaqueToken = response.token;
const tokenId = response.tokenId;
Print opaqueToken once to stdout. Then drop it. Store tokenId (apit_…). Scalekit cannot return the secret later.
If env is missing, still write this create path. Quote the one-time print in the reply (token: <response.token>). Do not invent a token string. Do not call Scalekit.
Done when: the create path prints token once, and the app stored tokenId.
async function authenticateToken(req, res, next) {
const header = req.headers.authorization || '';
const token = header.startsWith('Bearer ') ? header.slice(7) : '';
if (!token) return res.status(401).json({ error: 'Missing authorization token' });
try {
const result = await scalekit.token.validateToken(token);
req.tokenInfo = result.tokenInfo;
next();
} catch (error) {
if (error instanceof ScalekitValidateTokenFailureException) {
return res.status(401).json({ error: 'Invalid or expired token' });
}
throw error;
}
}
app.get('/api/resources', authenticateToken, (req, res) => {
const { organizationId, userId } = req.tokenInfo;
});
Done when: a protected /api route calls validateToken before the handler, and invalid keys return 401.
const listed = await scalekit.token.listTokens(organizationId, { pageSize: 10 });
await scalekit.token.invalidateToken(tokenId);
Invalidate is instant and idempotent. Rotate: create new → update consumer → verify → invalidate old.
Done when: the app can list keys and invalidate one.
Write the Node files and stop. Do not wait. Do not write MCP OAuth or SaaSKit login.
Done when: create, validate, list, and invalidate are in the repo, and this skill has stopped.
setup-saaskit if env is missingadd-mcp-oauth to put OAuth 2.1 on an MCP serverimplement-saaskit for SaaSKit loginWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub scalekit-inc/authstack --plugin saaskitOther plugins' skills for the same job
15 skills in this plugin
/add-mcp-oauthAdds MCP OAuth so an agent can protect the user's MCP server. Use when the user wants MCP OAuth or to protect their MCP server. It does not add API keys or client credentials (that's `add-api-auth`) or expose AgentKit tools over MCP (that's `expose-agentkit-mcp`).
/check-saaskit-prodChecks SaaSKit production so an agent can finish a go-live checklist. Use when the user wants SaaSKit production or to go live SaaSKit. It does not write login (that's `implement-saaskit`) or run dryrun (that's `run-dryrun`).
/deploy-self-hostedDeploys self-hosted Scalekit so an agent can install Helm or on-prem. Use when the user wants self-hosted Scalekit or Helm. It does not write SaaSKit login (that's `implement-saaskit`).