.claude/skills/pikku-auth-js/SKILL.md
Use when integrating Auth.js (NextAuth) with a Pikku app. Covers createAuthHandler, createAuthRoutes, and Auth.js configuration. TRIGGER when: code uses createAuthHandler, createAuthRoutes, user asks about Auth.js, NextAuth, OAuth providers, or @pikku/auth-js. DO NOT TRIGGER when: user asks about JWT middleware (use pikku-security) or custom session services (use pikku-services).
npx skillsauth add pikkujs/pikku pikku-auth-jsInstall 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.
@pikku/auth-js provides Auth.js integration for Pikku apps, handling OAuth providers, session management, and auth routes.
yarn add @pikku/auth-js @auth/core
createAuthHandler(config)Creates a Pikku function that handles all Auth.js routes (signin, signout, callback, etc.):
import { createAuthHandler } from '@pikku/auth-js'
const authHandler = createAuthHandler(
config: AuthConfig | ((services: CoreSingletonServices) => AuthConfig | Promise<AuthConfig>)
)
// Returns: { func: CorePikkuFunctionSessionless }
The config can be static or a factory function that receives singleton services (useful for dynamic provider configuration).
createAuthRoutes(config, basePath?)Creates HTTP route contracts for Auth.js endpoints:
import { createAuthRoutes } from '@pikku/auth-js'
const authRoutes = createAuthRoutes(
config: AuthConfig | ((services) => AuthConfig | Promise<AuthConfig>),
basePath?: string // default: '/auth'
)
// Returns: HTTPRouteContract<HTTPRouteMap>
import { createAuthHandler, createAuthRoutes } from '@pikku/auth-js'
import GitHub from '@auth/core/providers/github'
const authConfig = {
providers: [
GitHub({
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
}),
],
}
const authHandler = createAuthHandler(authConfig)
const authRoutes = createAuthRoutes(authConfig)
const authHandler = createAuthHandler(async (services) => {
const githubSecret = await services.secrets.getSecretJSON('github-oauth')
return {
providers: [
GitHub({
clientId: githubSecret.clientId,
clientSecret: githubSecret.clientSecret,
}),
],
}
})
import { wireHTTPRoute } from '@pikku/core/http'
// Auth routes are automatically wired when passed to your HTTP runner
const routes = [
...authRoutes,
// ...your other routes
]
documentation
Deprecated — use pikku-middleware instead. Tag middleware (addTagMiddleware) is now documented as a section within the pikku-middleware skill, alongside global HTTP middleware, execution order, and the service-to-service bearer auth pattern.
testing
Use when adding authorization checks to Pikku functions or routes — pikkuPermission, pikkuAuth, per-function permissions, pattern-based permissions, or understanding OR/AND permission logic. TRIGGER when: user wants to restrict who can call a function, check resource ownership, add role-based access, or understand where permission checks belong. DO NOT TRIGGER when: user asks about middleware or request interception (use pikku-middleware), authentication strategies (use pikku-security), or session management.
testing
Use when adding any middleware to a Pikku app — global HTTP middleware, tag-scoped middleware (including service-to-service bearer auth), per-route middleware, session-setting middleware, or understanding middleware execution order and priority. TRIGGER when: user wants middleware on some or all routes, machine-to-machine auth, tag-scoped cross-cutting concerns, global interceptors, or middleware priority/order questions. DO NOT TRIGGER when: user asks about permissions/authorization checks (use pikku-permissions), auth strategies like authBearer/authCookie (use pikku-security), or deployment.
documentation
Standard cleanup to run right after a Pikku template is cloned or scaffolded into a new project. TRIGGER when: a Pikku template was just cloned/scaffolded (via `pikku create`, `git clone <template>`, or the user says "I cloned the kanban template / starter / template"), or the working tree still looks like an untouched template (template README, placeholder `@project/*` name in package.json). DO NOT TRIGGER when: working in an established project mid-feature, or editing the template repo itself.