/saaskit:manage-saaskit-sessionsfrom saaskit
Manages SaaSKit sessions so an agent can store, validate, refresh, and revoke a session. Use when the user wants a session, refresh, or revoke. It does not write login, callback, or logout (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.
None: SKILL.md is the whole skill.
Store, validate, refresh, and revoke a session. Then stop.
implement-saaskit instead.implement-saaskit.Authorization: Bearer; refresh in an HttpOnly cookie or a secure store.HttpOnly, Secure in production, sameSite: 'lax'. Path-scope access to /api and refresh to /auth/refresh.implement-saaskit already set. Read them as-is.encrypt / decrypt are app-owned helpers, not Scalekit SDK methods. Optional only. If you add them, rewrite those same cookies.refreshAccessToken returns { accessToken, refreshToken } only. Reuse a short access-cookie lifetime.verifySession returns 401. It does not call /auth/refresh. The page does.scalekit.session.*. That is not the logout redirect.implement-saaskit already set accessToken (path: '/api'), refreshToken (path: '/auth/refresh'), and idToken (path: '/'). Use those values as-is.
Encrypt is optional. If you add it, rewrite those same cookies. Do not add a second store.
SPA: keep the access token in memory. Send Authorization: Bearer. Store the refresh token in an HttpOnly cookie or a secure store.
Done when: the app reads the cookies that skill already set, or an SPA memory store is in place.
import { ScalekitClient } from '@scalekit-sdk/node';
const scalekit = new ScalekitClient(
process.env.SCALEKIT_ENVIRONMENT_URL,
process.env.SCALEKIT_CLIENT_ID,
process.env.SCALEKIT_CLIENT_SECRET
);
export async function verifySession(req, res, next) {
const accessCookie = req.cookies?.accessToken;
if (!accessCookie) {
return res.status(401).json({ error: 'Authentication required' });
}
const isValid = await scalekit.validateAccessToken(accessCookie);
if (isValid) return next();
return res.status(401).json({ error: 'Session expired' });
}
Mount this on /api/* only. SPA: read the Bearer token from Authorization. Do not read an access-token cookie.
Done when: a protected /api route calls validateAccessToken before the handler.
/auth/refreshThe refresh cookie is path-scoped to this route.
app.post('/auth/refresh', async (req, res) => {
const refreshCookie = req.cookies?.refreshToken;
if (!refreshCookie) {
return res.status(401).json({ error: 'Session expired. Please sign in again.' });
}
try {
const authResult = await scalekit.refreshAccessToken(refreshCookie);
res.cookie('accessToken', authResult.accessToken, {
maxAge: 4 * 60 * 1000,
httpOnly: true,
secure: process.env.NODE_ENV === 'production',
sameSite: 'lax',
path: '/api',
});
res.cookie('refreshToken', authResult.refreshToken, {
httpOnly: true,
secure: process.env.NODE_ENV === 'production',
sameSite: 'lax',
path: '/auth/refresh',
});
return res.json({ ok: true });
} catch (e) {
return res.status(401).json({ error: 'Authentication failed' });
}
});
On 401 from /api, the page calls refresh, then retries once:
const refreshed = await fetch('/auth/refresh', {
method: 'POST',
credentials: 'include',
});
if (!refreshed.ok) location.href = '/auth/login';
// retry the /api request once
SPA: same call. Return { accessToken: authResult.accessToken } from the route, store it in memory, and retry. Do not set an access-token cookie.
Done when: a 401 from /api calls /auth/refresh then retries, and a failed refresh returns 401.
Use the session APIs. This is not logout.
const sessionDetails = await scalekit.session.getSession('ses_1234567890123456');
const userSessions = await scalekit.session.getUserSessions('usr_1234567890123456', {
pageSize: 10,
filter: { status: ['active'] },
});
await scalekit.session.revokeSession('ses_1234567890123456');
await scalekit.session.revokeAllUserSessions('usr_1234567890123456');
Done when: the app can list, revoke one, and revoke all.
Do not write login, callback, or the logout redirect.
Done when: store, validate, refresh, and revoke are in the repo, and this skill has stopped.
implement-saaskit for login, callback, cookies, and logoutsetup-saaskit if env is missingimplement-access-control for roles and permissionsWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
15 skills in this plugin
/add-api-authAdds 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`).
/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`).
/implement-access-controlImplements roles and permissions at a route so an agent can protect an endpoint. Use when the user wants roles, permissions, or RBAC. It does not write SaaSKit login (that's `implement-saaskit`).
/implement-saaskitImplements SaaSKit login so an agent can add a login route, a callback, session cookies, and logout. Use when the user wants to add SaaSKit login, a callback, or logout. It does not store, validate, refresh, or revoke a session after login (that's `manage-saaskit-sessions`) or write Next.js App Router auth (that's `implement-saaskit-nextjs`) or write Django, FastAPI, or Flask auth (that's `implement-saaskit-python`).
npx claudepluginhub scalekit-inc/authstack --plugin saaskit