supabase
Handles the full Supabase workflow from schema changes to deployment, with built-in security guardrails that catch common traps like RLS...
moai-core-spec-authoring
Complete SPEC document authoring guide with YAML metadata structure (7
Full skill instructions
---
code: SPEC-001
title: Add User Authentication with JWT
status: stable
created_at: 2025-11-13
updated_at: 2025-11-13
priority: high
effort: 8
version: "4.0.0"
epic: AUTH-01
domains:
- backend
- security
- database
---
# SPEC-001: Add User Authentication with JWT
## Overview
Implement secure JWT-based user authentication with password hashing and token validation.
## Requirements
### REQ-001 (Universal)
SPEC: The authentication service SHALL validate JWT tokens using RS256 algorithm against the public key.
### REQ-002 (Conditional)
SPEC: If a JWT token has expired, then the authentication service SHALL reject the request and return HTTP 401.
### REQ-003 (Unwanted Behavior)
SPEC: The authentication service SHALL NOT accept JWT tokens signed with symmetric algorithms (HS256, HS384, HS512).
### REQ-004 (Stakeholder)
As an API consumer, I want to pass JWT tokens in the Authorization header so that my requests are authenticated.
### REQ-005 (Boundary Condition)
SPEC: The authentication service SHALL return HTTP 429 when a single IP attempts more than 10 failed authentications in 5 minutes.
## Unwanted Behaviors
### Security Constraints
- The system SHALL NOT store JWT secrets in source code
- The system SHALL NOT log JWT tokens or sensitive claims
### Performance Constraints
- The system SHALL NOT block on token validation (async pattern)
- The system SHALL NOT cache tokens indefinitely
## Acceptance Criteria
- [ ] All 5 REQ patterns implemented and tested
- [ ] Code coverage ≥85%
- [ ] Security scan passed (OWASP Top 10)
- [ ] Performance: JWT validation p99 latency ≤200ms
| Pattern | Syntax | Use Case |
|---|---|---|
| Universal | The [System] SHALL [Action] | Core system behavior |
| Conditional | If [Condition], then [System] SHALL [Action] | Conditional logic |
| Unwanted Behavior | The [System] SHALL NOT [Action] | Security constraints |
| Stakeholder | As a [Role], I want [Feature] so that [Benefit] | User stories |
| Boundary Condition | [System] SHALL [Action] when [Condition] | Edge cases |
---
# SPEC identifier (auto-generated)
code: SPEC-001
# SPEC title (descriptive, 50-80 chars)
title: Add User Authentication with JWT
# SPEC status (draft | active | deprecated | archived)
status: stable
# Creation timestamp (ISO 8601: YYYY-MM-DD)
created_at: 2025-11-13
# Last updated timestamp (ISO 8601: YYYY-MM-DD)
updated_at: 2025-11-13
# Business priority (critical | high | medium | low)
priority: high
# Estimated effort in story points (1-13 scale)
effort: 8
---
# Version tracking (semantic versioning: major.minor.patch)
version: "4.0.0"
# Deadline target date (ISO 8601: YYYY-MM-DD)
deadline: 2025-12-15
# Epic this SPEC belongs to (e.g., AUTH-01, ONBOARDING-02)
epic: AUTH-01
# Related SPEC codes (dependencies or conflicts)
depends_on:
- SPEC-002
- SPEC-003
# Affected domains (for routing to specialists)
domains:
- backend
- security
- database
# Acceptance criteria complexity rating
acceptance_difficulty: high
# Rollback complexity rating (critical | high | medium | low)
rollback_risk: medium
# Risk assessment notes
risks: |
- Security: JWT key rotation must be tested
- Performance: Token validation on every request
# Custom tags for filtering/searching
tags:
- authentication
- security
- jwt
- users
Syntax:
SPEC: The [System] SHALL [Action]
Example:
SPEC-001-REQ-001: The authentication service SHALL validate
all JWT tokens using RS256 algorithm against the public key.
Related TEST:
- test_valid_jwt_with_rs256_signature
- test_invalid_jwt_with_wrong_algorithm
Syntax:
SPEC: If [Condition], then the [System] SHALL [Action]
Example:
SPEC-001-REQ-002: If a JWT token has expired,
then the authentication service SHALL reject the request
and return HTTP 401 Unauthorized with error code TOKEN_EXPIRED.
Related TEST:
- test_expired_token_returns_401
- test_expired_token_error_message
Syntax:
SPEC: The [System] SHALL NOT [Action]
Example:
SPEC-001-REQ-003: The authentication service SHALL NOT
accept JWT tokens signed with symmetric algorithms (HS256, HS384, HS512)
in a production environment.
Related TEST:
- test_reject_hs256_signed_token
- test_reject_hs384_signed_token
- test_reject_hs512_signed_token
Syntax:
SPEC: As a [User Role], I want [Feature] so that [Benefit]
Example:
SPEC-001-REQ-004: As an API consumer,
I want to pass JWT tokens in the Authorization header
so that my requests are authenticated without exposing tokens.
Related TEST:
- test_jwt_from_authorization_header
- test_jwt_in_query_param_rejected
- test_malformed_authorization_header
Syntax:
SPEC: [System] SHALL [Action] when [Boundary Condition]
Example:
SPEC-001-REQ-005: The authentication service SHALL return
HTTP 429 Too Many Requests when a single IP address
attempts more than 10 failed authentication attempts within 5 minutes.
Related TEST:
- test_rate_limit_after_10_failures
- test_rate_limit_window_5_minutes
- test_rate_limit_by_ip_address
DRAFT → ACTIVE → DEPRECATED → ARCHIVED
↓ ↓
Under Review Stable, In Use
↓ ↓
Changes Expected Changes Require
Feedback Pending Major Version Bump
DRAFT → ACTIVE:
version bumped to 1.0.0ACTIVE → DEPRECATED:
DEPRECATED → ARCHIVED:
Critical security and quality constraints that MUST be tested:
unwanted_behaviors:
security:
- The system SHALL NOT store JWT secrets in source code
- The system SHALL NOT log JWT tokens or sensitive claims
- The system SHALL NOT accept mixed algorithm tokens
performance:
- The system SHALL NOT block on token validation (async pattern)
- The system SHALL NOT cache tokens indefinitely
reliability:
- The system SHALL NOT fail authentication if secondary cache is down
- The system SHALL NOT accept malformed JSON Web Tokens
data_integrity:
- The system SHALL NOT modify token claims during validation
- The system SHALL NOT accept tokens from untrusted issuers
Each Unwanted Behavior requires:
↓
↓
↓
SPEC Document:
---
# SPEC-001: Feature Name
---
Test File:
def test_requirement_001():
"""Test SPEC-001 REQ-001 universal pattern."""
pass
Implementation:
def authenticate_user(token: str) -> bool:
"""Validate JWT token per SPEC-001."""
pass
Documentation:
## Authentication Flow
Per SPEC-001, the system SHALL validate all JWT tokens...
code field filled (SPEC-XXX format)title is descriptive (50-80 characters)status is one of: draft | active | deprecated | archivedcreated_at is ISO 8601 format (YYYY-MM-DD)updated_at matches actual update datepriority is one of: critical | high | medium | loweffort is between 1-13 (story points)Bad:
SPEC-001-REQ-001: The system should authenticate users quickly.
Good:
SPEC-001-REQ-001: The authentication service SHALL validate JWT tokens
and return a response within 50ms on average,
with p99 latency not exceeding 200ms.
Bad:
- The feature should work
- Tests should pass
- No obvious bugs
Good:
- [ ] All 12 test cases pass (unit + integration)
- [ ] Code coverage ≥85% (src/auth/validate.py)
- [ ] Security scan: OWASP Top 10 coverage complete
- [ ] Performance: JWT validation p99 latency ≤200ms
Bad:
# (No unwanted_behaviors section)
Good:
unwanted_behaviors:
security:
- The system SHALL NOT store plaintext passwords
- The system SHALL NOT log authentication tokens
Automatic Triggers:
/alfred:1-plan command executionManual Invocation:
moai-core-best-practices - TRUST 5 principles for SPEC authoringmoai-core-spec-validation - Automated SPEC validationmoai-foundation-specs - SPEC lifecycle managementmoai-foundation-trust - Security and compliance principlesmoai-core-workflow - SPEC creation workflowsTest First: All requirements include test cases and validation criteria Readable: Clear EARS syntax with unambiguous language Unified: Consistent structure across all SPEC documents Secured: Unwanted Behaviors section with security constraints Traceable: TAG integration for complete requirement traceability
Enterprise Compliance: Progressive disclosure with comprehensive EARS syntax, validation checklists, and lifecycle management.
Last Updated: 2025-11-18
Dependencies: YAML metadata format, EARS specification, TAG system
See Also: examples.md for detailed SPEC examples
Handles the full Supabase workflow from schema changes to deployment, with built-in security guardrails that catch common traps like RLS...
Comprehensive guides and best practices for Neon Serverless Postgres, covering setup, connection methods, authentication, and platform APIs.
Guide for setting up and using Firebase Authentication. Use this skill when the user's app requires user sign-in, user management, or secure data access using auth rules.
A skill to evaluate how secure Firestore security rules are. Use this when Firestore security rules are updated to ensure that the generated rules are extremely secure and robust.
Official skill for integrating Firebase AI Logic (Gemini API) into web applications. Covers setup, multimodal inference, structured output, and security.
Complete Better Auth server and client setup with database adapters, session management, plugins, and security configuration.
Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".
Complete Cloudflare platform integration with decision trees for compute, storage, AI, networking, security, and infrastructure-as-code.
Run Azure compliance and security audits with azqr plus Key Vault expiration checks. Covers best-practice assessment, resource review, policy/compliance validation, and security posture checks. WHEN: compliance scan, security audit, BEFORE running azqr (compliance cli tool), Azure best practices, Key Vault expiration check, expired certificates, expiring secrets, orphaned resources, compliance assessment.
Send, read, and manage Gmail messages, drafts, labels, and account settings.
Comprehensive website auditing across 230+ rules in 21 categories including SEO, performance, security, and accessibility.
Shared authentication, CLI syntax, and output formatting patterns for gws Google Workspace commands.
Discover your celebrity doppelgänger with StarByFace!
GeoSpy: Pricing, Features, FAQs, and Alternatives for AI Teams
Detect AI-generated voices to protect against audio fraud.
Ensure Your Content's Originality with AI Plagiarism Checker
Upscale images by 400% without quality loss
Protect your social media from copyright disputes
Accurately Detect AI-Generated Content with TheChecker.AI
Chrome extension that detects and flags AI-generated content