auth-flow-planner
Designs a secure authentication and authorization flow for any application, covering login, sessions, roles, and edge cases.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Designs a secure authentication and authorization flow for any application, covering login, sessions, roles, and edge cases.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Runs a systematic checklist review on any code diff or file, covering correctness, security, performance, and readability.
Writes a high-quality CLAUDE.md, .cursorrules, or .windsurfrules file that gives a coding agent the right project context, conventions, and constraints to work effectively.
Designs an eval suite for an LLM agent or pipeline including success metrics, trajectory scoring, LLM-as-judge setup, and regression test cases.
Designs a hybrid retrieval pipeline combining dense vector search and BM25 sparse search with reciprocal rank fusion, and explains when to use each configuration.
Converts a workflow description into a LangGraph node/edge graph with typed state, conditional routing, and human-in-the-loop checkpoints.
Audits an AI application for unnecessary token spend and recommends prompt caching, model routing, and token reduction techniques to cut costs.
| name | Auth Flow Planner |
| description | Designs a secure authentication and authorization flow for any application, covering login, sessions, roles, and edge cases. |
| category | coding |
| tags | ["auth","security","backend","jwt","oauth"] |
| author | simplyutils |
This skill designs a complete authentication and authorization flow for any application. It covers the full lifecycle: registration, login, session management, token refresh, password reset, role-based access control, and all the edge cases (expired tokens, concurrent sessions, brute force protection). The output is a detailed design document with flow diagrams, endpoint definitions, data models, and security considerations — ready to hand off to engineering.
Use this when starting a new application, when auditing an existing auth system, or when extending your auth with new features (OAuth, MFA, roles).
Copy this file to .agents/skills/auth-flow-planner/SKILL.md in your project root.
Then ask:
Provide context about:
Add the instructions below to your .cursorrules or paste them into the Cursor AI pane with your application context.
Provide the application context and ask Codex to follow the instructions below to produce the auth design.
When asked to plan an authentication flow, follow these steps:
Gather:
If any of this is unclear, state your assumptions and proceed.
Recommend one of:
Stateless JWT — Good for: API-only services, microservices, when you can't or don't want to maintain session state.
Stateful sessions (server-side) — Good for: traditional web apps, when you need instant revocation, when security > scalability.
Hybrid (recommended for most SaaS) — Short-lived JWT for requests, refresh token stored in session table for revocation control.
For each of the following flows, produce:
Required flows to cover:
If roles are required:
For every flow, verify these protections are designed in:
Brute force protection
Token security
CSRF protection
Password storage
Session fixation
Sensitive operations
# Auth Flow Design — [Application Name]
## Strategy Summary
[2–3 sentences on chosen session approach and why]
## User Roles
| Role | Permissions |
|------|-------------|
| [Role] | [What they can do] |
## Flows
### [Flow Name]
**Purpose**: [What this flow achieves]
**Steps**:
1. [Step 1]
2. [Step 2]
...
**Endpoints**:
- `POST /api/auth/[action]` — Request: `{ field }` — Response: `{ field }`
**Security notes**: [Any specific considerations]
---
[Repeat for each flow]
## Data Models
### users table
| Column | Type | Notes |
|--------|------|-------|
| id | uuid | Primary key |
| email | text | Unique, indexed |
| password_hash | text | bcrypt |
| ...
### sessions / refresh_tokens table
[If stateful]
## Security Checklist
- [ ] Rate limiting on login endpoint
- [ ] Refresh token rotation
- [ ] HttpOnly cookies for refresh token
- [ ] CSRF protection
- [ ] bcrypt for password hashing
- [ ] Re-auth for sensitive operations
Input to Agent:
"Use the Auth Flow Planner skill. Building a SaaS web app with: email/password login, Google OAuth, two roles (admin and member), Node.js/Express backend, React frontend. No MFA for now. Users belong to organizations."
Output from Agent:
Auth Flow Design — SaaS App
Strategy Summary
Hybrid approach: short-lived JWTs (15 min) for authenticated requests, with refresh tokens stored in a database table and delivered via HttpOnly cookie. This allows instant revocation (important for deactivating team members) while keeping request validation stateless.
User Roles
Role Permissions Owner Full access to org settings, billing, member management, all features Admin Manage members, all features, no billing access Member Access to product features, no admin settings Flows
1. Registration (Email/Password)
Steps:
- User submits email + password via
POST /api/auth/register- Server validates: email format, password strength (min 8 chars), email not already registered
- Hash password with bcrypt (cost factor 12)
- Create
usersrecord withemail_verified: false- Create initial
organizationsrecord, set user as Owner- Send verification email with a signed token (valid 24h)
- Return
{ message: "Check your email to verify your account" }— do not auto-login before verificationEndpoints:
POST /api/auth/register—{ email, password, orgName }→{ message }Security notes: Rate limit to 5 registrations per IP per hour. Do not reveal whether an email is already registered (return the same message either way to prevent enumeration).
2. Login
Steps:
- User submits email + password via
POST /api/auth/login- Server looks up user by email; if not found, return generic error (no enumeration)
- Verify password with bcrypt; if wrong, increment failed attempt counter
- After 5 failed attempts from same IP in 15 min, return 429 with
retryAfter- Check
email_verified: true; if not, return 403 with "Please verify your email"- Generate access JWT (15 min expiry, payload:
{ userId, orgId, role })- Generate refresh token (random 64-byte hex), store in
refresh_tokenstable with expiry 30 days- Set refresh token in HttpOnly, Secure, SameSite=Strict cookie
- Return access token in response body
Endpoints:
POST /api/auth/login—{ email, password }→{ accessToken, user }
bcrypt, jsonwebtoken, passport, lucia, better-auth, or a managed service like Auth0, Clerk, or Supabase Auth.