/auth-implementation

Sign-in, sessions and an access matrix enforced next to every protected read and write.

Build·Sign-in → Access·MIT
$npx skills add tushaarmehtaa/tushar-skills --skill auth-implementation -g -a claude-code -y

Then type /auth-implementation in Claude Code, or describe the task and let it pick the skill.

What you get back contract tests · 9 Oct 2026

claude · tallyroom

Using /auth-implementation
  • Another group's ID → 404
  • Group data stays server-only
  • Stripe key leak removed
Signed-out visitors go to sign-in. Members only see their own groups.
Claude Code 2.1.295·1m 55s·13 files changed
  • Clerk sign-in is now in place. Signed-out visitors can't open the dashboard or start a checkout, and the dashboard only shows groups the signed-in person belongs to. The build passes and I checked the signed-out case against the running server. I haven't tested a real sign-in, because the keys in .env.local are fake test values, so the signed-in pages are still unchecked end to end.
  • Checks sit next to the data: the dashboard page and the new checkout route each check who is signed in themselves, so protection doesn't depend on proxy.js alone.
  • One security fix you didn't ask for: lib/checkout.js was putting the first 7 characters of STRIPE_SECRET_KEY into the checkout URL, and its fallback key string was bundled into code sent to the browser. I removed both, and the file is now server-only too.
CaveatRan with test Clerk keys; no real sign-in was tested, and group membership is a stub setting.

Measured before → after

PageSigned outSigned in, not a memberSigned in, member
/, /pricing, /sign-in, /sign-upopenopenopen
/dashboardsent to sign-in"No groups yet" messagetheir groups only
/dashboard?group=<id>sent to sign-in404that group
/checkout/<plan>sent to sign-in, then back aftercontinues to checkoutcontinues to checkout

Input → output from the run

app/dashboard/page.jsx before
export default function Dashboard() {
  const total = expenses.reduce((s, e) => s + e.amount, 0);
  return (
    <main className="page">
      <h1>Flat 4B — Indiranagar</h1>
app/dashboard/page.jsx after
import { auth } from "@clerk/nextjs/server";
import { notFound } from "next/navigation";
import { getGroupForUser, listGroupsForUser } from "../../lib/groups";

export default async function Dashboard({ searchParams }) {
  const { userId, redirectToSignIn } = await auth();
  if (!userId) return redirectToSignIn();

  const groups = listGroupsForUser(userId);

When to use it

Use when

Use when adding sign-in, identity sync, account linking, roles or access control.

Skip it when

Skip it if you want a new identity provider picked for you; it keeps the one you have unless you decide to switch.

The thinking behind it

Sign-in is the easy part. Making every route check who's asking is the hard part. Get both right and nobody reads data that isn't theirs.

Output contract from the skill's Output section

Report provider/version and identity model, files/migrations changed, access matrix and enforcement points, sync strategy, RLS/grants, environment-variable names, automated verification evidence, and manual dashboard/backfill/production checks.

How it checks its own work from the instructions

  • New sign-up, returning login, logout, and expiry are tested
  • Every protected resource rejects unauthenticated and other-user requests
  • Cross-tenant and non-admin access is tested and denied
  • Replayed sync and account linking are tested

Requirements what it needs

Works in
Codex, Claude Code, Cursor
Needs
project files, terminal commands, network access

The instructions SKILL.md · 33 lines

Instructions & references

Back to overview ↑
On this page 4 sections
SKILL.md · MIT

Authentication implementation

Implement identity and authorization end to end. Prefer the existing provider. Do not introduce or replace an identity system without an explicit user decision.

Workflow

  1. Detect framework/router version, auth package and version, database/ORM, session transport, user/account tables, tenant model, middleware or proxy, protected resources, and existing migrations.
  2. Distinguish authentication from authorization. Write an access matrix for public, signed-in, owner, team member, admin, and service/background paths that actually exist.
  3. Decide whether a local user mirror is necessary. If it is, model provider identities separately from application users when multiple login methods or providers are possible. Never link accounts from an unverified client-supplied email.
  4. Ask only when a material choice remains: provider selection, account-linking policy, deletion behavior, organization/tenant model, or whether existing users must be backfilled.
  5. Use the matching provider reference only after detecting the exact stack and installed version:
    • Clerk for current Next.js Clerk protection and verified user synchronization.
    • Auth.js for current Auth.js/NextAuth handlers, adapters, sessions, and route protection.
    • Supabase Auth for public-profile synchronization and Supabase session handling.
    • For Firebase, Auth0, custom JWT, or a provider/database combination not covered, preserve existing code and consult current primary provider documentation instead of adapting an incompatible example.
  6. Enforce access next to every protected read/mutation. Middleware/proxy may provide broad routing, but it is not the sole authorization boundary.
  7. For Supabase Data API access, implement RLS and grants with the actual token strategy. Add both using and with check where ownership may change. Service credentials stay server-only; do not create redundant service-role policies when the credential already bypasses RLS.
  8. Make sync idempotent and verifiable. Prefer signed provider webhooks for lifecycle sync, or fetch authoritative provider data on the server for just-in-time sync. Handle create, update, deletion, replay, out-of-order delivery, and backfill.

Verification

Test new sign-up, returning login, logout, expiry/refresh, account switching, verified linking, provider update/deletion, and replayed sync. For every protected resource, run negative tests as unauthenticated, another user, another tenant, and a non-admin; test permitted owner/admin/service cases separately. Run migrations and the repository’s lint/type/test/build commands in the target runtime.

Output

Report provider/version and identity model, files/migrations changed, access matrix and enforcement points, sync strategy, RLS/grants, environment-variable names, automated verification evidence, and manual dashboard/backfill/production checks.

View on GitHub ↗
Claude app, ChatGPT and ZIP download

local coding agent required

This skill requires project files, terminal commands, and network access. Uploading it to a chat app does not provide equivalent execution.

ChatGPT Skills

This workflow needs a local coding environment or capabilities that a chat-only Skills upload does not provide.

Package details
Package
auth-implementation/SKILL.md
Author
@tushaarmehtaa
Added
7 Mar 2026
Tags
authclerkauthjssupabaseauthorizationrlssessions