cfsa-antigravity 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +54 -0
  3. package/package.json +46 -32
  4. package/template/.agent/kit-sync.md +1 -1
  5. package/template/.agent/skill-library/MANIFEST.md +20 -10
  6. package/template/.agent/skill-library/stack/auth/lucia/SKILL.md +230 -0
  7. package/template/.agent/skill-library/stack/auth/supabase-auth/SKILL.md +293 -0
  8. package/template/.agent/skill-library/stack/extensions/plasmo/SKILL.md +195 -0
  9. package/template/.agent/skill-library/stack/extensions/wxt/SKILL.md +216 -0
  10. package/template/.agent/skill-library/stack/feature-flags/flagsmith/SKILL.md +187 -0
  11. package/template/.agent/skill-library/stack/feature-flags/launchdarkly/SKILL.md +183 -0
  12. package/template/.agent/skill-library/stack/feature-flags/posthog-flags/SKILL.md +189 -0
  13. package/template/.agent/skill-library/stack/messaging/nats/SKILL.md +147 -0
  14. package/template/.agent/skill-library/stack/messaging/rabbitmq/SKILL.md +178 -0
  15. package/template/.agent/skill-library/stack/messaging/sqs/SKILL.md +187 -0
  16. package/template/.agent/skill-library/stack/mobile/kotlin-compose/SKILL.md +215 -0
  17. package/template/.agent/skill-library/stack/mobile/swiftui/SKILL.md +261 -0
  18. package/template/.agent/skill-library/stack/notifications/fcm/SKILL.md +229 -0
  19. package/template/.agent/skill-library/stack/notifications/sendgrid/SKILL.md +220 -0
  20. package/template/.agent/skill-library/stack/notifications/twilio/SKILL.md +204 -0
  21. package/template/.agent/skill-library/stack/search/algolia/SKILL.md +206 -0
  22. package/template/.agent/skill-library/stack/search/typesense/SKILL.md +189 -0
  23. package/template/.agent/skill-library/stack/storage/cloudflare-r2/SKILL.md +252 -0
  24. package/template/.agent/skill-library/stack/storage/gcs/SKILL.md +229 -0
  25. package/template/.agent/skills/accessibility/references/ia-spec-checklist.md +35 -0
  26. package/template/.agent/skills/adversarial-review/SKILL.md +1 -1
  27. package/template/.agent/skills/api-design-principles/SKILL.md +153 -21
  28. package/template/.agent/skills/architecture-mapping/SKILL.md +11 -11
  29. package/template/.agent/skills/brainstorming/SKILL.md +113 -172
  30. package/template/.agent/skills/clean-code/SKILL.md +243 -87
  31. package/template/.agent/skills/concise-planning/SKILL.md +74 -35
  32. package/template/.agent/skills/database-schema-design/SKILL.md +2 -2
  33. package/template/.agent/skills/idea-extraction/SKILL.md +239 -110
  34. package/template/.agent/skills/minimalist-surgical-development/SKILL.md +109 -43
  35. package/template/.agent/skills/pipeline-rubrics/references/ia-rubric.md +2 -2
  36. package/template/.agent/skills/pipeline-rubrics/references/scoring.md +1 -1
  37. package/template/.agent/skills/prd-templates/SKILL.md +5 -5
  38. package/template/.agent/skills/prd-templates/references/architecture-design-template.md +1 -1
  39. package/template/.agent/skills/prd-templates/references/decomposition-templates.md +3 -3
  40. package/template/.agent/skills/prd-templates/references/design-system-prerequisite-check.md +18 -0
  41. package/template/.agent/skills/prd-templates/references/ideation-crosscut-template.md +57 -0
  42. package/template/.agent/skills/prd-templates/references/ideation-domain-template.md +55 -0
  43. package/template/.agent/skills/prd-templates/references/ideation-index-template.md +95 -0
  44. package/template/.agent/skills/prd-templates/references/ideation-meta-template.md +126 -0
  45. package/template/.agent/skills/prd-templates/references/placeholder-workflow-mapping.md +21 -0
  46. package/template/.agent/skills/prd-templates/references/spec-coverage-sweep.md +44 -0
  47. package/template/.agent/skills/prd-templates/references/vision-template.md +31 -40
  48. package/template/.agent/skills/prompt-engineer/SKILL.md +143 -189
  49. package/template/.agent/skills/resolve-ambiguity/SKILL.md +1 -1
  50. package/template/.agent/skills/session-continuity/protocols/11-parallel-synthesis.md +21 -0
  51. package/template/.agent/skills/skill-creator/SKILL.md +142 -529
  52. package/template/.agent/skills/spec-writing/SKILL.md +2 -2
  53. package/template/.agent/skills/tech-stack-catalog/SKILL.md +1 -1
  54. package/template/.agent/skills/verification-before-completion/SKILL.md +62 -110
  55. package/template/.agent/skills/workflow-automation/SKILL.md +231 -46
  56. package/template/.agent/workflows/audit-ambiguity-execute.md +22 -24
  57. package/template/.agent/workflows/audit-ambiguity.md +1 -1
  58. package/template/.agent/workflows/bootstrap-agents-provision.md +2 -17
  59. package/template/.agent/workflows/bootstrap-agents.md +2 -0
  60. package/template/.agent/workflows/create-prd-architecture.md +2 -2
  61. package/template/.agent/workflows/create-prd-compile.md +2 -2
  62. package/template/.agent/workflows/create-prd-design-system.md +3 -3
  63. package/template/.agent/workflows/create-prd-security.md +2 -2
  64. package/template/.agent/workflows/create-prd-stack.md +5 -5
  65. package/template/.agent/workflows/create-prd.md +18 -12
  66. package/template/.agent/workflows/decompose-architecture-structure.md +3 -3
  67. package/template/.agent/workflows/decompose-architecture-validate.md +2 -2
  68. package/template/.agent/workflows/decompose-architecture.md +2 -2
  69. package/template/.agent/workflows/evolve-contract.md +28 -1
  70. package/template/.agent/workflows/evolve-feature-cascade.md +1 -1
  71. package/template/.agent/workflows/evolve-feature-classify.md +4 -4
  72. package/template/.agent/workflows/evolve-feature.md +1 -1
  73. package/template/.agent/workflows/ideate-discover.md +116 -68
  74. package/template/.agent/workflows/ideate-extract.md +53 -34
  75. package/template/.agent/workflows/ideate-validate.md +129 -57
  76. package/template/.agent/workflows/ideate.md +17 -51
  77. package/template/.agent/workflows/implement-slice-setup.md +1 -1
  78. package/template/.agent/workflows/implement-slice-tdd.md +28 -48
  79. package/template/.agent/workflows/implement-slice.md +3 -1
  80. package/template/.agent/workflows/plan-phase-preflight.md +124 -0
  81. package/template/.agent/workflows/plan-phase-write.md +112 -0
  82. package/template/.agent/workflows/plan-phase.md +7 -171
  83. package/template/.agent/workflows/remediate-pipeline-assess.md +3 -3
  84. package/template/.agent/workflows/remediate-pipeline-execute.md +1 -1
  85. package/template/.agent/workflows/remediate-pipeline.md +1 -1
  86. package/template/.agent/workflows/resolve-ambiguity.md +2 -2
  87. package/template/.agent/workflows/sync-kit.md +52 -5
  88. package/template/.agent/workflows/validate-phase.md +6 -35
  89. package/template/.agent/workflows/write-architecture-spec-deepen.md +1 -1
  90. package/template/.agent/workflows/write-architecture-spec-design.md +21 -49
  91. package/template/.agent/workflows/write-architecture-spec.md +1 -1
  92. package/template/.agent/workflows/write-be-spec-classify.md +5 -3
  93. package/template/.agent/workflows/write-be-spec-write.md +2 -1
  94. package/template/.agent/workflows/write-be-spec.md +2 -2
  95. package/template/.agent/workflows/write-fe-spec-classify.md +3 -10
  96. package/template/.agent/workflows/write-fe-spec-write.md +3 -2
  97. package/template/.agent/workflows/write-fe-spec.md +4 -2
  98. package/template/AGENTS.md +11 -11
  99. package/template/GEMINI.md +13 -11
  100. package/template/docs/README.md +64 -19
  101. package/template/docs/kit-architecture.md +307 -0
  102. package/template/docs/plans/README.md +2 -1
  103. package/template/docs/plans/ideation/.gitkeep +0 -0
  104. package/template/docs/plans/ideation/README.md +23 -0
  105. package/template/docs/plans/ideation/cross-cuts/.gitkeep +0 -0
  106. package/template/docs/plans/ideation/domains/.gitkeep +0 -0
  107. package/template/docs/plans/ideation/meta/.gitkeep +0 -0
  108. package/template/.agent/skill-library/meta/brand-guidelines/SKILL.md +0 -73
  109. package/template/.agent/skill-library/meta/git-advanced/SKILL.md +0 -972
  110. package/template/.agent/skill-library/meta/regex-patterns/SKILL.md +0 -751
  111. package/template/.agent/skill-library/stack/engines/godot/SKILL.md +0 -488
  112. package/template/.agent/skill-library/stack/observability/logging-best-practices/SKILL.md +0 -168
  113. package/template/.agent/skill-library/surface/api/api-versioning/SKILL.md +0 -420
  114. package/template/.agent/skill-library/surface/api/rest-api-design/SKILL.md +0 -478
  115. package/template/.agent/skills/prompt-engineer/README.md +0 -659
  116. package/template/.agent/skills/rest-api-design/SKILL.md +0 -478
  117. package/template/.agent/skills/skill-creator/LICENSE.txt +0 -202
  118. package/template/.agent/skills/skill-creator/README.md +0 -270
  119. package/template/.agent/skills/skill-creator/references/output-patterns.md +0 -82
  120. package/template/.agent/skills/skill-creator/references/workflows.md +0 -28
  121. package/template/.agent/skills/skill-creator/scripts/init_skill.py +0 -303
  122. package/template/.agent/skills/skill-creator/scripts/package_skill.py +0 -110
  123. package/template/.agent/skills/skill-creator/scripts/quick_validate.py +0 -95
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 RepairYourTech
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # CFSA Antigravity
2
+
3
+ > Constraint-First Specification Architecture — production-grade from line one
4
+
5
+ A pipeline that turns a raw idea into exhaustively specified, test-driven, production-quality code through progressive gates. Stack-agnostic. Agent-agnostic. Cross-platform. Every line of code is production-grade from the moment it's written.
6
+
7
+ ## Quick Install
8
+
9
+ ```bash
10
+ npx cfsa-antigravity init
11
+ ```
12
+
13
+ This installs the `.agent/` folder, `docs/` structure, and agent config files into your project.
14
+
15
+ ## CLI
16
+
17
+ | Command | Description |
18
+ |---------|-------------|
19
+ | `cfsa-antigravity init` | Install the pipeline into your project |
20
+ | `cfsa-antigravity status` | Check installation + unfilled placeholders |
21
+ | `cfsa-antigravity init --force` | Overwrite existing installation |
22
+ | `cfsa-antigravity init --dry-run` | Preview what would be installed |
23
+ | `cfsa-antigravity init --path ./dir` | Install into specific directory |
24
+
25
+ ## Get Started
26
+
27
+ ```
28
+ /ideate
29
+ ```
30
+
31
+ The pipeline tells you what to run next at every step. You never have to guess.
32
+
33
+ ## Documentation
34
+
35
+ | Document | Contents |
36
+ |----------|----------|
37
+ | [Pipeline Guide](docs/README.md) | Full walkthrough — every command, every stage |
38
+ | [Kit Architecture](docs/kit-architecture.md) | How the kit's internals work |
39
+
40
+ ## Five Principles
41
+
42
+ 1. **Constraints before decisions** — map what's decided before presenting options
43
+ 2. **Exhaustive iteration over shallow speed** — no ambiguity moves forward
44
+ 3. **Work shifted left** — design decisions made in spec, not in code
45
+ 4. **Progressive decision locking** — each stage locks decisions for downstream
46
+ 5. **TDD as the implementation contract** — Red → Green → Refactor, every slice
47
+
48
+ ## Contributing
49
+
50
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for how to set up, make changes, and submit PRs.
51
+
52
+ ## License
53
+
54
+ [MIT](LICENSE)
package/package.json CHANGED
@@ -1,34 +1,48 @@
1
1
  {
2
- "name": "cfsa-antigravity",
3
- "version": "1.0.0",
4
- "description": "CFSA Pipeline — Constraint-First Specification Architecture for AI agents. Production-grade from line one.",
5
- "bin": {
6
- "cfsa-antigravity": "./bin/cli.mjs"
7
- },
8
- "files": [
9
- "bin/",
10
- "template/"
11
- ],
12
- "keywords": [
13
- "ai",
14
- "agent",
15
- "cfsa",
16
- "specification",
17
- "pipeline",
18
- "tdd",
19
- "antigravity",
20
- "production",
21
- "workflows",
22
- "skills"
23
- ],
24
- "author": "RepairYourTech",
25
- "license": "MIT",
26
- "repository": {
27
- "type": "git",
28
- "url": "https://github.com/RepairYourTech/cfsa-antigravity"
29
- },
30
- "homepage": "https://github.com/RepairYourTech/cfsa-antigravity#readme",
31
- "engines": {
32
- "node": ">=18.0.0"
33
- }
2
+ "name": "cfsa-antigravity",
3
+ "version": "2.0.0",
4
+ "description": "CFSA Pipeline — Constraint-First Specification Architecture for AI agents. Production-grade from line one.",
5
+ "scripts": {
6
+ "changeset": "changeset",
7
+ "version": "changeset version",
8
+ "build": "./scripts/build-template.sh",
9
+ "check": "./scripts/check-template-integrity.sh",
10
+ "prepare": "husky || true"
11
+ },
12
+ "bin": {
13
+ "cfsa-antigravity": "./bin/cli.mjs"
14
+ },
15
+ "files": [
16
+ "bin/",
17
+ "template/"
18
+ ],
19
+ "keywords": [
20
+ "ai",
21
+ "agent",
22
+ "cfsa",
23
+ "specification",
24
+ "pipeline",
25
+ "tdd",
26
+ "antigravity",
27
+ "production",
28
+ "workflows",
29
+ "skills"
30
+ ],
31
+ "author": "RepairYourTech",
32
+ "license": "MIT",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/RepairYourTech/cfsa-antigravity"
36
+ },
37
+ "homepage": "https://github.com/RepairYourTech/cfsa-antigravity#readme",
38
+ "engines": {
39
+ "node": ">=18.0.0"
40
+ },
41
+ "devDependencies": {
42
+ "@changesets/changelog-github": "^0.6.0",
43
+ "@changesets/cli": "^2.30.0",
44
+ "@commitlint/cli": "^20.4.4",
45
+ "@commitlint/config-conventional": "^20.4.4",
46
+ "husky": "^9.1.7"
47
+ }
34
48
  }
@@ -9,7 +9,7 @@
9
9
 
10
10
  # Kit Sync State
11
11
 
12
- upstream: https://github.com/RepairYourTech/Anti-MVP-Vibe-Pipeline
12
+ upstream: https://github.com/RepairYourTech/cfsa-antigravity
13
13
  last_synced_commit: FIRST_SYNC_PENDING
14
14
  last_synced_at: FIRST_SYNC_PENDING
15
15
  kit_version: main
@@ -75,6 +75,8 @@ When a stack key matches a value pattern (case-insensitive), install the listed
75
75
  | `API_LAYER` | `*trpc*` | `stack/api/trpc` | `trpc` |
76
76
  | `API_LAYER` | `*graphql*` | `stack/api/graphql` | `graphql` |
77
77
 
78
+ > **`{{API_DESIGN_SKILL}}` provision**: When `API_LAYER` is set, bootstrap fills `{{API_DESIGN_SKILL}}` with the matching API skill name (e.g., `trpc`, `graphql`). When `API_LAYER` is not set (REST is the default API style), `{{API_DESIGN_SKILL}}` defaults to `api-design-principles` (pre-installed). This replaces the former hardcoded `rest-api-design` reference.
79
+
78
80
  ### ORM / Data Layer
79
81
 
80
82
  | Stack Key | Value Pattern | Library Path | Installed As |
@@ -164,7 +166,7 @@ Note: `DESIGN_DIRECTION` does not copy a skill from the library — it fills pla
164
166
  |-----------|--------------|-------------|-------------|
165
167
  | `OBSERVABILITY` | `*opentelemetry*` OR `*otel*` | `stack/observability/opentelemetry` | `opentelemetry` |
166
168
  | `OBSERVABILITY` | `*distributed-tracing*` OR `*jaeger*` OR `*zipkin*` | `stack/observability/distributed-tracing` | `distributed-tracing` |
167
- | `OBSERVABILITY` | `*structured-logging*` OR `*pino*` OR `*winston*` | `stack/observability/logging-best-practices` | `logging-best-practices` |
169
+ | `OBSERVABILITY` | `*structured-logging*` OR `*pino*` OR `*winston*` | Pre-installed: `.agent/skills/logging-best-practices` | `logging-best-practices` (pre-installed) |
168
170
  | `OBSERVABILITY` | `*python*` | `stack/observability/python-observability` | `python-observability` |
169
171
  | `OBSERVABILITY` | `*datadog*` | `stack/observability/datadog` | `datadog` |
170
172
  | `OBSERVABILITY` | `*prometheus*` OR `*grafana*` | `stack/observability/prometheus-grafana` | `prometheus-grafana` |
@@ -232,6 +234,7 @@ Note: `DESIGN_DIRECTION` does not copy a skill from the library — it fills pla
232
234
  | Stack Key | Value Pattern | Library Path | Installed As |
233
235
  |-----------|--------------|-------------|-------------|
234
236
  | `MOBILE_FRAMEWORK` | `*expo*` OR `*react-native*` OR `*react native*` | `stack/mobile/react-native` | `react-native` |
237
+ | `MOBILE_FRAMEWORK` | `*expo*` | `stack/mobile/expo-react-native` | `expo-react-native` |
235
238
  | `MOBILE_FRAMEWORK` | `*flutter*` | `stack/mobile/flutter` | `flutter` |
236
239
  | `MOBILE_FRAMEWORK` | `*swiftui*` OR `*swift*` | `stack/mobile/swiftui` | `swiftui` |
237
240
  | `MOBILE_FRAMEWORK` | `*kotlin*` OR `*compose*` OR `*jetpack*` | `stack/mobile/kotlin-compose` | `kotlin-compose` |
@@ -261,10 +264,8 @@ Note: `DESIGN_DIRECTION` does not copy a skill from the library — it fills pla
261
264
 
262
265
  | Stack Key | Value Pattern | Library Path | Installed As |
263
266
  |-----------|--------------|-------------|-------------|
264
- | `GAME_ENGINE` | `*godot*` | `stack/engines/godot` | `godot` |
265
- | `GAME_ENGINE` | `*unity*` | `stack/engines/unity` | `unity` |
266
- | `GAME_ENGINE` | `*unreal*` OR `*ue5*` | `stack/engines/unreal` | `unreal` |
267
- | `GAME_ENGINE` | `*bevy*` | `stack/engines/bevy` | `bevy` |
267
+ | `GAME_ENGINE` | `*godot*` | `stack/gamedev/godot` | `godot` |
268
+ | `GAME_ENGINE` | `*unity*` | `stack/gamedev/unity` | `unity` |
268
269
 
269
270
  ### Security
270
271
 
@@ -353,7 +354,7 @@ When the project includes a surface type, install the listed skills.
353
354
  | `api` | `surface/api/api-caching` | `api-caching` |
354
355
  | `api` | `surface/api/api-documentation-openapi` | `api-documentation-openapi` |
355
356
  | `api` | `surface/api/webhook-design` | `webhook-design` |
356
- | `api` | `surface/api/rest-api-design` | `rest-api-design` |
357
+ | `api` | Pre-installed: `.agent/skills/api-design-principles` | `api-design-principles` (pre-installed) |
357
358
  | `api` | `surface/api/api-security-checklist` | `api-security-checklist` |
358
359
  | `api` | `stack/security/input-sanitization` | `input-sanitization` |
359
360
 
@@ -411,7 +412,7 @@ These skills are NOT auto-installed. Install via `/find-skills` or manually copy
411
412
  | `meta/mcp-builder` | Building MCP servers |
412
413
  | `meta/tmux-processes` | Long-lived process management via tmux |
413
414
  | `meta/using-tmux-for-interactive-commands` | Interactive CLI tools via tmux |
414
- | `meta/brand-guidelines` | Brand color and typography application |
415
+ | Pre-installed: `.agent/skills/brand-guidelines` | Brand color and typography application (pre-installed) |
415
416
  | `meta/product-marketing-context` | Marketing context document generator — run first before any SEO or CRO skill |
416
417
 
417
418
  ---
@@ -467,14 +468,23 @@ To add a new skill to the library:
467
468
  | `EMAIL` | Email service | Resend |
468
469
  | `QUEUE` | Job queue | Inngest, BullMQ |
469
470
  | `REALTIME` | Realtime communication | Socket.io |
470
- | `SEARCH` | Search engine | Meilisearch |
471
+ | `SEARCH` | Search engine | Meilisearch, Algolia, Typesense, Elasticsearch |
471
472
  | `CMS` | Content management | Payload CMS, WordPress, Shopify |
472
- | `STORAGE` | File/object storage | AWS S3 |
473
+ | `STORAGE` | File/object storage | AWS S3, Cloudflare R2, Google Cloud Storage |
473
474
  | `CI_CD` | CI/CD pipeline | GitHub Actions, Terraform |
474
- | `MOBILE_FRAMEWORK` | Mobile framework | Expo, React Native |
475
+ | `MOBILE_FRAMEWORK` | Mobile framework | Expo, React Native, Flutter, SwiftUI, Kotlin/Compose |
475
476
  | `LANGUAGE` | Programming language | TypeScript, Python, Rust, Go, C/C++, Java, Kotlin, JavaScript, GDScript, Bash |
477
+ | `MESSAGE_BROKER` | Message broker/queue | Kafka, RabbitMQ, NATS, AWS SQS |
478
+ | `NOTIFICATIONS` | Notification service | Twilio, FCM, SendGrid |
479
+ | `BROWSER_EXTENSION` | Browser extension framework | WXT, Plasmo, Chrome Extension |
480
+ | `VSCODE_EXTENSION` | VS Code extension | VS Code Extension |
481
+ | `FEATURE_FLAGS` | Feature flag service | LaunchDarkly, PostHog, Flagsmith |
482
+ | `DATABASE_ANALYTICS` | Analytics database | ClickHouse |
476
483
  | `3D_FRAMEWORK` | 3D rendering | Three.js, React Three Fiber |
477
484
  | `GAME_ENGINE` | Game engine | Godot, Unity |
478
485
  | `SECURITY` | Security focus area | OWASP, Crypto, CSP/CORS, Dependency Auditing, Input Sanitization |
479
486
  | `SECURITY_SKILLS` | Accumulated list of all provisioned security skills (comma-separated, auto-filled by bootstrap) | e.g., `owasp-web-security,csp-cors-headers,input-sanitization,dependency-auditing` |
487
+ | `API_DESIGN_SKILL` | API design skill for the project's API style (auto-filled by bootstrap, defaults to `api-design-principles`) | `api-design-principles`, `trpc`, `graphql` |
480
488
  | `DESIGN_DIRECTION` | Confirmed visual design direction | Minimal/Functional, Editorial, Luxury/Refined, Playful/Expressive, Technical/Brutalist, Cinematic/Immersive, or Hybrid |
489
+ | `CDN_ASSETS` | CDN provider for static assets (no skill provisioned — handled by `HOSTING_SKILL`) | Cloudflare, AWS CloudFront, Vercel Edge |
490
+ | `BACKEND_RUNTIME` | Backend runtime environment (no skill provisioned — handled by `LANGUAGE_SKILL` and `BACKEND_FRAMEWORK_SKILL`) | Node.js, Bun, Deno, Python |
@@ -0,0 +1,230 @@
1
+ ---
2
+ name: lucia
3
+ description: "Lucia auth patterns covering session management, database adapters, OAuth integration, password hashing, and middleware. Use when implementing authentication with Lucia."
4
+ version: 1.0.0
5
+ source: self
6
+ date_added: "2026-03-14"
7
+ ---
8
+
9
+ # Lucia
10
+
11
+ Lightweight, session-based auth library. No magic — you own the user table, session table, and auth logic. Lucia handles session tokens and cookie management.
12
+
13
+ ## When to Use
14
+
15
+ - Want full control over auth without a third-party service
16
+ - Building with Astro, SvelteKit, Next.js, or Express
17
+ - Need session-based auth (not JWT-based)
18
+ - Want to store users/sessions in your own database
19
+
20
+ ## When NOT to Use
21
+
22
+ - Want a managed auth service with pre-built UI (use Clerk or Auth.js)
23
+ - Need JWT-based authentication (Lucia uses opaque session tokens)
24
+ - Want OAuth without writing the callback handler yourself
25
+
26
+ ## Setup
27
+
28
+ ### Installation
29
+
30
+ ```bash
31
+ npm install lucia
32
+ npm install @lucia-auth/adapter-drizzle # or adapter-prisma, adapter-mongoose, etc.
33
+ ```
34
+
35
+ ### Database Schema (Drizzle Example)
36
+
37
+ ```typescript
38
+ // db/schema.ts
39
+ import { pgTable, text, timestamp } from 'drizzle-orm/pg-core';
40
+
41
+ export const userTable = pgTable('user', {
42
+ id: text('id').primaryKey(), // Generate with generateIdFromEntropySize(10)
43
+ email: text('email').notNull().unique(),
44
+ hashedPassword: text('hashed_password'),
45
+ name: text('name'),
46
+ });
47
+
48
+ export const sessionTable = pgTable('session', {
49
+ id: text('id').primaryKey(),
50
+ userId: text('user_id').notNull().references(() => userTable.id),
51
+ expiresAt: timestamp('expires_at', { withTimezone: true, mode: 'date' }).notNull(),
52
+ });
53
+ ```
54
+
55
+ ### Lucia Instance
56
+
57
+ ```typescript
58
+ // lib/auth.ts
59
+ import { Lucia } from 'lucia';
60
+ import { DrizzlePostgreSQLAdapter } from '@lucia-auth/adapter-drizzle';
61
+ import { db } from './db';
62
+ import { sessionTable, userTable } from './db/schema';
63
+
64
+ const adapter = new DrizzlePostgreSQLAdapter(db, sessionTable, userTable);
65
+
66
+ export const lucia = new Lucia(adapter, {
67
+ sessionCookie: {
68
+ attributes: {
69
+ secure: process.env.NODE_ENV === 'production',
70
+ },
71
+ },
72
+ getUserAttributes: (attributes) => ({
73
+ email: attributes.email,
74
+ name: attributes.name,
75
+ }),
76
+ });
77
+
78
+ // Type augmentation
79
+ declare module 'lucia' {
80
+ interface Register {
81
+ Lucia: typeof lucia;
82
+ DatabaseUserAttributes: { email: string; name: string };
83
+ }
84
+ }
85
+ ```
86
+
87
+ ## Sign-Up Flow
88
+
89
+ ```typescript
90
+ import { generateIdFromEntropySize } from 'lucia';
91
+ import { hash } from '@node-rs/argon2';
92
+
93
+ async function signUp(email: string, password: string, name: string) {
94
+ const userId = generateIdFromEntropySize(10); // 16-char random ID
95
+ const hashedPassword = await hash(password, {
96
+ memoryCost: 19456,
97
+ timeCost: 2,
98
+ outputLen: 32,
99
+ parallelism: 1,
100
+ });
101
+
102
+ await db.insert(userTable).values({ id: userId, email, hashedPassword, name });
103
+
104
+ const session = await lucia.createSession(userId, {});
105
+ const sessionCookie = lucia.createSessionCookie(session.id);
106
+ return sessionCookie; // Set this as a response cookie
107
+ }
108
+ ```
109
+
110
+ ## Sign-In Flow
111
+
112
+ ```typescript
113
+ import { verify } from '@node-rs/argon2';
114
+
115
+ async function signIn(email: string, password: string) {
116
+ const user = await db.query.userTable.findFirst({ where: eq(userTable.email, email) });
117
+ if (!user || !user.hashedPassword) {
118
+ throw new Error('Invalid email or password');
119
+ }
120
+
121
+ const validPassword = await verify(user.hashedPassword, password);
122
+ if (!validPassword) {
123
+ throw new Error('Invalid email or password');
124
+ }
125
+
126
+ const session = await lucia.createSession(user.id, {});
127
+ return lucia.createSessionCookie(session.id);
128
+ }
129
+ ```
130
+
131
+ ## Session Validation Middleware
132
+
133
+ ### Next.js
134
+
135
+ ```typescript
136
+ // middleware.ts or lib/auth-middleware.ts
137
+ import { cookies } from 'next/headers';
138
+
139
+ export async function validateRequest() {
140
+ const sessionId = (await cookies()).get(lucia.sessionCookieName)?.value ?? null;
141
+ if (!sessionId) return { user: null, session: null };
142
+
143
+ const result = await lucia.validateSession(sessionId);
144
+
145
+ if (result.session?.fresh) {
146
+ const cookie = lucia.createSessionCookie(result.session.id);
147
+ (await cookies()).set(cookie.name, cookie.value, cookie.attributes);
148
+ }
149
+ if (!result.session) {
150
+ const cookie = lucia.createBlankSessionCookie();
151
+ (await cookies()).set(cookie.name, cookie.value, cookie.attributes);
152
+ }
153
+
154
+ return result;
155
+ }
156
+ ```
157
+
158
+ ### Usage in Server Components
159
+
160
+ ```typescript
161
+ // app/dashboard/page.tsx
162
+ import { validateRequest } from '@/lib/auth-middleware';
163
+ import { redirect } from 'next/navigation';
164
+
165
+ export default async function DashboardPage() {
166
+ const { user, session } = await validateRequest();
167
+ if (!user) redirect('/login');
168
+
169
+ return <h1>Welcome, {user.name}</h1>;
170
+ }
171
+ ```
172
+
173
+ ## Sign Out
174
+
175
+ ```typescript
176
+ async function signOut() {
177
+ const { session } = await validateRequest();
178
+ if (session) {
179
+ await lucia.invalidateSession(session.id);
180
+ }
181
+ const cookie = lucia.createBlankSessionCookie();
182
+ (await cookies()).set(cookie.name, cookie.value, cookie.attributes);
183
+ }
184
+ ```
185
+
186
+ ## OAuth Integration
187
+
188
+ ```typescript
189
+ // Using Arctic for OAuth providers
190
+ import { GitHub } from 'arctic';
191
+
192
+ const github = new GitHub(
193
+ process.env.GITHUB_CLIENT_ID!,
194
+ process.env.GITHUB_CLIENT_SECRET!,
195
+ null
196
+ );
197
+
198
+ // 1. Redirect to provider
199
+ async function initiateOAuth() {
200
+ const state = generateState();
201
+ const url = github.createAuthorizationURL(state, ['user:email']);
202
+ // Set state in cookie, redirect to url
203
+ }
204
+
205
+ // 2. Handle callback
206
+ async function handleOAuthCallback(code: string) {
207
+ const tokens = await github.validateAuthorizationCode(code);
208
+ const response = await fetch('https://api.github.com/user', {
209
+ headers: { Authorization: `Bearer ${tokens.accessToken()}` },
210
+ });
211
+ const githubUser = await response.json();
212
+
213
+ // Find or create user, then create session
214
+ const session = await lucia.createSession(user.id, {});
215
+ return lucia.createSessionCookie(session.id);
216
+ }
217
+ ```
218
+
219
+ ## Anti-Patterns
220
+
221
+ | Don't | Do |
222
+ |-------|-----|
223
+ | Use `bcrypt` for password hashing | Use `@node-rs/argon2` — Argon2id is the current best |
224
+ | Skip the `session.fresh` check | Always refresh session cookies when `fresh === true` |
225
+ | Store session tokens in localStorage | Use httpOnly cookies via `lucia.createSessionCookie()` |
226
+ | Call `validateSession` on every render | Cache the result per-request (e.g., in React `cache()`) |
227
+ | Create sessions without invalidating old ones | Implement session limits or invalidate on password change |
228
+ | Skip type augmentation for `Register` | Always declare `DatabaseUserAttributes` for type safety |
229
+ | Use UUIDs for user IDs | Use `generateIdFromEntropySize()` — shorter, more entropy |
230
+ | Hash passwords with default/weak params | Set explicit Argon2 params (memoryCost ≥ 19456) |