contextos-agents 1.5.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.
- package/.agents/AGENTS.md +421 -0
- package/.agents/adapters/aider/export.js +137 -0
- package/.agents/adapters/claude/export.js +55 -0
- package/.agents/adapters/copilot/export.js +107 -0
- package/.agents/adapters/cursor/export.js +210 -0
- package/.agents/adapters/gemini/export.js +115 -0
- package/.agents/adapters/shared.js +119 -0
- package/.agents/adapters/zed/export.js +111 -0
- package/.agents/core/profiles/backend.yaml +47 -0
- package/.agents/core/profiles/enterprise.yaml +46 -0
- package/.agents/core/profiles/frontend.yaml +46 -0
- package/.agents/core/profiles/hackathon.yaml +45 -0
- package/.agents/core/profiles/mvp.yaml +43 -0
- package/.agents/core/profiles/startup.yaml +48 -0
- package/.agents/core/skills/adapters/EXAMPLES.md +19 -0
- package/.agents/core/skills/adapters/SKILL.md +105 -0
- package/.agents/core/skills/adapters/TROUBLESHOOTING.md +7 -0
- package/.agents/core/skills/adapters/VALIDATION.json +12 -0
- package/.agents/core/skills/adapters/skill.yaml +10 -0
- package/.agents/core/skills/architecture-diagrams/SKILL.md +108 -0
- package/.agents/core/skills/architecture-diagrams/VALIDATION.json +12 -0
- package/.agents/core/skills/architecture-diagrams/skill.yaml +8 -0
- package/.agents/core/skills/brutalist-design/SKILL.md +150 -0
- package/.agents/core/skills/brutalist-design/VALIDATION.json +12 -0
- package/.agents/core/skills/brutalist-design/skill.yaml +8 -0
- package/.agents/core/skills/context-manager/EXAMPLES.md +19 -0
- package/.agents/core/skills/context-manager/SKILL.md +126 -0
- package/.agents/core/skills/context-manager/TROUBLESHOOTING.md +7 -0
- package/.agents/core/skills/context-manager/VALIDATION.json +12 -0
- package/.agents/core/skills/context-manager/skill.yaml +10 -0
- package/.agents/core/skills/context-os/EXAMPLES.md +21 -0
- package/.agents/core/skills/context-os/SKILL.md +169 -0
- package/.agents/core/skills/context-os/TROUBLESHOOTING.md +7 -0
- package/.agents/core/skills/context-os/VALIDATION.json +12 -0
- package/.agents/core/skills/context-os/packs.yaml +59 -0
- package/.agents/core/skills/context-os/references/context-rules.md +68 -0
- package/.agents/core/skills/context-os/references/pipeline.md +119 -0
- package/.agents/core/skills/context-os/references/project-graph.md +103 -0
- package/.agents/core/skills/context-os/rules.yaml +135 -0
- package/.agents/core/skills/context-os/skill.yaml +10 -0
- package/.agents/core/skills/database/EXAMPLES.md +74 -0
- package/.agents/core/skills/database/SKILL.md +101 -0
- package/.agents/core/skills/database/TROUBLESHOOTING.md +18 -0
- package/.agents/core/skills/database/VALIDATION.json +11 -0
- package/.agents/core/skills/database/skill.yaml +25 -0
- package/.agents/core/skills/ddd/EXAMPLES.md +42 -0
- package/.agents/core/skills/ddd/SKILL.md +247 -0
- package/.agents/core/skills/ddd/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/ddd/VALIDATION.json +12 -0
- package/.agents/core/skills/ddd/ddd.md +178 -0
- package/.agents/core/skills/ddd/skill.yaml +10 -0
- package/.agents/core/skills/decisions/EXAMPLES.md +35 -0
- package/.agents/core/skills/decisions/SKILL.md +90 -0
- package/.agents/core/skills/decisions/TROUBLESHOOTING.md +13 -0
- package/.agents/core/skills/decisions/VALIDATION.json +12 -0
- package/.agents/core/skills/decisions/skill.yaml +10 -0
- package/.agents/core/skills/docker/EXAMPLES.md +56 -0
- package/.agents/core/skills/docker/SKILL.md +63 -0
- package/.agents/core/skills/docker/TROUBLESHOOTING.md +18 -0
- package/.agents/core/skills/docker/VALIDATION.json +11 -0
- package/.agents/core/skills/docker/skill.yaml +23 -0
- package/.agents/core/skills/engineering-workflow/EXAMPLES.md +57 -0
- package/.agents/core/skills/engineering-workflow/SKILL.md +343 -0
- package/.agents/core/skills/engineering-workflow/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/engineering-workflow/VALIDATION.json +12 -0
- package/.agents/core/skills/engineering-workflow/skill.yaml +13 -0
- package/.agents/core/skills/fastapi/EXAMPLES.md +36 -0
- package/.agents/core/skills/fastapi/SKILL.md +148 -0
- package/.agents/core/skills/fastapi/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/fastapi/VALIDATION.json +12 -0
- package/.agents/core/skills/fastapi/fastapi.md +112 -0
- package/.agents/core/skills/fastapi/skill.yaml +10 -0
- package/.agents/core/skills/gemini-precision/SKILL.md +169 -0
- package/.agents/core/skills/gemini-precision/VALIDATION.json +12 -0
- package/.agents/core/skills/gemini-precision/skill.yaml +9 -0
- package/.agents/core/skills/generators/EXAMPLES.md +19 -0
- package/.agents/core/skills/generators/SKILL.md +112 -0
- package/.agents/core/skills/generators/TROUBLESHOOTING.md +7 -0
- package/.agents/core/skills/generators/VALIDATION.json +12 -0
- package/.agents/core/skills/generators/skill.yaml +10 -0
- package/.agents/core/skills/generators/templates/API.md +77 -0
- package/.agents/core/skills/generators/templates/ARCHITECTURE.md +70 -0
- package/.agents/core/skills/generators/templates/DATABASE.md +42 -0
- package/.agents/core/skills/generators/templates/DECISION.md +46 -0
- package/.agents/core/skills/generators/templates/PRD.md +67 -0
- package/.agents/core/skills/generators/templates/PROJECT_GRAPH.md +56 -0
- package/.agents/core/skills/generators/templates/ROADMAP.md +51 -0
- package/.agents/core/skills/generators/templates/TASKS.md +43 -0
- package/.agents/core/skills/generators/templates/UI.md +73 -0
- package/.agents/core/skills/graphify/EXAMPLES.md +73 -0
- package/.agents/core/skills/graphify/SKILL.md +130 -0
- package/.agents/core/skills/graphify/VALIDATION.json +12 -0
- package/.agents/core/skills/graphify/skill.yaml +13 -0
- package/.agents/core/skills/gstack-roles/EXAMPLES.md +23 -0
- package/.agents/core/skills/gstack-roles/SKILL.md +152 -0
- package/.agents/core/skills/gstack-roles/TROUBLESHOOTING.md +13 -0
- package/.agents/core/skills/gstack-roles/VALIDATION.json +12 -0
- package/.agents/core/skills/gstack-roles/skill.yaml +12 -0
- package/.agents/core/skills/impeccable-design/EXAMPLES.md +26 -0
- package/.agents/core/skills/impeccable-design/SKILL.md +201 -0
- package/.agents/core/skills/impeccable-design/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/impeccable-design/VALIDATION.json +12 -0
- package/.agents/core/skills/impeccable-design/skill.yaml +14 -0
- package/.agents/core/skills/interview-me/SKILL.md +97 -0
- package/.agents/core/skills/interview-me/VALIDATION.json +12 -0
- package/.agents/core/skills/interview-me/skill.yaml +8 -0
- package/.agents/core/skills/microservices/EXAMPLES.md +38 -0
- package/.agents/core/skills/microservices/SKILL.md +164 -0
- package/.agents/core/skills/microservices/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/microservices/VALIDATION.json +12 -0
- package/.agents/core/skills/microservices/microservices.md +119 -0
- package/.agents/core/skills/microservices/skill.yaml +10 -0
- package/.agents/core/skills/minimalist-design/SKILL.md +113 -0
- package/.agents/core/skills/minimalist-design/VALIDATION.json +12 -0
- package/.agents/core/skills/minimalist-design/skill.yaml +8 -0
- package/.agents/core/skills/nestjs/EXAMPLES.md +40 -0
- package/.agents/core/skills/nestjs/SKILL.md +139 -0
- package/.agents/core/skills/nestjs/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/nestjs/VALIDATION.json +12 -0
- package/.agents/core/skills/nestjs/nestjs.md +103 -0
- package/.agents/core/skills/nestjs/skill.yaml +10 -0
- package/.agents/core/skills/nextjs/EXAMPLES.md +40 -0
- package/.agents/core/skills/nextjs/SKILL.md +163 -0
- package/.agents/core/skills/nextjs/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/nextjs/VALIDATION.json +12 -0
- package/.agents/core/skills/nextjs/nextjs.md +67 -0
- package/.agents/core/skills/nextjs/skill.yaml +10 -0
- package/.agents/core/skills/node/EXAMPLES.md +80 -0
- package/.agents/core/skills/node/SKILL.md +128 -0
- package/.agents/core/skills/node/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/node/VALIDATION.json +12 -0
- package/.agents/core/skills/node/node.md +87 -0
- package/.agents/core/skills/node/skill.yaml +10 -0
- package/.agents/core/skills/performance/EXAMPLES.md +30 -0
- package/.agents/core/skills/performance/SKILL.md +75 -0
- package/.agents/core/skills/performance/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/performance/VALIDATION.json +12 -0
- package/.agents/core/skills/performance/performance.md +52 -0
- package/.agents/core/skills/performance/skill.yaml +10 -0
- package/.agents/core/skills/ponytail-mindset/EXAMPLES.md +45 -0
- package/.agents/core/skills/ponytail-mindset/SKILL.md +193 -0
- package/.agents/core/skills/ponytail-mindset/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/ponytail-mindset/VALIDATION.json +12 -0
- package/.agents/core/skills/ponytail-mindset/skill.yaml +14 -0
- package/.agents/core/skills/react/EXAMPLES.md +79 -0
- package/.agents/core/skills/react/SKILL.md +132 -0
- package/.agents/core/skills/react/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/react/VALIDATION.json +12 -0
- package/.agents/core/skills/react/react.md +93 -0
- package/.agents/core/skills/react/skill.yaml +10 -0
- package/.agents/core/skills/react-best-practices/SKILL.md +155 -0
- package/.agents/core/skills/react-best-practices/VALIDATION.json +12 -0
- package/.agents/core/skills/react-best-practices/skill.yaml +10 -0
- package/.agents/core/skills/redesign-audit/SKILL.md +117 -0
- package/.agents/core/skills/redesign-audit/VALIDATION.json +12 -0
- package/.agents/core/skills/redesign-audit/skill.yaml +8 -0
- package/.agents/core/skills/security/EXAMPLES.md +64 -0
- package/.agents/core/skills/security/SKILL.md +158 -0
- package/.agents/core/skills/security/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/security/VALIDATION.json +12 -0
- package/.agents/core/skills/security/security.md +106 -0
- package/.agents/core/skills/security/skill.yaml +10 -0
- package/.agents/core/skills/soft-design/SKILL.md +108 -0
- package/.agents/core/skills/soft-design/VALIDATION.json +12 -0
- package/.agents/core/skills/soft-design/skill.yaml +8 -0
- package/.agents/core/skills/state-management/EXAMPLES.md +56 -0
- package/.agents/core/skills/state-management/SKILL.md +48 -0
- package/.agents/core/skills/state-management/TROUBLESHOOTING.md +18 -0
- package/.agents/core/skills/state-management/VALIDATION.json +11 -0
- package/.agents/core/skills/state-management/skill.yaml +22 -0
- package/.agents/core/skills/subagent-orchestrator/SKILL.md +100 -0
- package/.agents/core/skills/subagent-orchestrator/VALIDATION.json +12 -0
- package/.agents/core/skills/subagent-orchestrator/skill.yaml +8 -0
- package/.agents/core/skills/system-design/EXAMPLES.md +75 -0
- package/.agents/core/skills/system-design/SKILL.md +419 -0
- package/.agents/core/skills/system-design/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/system-design/VALIDATION.json +12 -0
- package/.agents/core/skills/system-design/skill.yaml +13 -0
- package/.agents/core/skills/system-design/system-design.md +112 -0
- package/.agents/core/skills/testing/EXAMPLES.md +71 -0
- package/.agents/core/skills/testing/SKILL.md +70 -0
- package/.agents/core/skills/testing/TROUBLESHOOTING.md +18 -0
- package/.agents/core/skills/testing/VALIDATION.json +11 -0
- package/.agents/core/skills/testing/skill.yaml +26 -0
- package/.agents/core/skills/typescript/EXAMPLES.md +64 -0
- package/.agents/core/skills/typescript/SKILL.md +112 -0
- package/.agents/core/skills/typescript/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/typescript/VALIDATION.json +12 -0
- package/.agents/core/skills/typescript/skill.yaml +10 -0
- package/.agents/core/skills/typescript/typescript.md +71 -0
- package/.agents/core/skills/ui-design/EXAMPLES.md +21 -0
- package/.agents/core/skills/ui-design/SKILL.md +124 -0
- package/.agents/core/skills/ui-design/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/ui-design/VALIDATION.json +12 -0
- package/.agents/core/skills/ui-design/skill.yaml +10 -0
- package/.agents/core/skills/ui-design/ui.md +88 -0
- package/.agents/core/skills/ui-ux-pro/EXAMPLES.md +62 -0
- package/.agents/core/skills/ui-ux-pro/SKILL.md +375 -0
- package/.agents/core/skills/ui-ux-pro/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/ui-ux-pro/VALIDATION.json +12 -0
- package/.agents/core/skills/ui-ux-pro/skill.yaml +13 -0
- package/.agents/core/skills/ux-design/EXAMPLES.md +36 -0
- package/.agents/core/skills/ux-design/SKILL.md +116 -0
- package/.agents/core/skills/ux-design/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/ux-design/VALIDATION.json +12 -0
- package/.agents/core/skills/ux-design/skill.yaml +10 -0
- package/.agents/core/skills/ux-design/ux.md +80 -0
- package/.agents/core/skills/vercel-optimize/SKILL.md +83 -0
- package/.agents/core/skills/vercel-optimize/VALIDATION.json +12 -0
- package/.agents/core/skills/vercel-optimize/skill.yaml +10 -0
- package/.agents/core/skills/web-accessibility/EXAMPLES.md +39 -0
- package/.agents/core/skills/web-accessibility/SKILL.md +170 -0
- package/.agents/core/skills/web-accessibility/TROUBLESHOOTING.md +19 -0
- package/.agents/core/skills/web-accessibility/VALIDATION.json +12 -0
- package/.agents/core/skills/web-accessibility/accessibility.md +63 -0
- package/.agents/core/skills/web-accessibility/skill.yaml +10 -0
- package/.agents/ctx.js +370 -0
- package/.agents/generated/claude/skills/adapters/SKILL.md +126 -0
- package/.agents/generated/claude/skills/architecture-diagrams/SKILL.md +101 -0
- package/.agents/generated/claude/skills/brutalist-design/SKILL.md +145 -0
- package/.agents/generated/claude/skills/context-manager/SKILL.md +147 -0
- package/.agents/generated/claude/skills/context-os/SKILL.md +191 -0
- package/.agents/generated/claude/skills/database/SKILL.md +191 -0
- package/.agents/generated/claude/skills/ddd/SKILL.md +305 -0
- package/.agents/generated/claude/skills/decisions/SKILL.md +134 -0
- package/.agents/generated/claude/skills/docker/SKILL.md +135 -0
- package/.agents/generated/claude/skills/engineering-workflow/SKILL.md +414 -0
- package/.agents/generated/claude/skills/fastapi/SKILL.md +200 -0
- package/.agents/generated/claude/skills/gemini-precision/SKILL.md +161 -0
- package/.agents/generated/claude/skills/generators/SKILL.md +133 -0
- package/.agents/generated/claude/skills/graphify/SKILL.md +198 -0
- package/.agents/generated/claude/skills/gstack-roles/SKILL.md +184 -0
- package/.agents/generated/claude/skills/impeccable-design/SKILL.md +241 -0
- package/.agents/generated/claude/skills/interview-me/SKILL.md +90 -0
- package/.agents/generated/claude/skills/microservices/SKILL.md +218 -0
- package/.agents/generated/claude/skills/minimalist-design/SKILL.md +108 -0
- package/.agents/generated/claude/skills/nestjs/SKILL.md +195 -0
- package/.agents/generated/claude/skills/nextjs/SKILL.md +219 -0
- package/.agents/generated/claude/skills/node/SKILL.md +224 -0
- package/.agents/generated/claude/skills/performance/SKILL.md +121 -0
- package/.agents/generated/claude/skills/ponytail-mindset/SKILL.md +252 -0
- package/.agents/generated/claude/skills/react/SKILL.md +227 -0
- package/.agents/generated/claude/skills/react-best-practices/SKILL.md +146 -0
- package/.agents/generated/claude/skills/redesign-audit/SKILL.md +112 -0
- package/.agents/generated/claude/skills/security/SKILL.md +237 -0
- package/.agents/generated/claude/skills/soft-design/SKILL.md +103 -0
- package/.agents/generated/claude/skills/state-management/SKILL.md +120 -0
- package/.agents/generated/claude/skills/subagent-orchestrator/SKILL.md +93 -0
- package/.agents/generated/claude/skills/system-design/SKILL.md +507 -0
- package/.agents/generated/claude/skills/testing/SKILL.md +157 -0
- package/.agents/generated/claude/skills/typescript/SKILL.md +192 -0
- package/.agents/generated/claude/skills/ui-design/SKILL.md +161 -0
- package/.agents/generated/claude/skills/ui-ux-pro/SKILL.md +451 -0
- package/.agents/generated/claude/skills/ux-design/SKILL.md +168 -0
- package/.agents/generated/claude/skills/vercel-optimize/SKILL.md +76 -0
- package/.agents/generated/claude/skills/web-accessibility/SKILL.md +225 -0
- package/.agents/generated/gemini/skills/adapters/SKILL.md +135 -0
- package/.agents/generated/gemini/skills/architecture-diagrams/SKILL.md +107 -0
- package/.agents/generated/gemini/skills/brutalist-design/SKILL.md +151 -0
- package/.agents/generated/gemini/skills/context-manager/SKILL.md +156 -0
- package/.agents/generated/gemini/skills/context-os/SKILL.md +200 -0
- package/.agents/generated/gemini/skills/database/SKILL.md +200 -0
- package/.agents/generated/gemini/skills/ddd/SKILL.md +314 -0
- package/.agents/generated/gemini/skills/decisions/SKILL.md +143 -0
- package/.agents/generated/gemini/skills/docker/SKILL.md +144 -0
- package/.agents/generated/gemini/skills/engineering-workflow/SKILL.md +423 -0
- package/.agents/generated/gemini/skills/fastapi/SKILL.md +209 -0
- package/.agents/generated/gemini/skills/gemini-precision/SKILL.md +167 -0
- package/.agents/generated/gemini/skills/generators/SKILL.md +142 -0
- package/.agents/generated/gemini/skills/graphify/SKILL.md +205 -0
- package/.agents/generated/gemini/skills/gstack-roles/SKILL.md +193 -0
- package/.agents/generated/gemini/skills/impeccable-design/SKILL.md +250 -0
- package/.agents/generated/gemini/skills/interview-me/SKILL.md +96 -0
- package/.agents/generated/gemini/skills/microservices/SKILL.md +227 -0
- package/.agents/generated/gemini/skills/minimalist-design/SKILL.md +114 -0
- package/.agents/generated/gemini/skills/nestjs/SKILL.md +204 -0
- package/.agents/generated/gemini/skills/nextjs/SKILL.md +298 -0
- package/.agents/generated/gemini/skills/node/SKILL.md +323 -0
- package/.agents/generated/gemini/skills/performance/SKILL.md +185 -0
- package/.agents/generated/gemini/skills/ponytail-mindset/SKILL.md +261 -0
- package/.agents/generated/gemini/skills/react/SKILL.md +332 -0
- package/.agents/generated/gemini/skills/react-best-practices/SKILL.md +152 -0
- package/.agents/generated/gemini/skills/redesign-audit/SKILL.md +118 -0
- package/.agents/generated/gemini/skills/security/SKILL.md +355 -0
- package/.agents/generated/gemini/skills/soft-design/SKILL.md +109 -0
- package/.agents/generated/gemini/skills/state-management/SKILL.md +129 -0
- package/.agents/generated/gemini/skills/subagent-orchestrator/SKILL.md +99 -0
- package/.agents/generated/gemini/skills/system-design/SKILL.md +631 -0
- package/.agents/generated/gemini/skills/testing/SKILL.md +166 -0
- package/.agents/generated/gemini/skills/typescript/SKILL.md +275 -0
- package/.agents/generated/gemini/skills/ui-design/SKILL.md +170 -0
- package/.agents/generated/gemini/skills/ui-ux-pro/SKILL.md +460 -0
- package/.agents/generated/gemini/skills/ux-design/SKILL.md +177 -0
- package/.agents/generated/gemini/skills/vercel-optimize/SKILL.md +82 -0
- package/.agents/generated/gemini/skills/web-accessibility/SKILL.md +300 -0
- package/.agents/mcp/runtime.py +454 -0
- package/.agents/mcp/server.mjs +189373 -0
- package/.agents/plugins.js +574 -0
- package/.agents/profiles.js +267 -0
- package/.agents/resolver.js +336 -0
- package/.agents/skills-index.json +200 -0
- package/.agents/skills.json +6 -0
- package/.agents/validate.js +500 -0
- package/LICENSE +21 -0
- package/README.md +415 -0
- package/benchmarks/gemini-issues.js +533 -0
- package/bin/index.js +458 -0
- package/package.json +70 -0
- package/registry.json +53 -0
- package/registry.schema.json +32 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: high-end-visual-design
|
|
3
|
+
description: Teaches the AI to design like a high-end agency. Defines the exact fonts, spacing, shadows, card structures, and animations that make a website feel expensive. Blocks all the common defaults that make AI designs look cheap or generic.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Agent Skill: Principal UI/UX Architect & Motion Choreographer (Awwwards-Tier)
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Engineers high-end, agency-level digital experiences characterized by tactile haptic depth, cinematic spatial rhythm, obsessive micro-interactions, and fluid spring physics. Rejects generic commodity SaaS templates in favor of bespoke layout archetypes, nested double-bezel enclosures, and purposeful motion dynamics.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- When tasked with creating luxury, premium, Awwwards-tier landing pages, portfolio showpieces, or editorial SaaS interfaces.
|
|
15
|
+
- When explicitly prompted for "soft UI", "expensive design", "Apple-level polish", or "calm aesthetics".
|
|
16
|
+
- When standard component libraries feel too clinical or generic.
|
|
17
|
+
|
|
18
|
+
## Rules & Patterns
|
|
19
|
+
|
|
20
|
+
### 1. Absolute Zero Directive (Strict Anti-Patterns)
|
|
21
|
+
|
|
22
|
+
- **Banned Fonts:** Inter, Roboto, Arial, Open Sans, Helvetica. (Use `Geist`, `Clash Display`, `PP Editorial New`, or `Plus Jakarta Sans`).
|
|
23
|
+
- **Banned Icons:** Thick-stroked Lucide, FontAwesome, or Material Icons. Use ultra-light, precise line icons (Phosphor Light, Remix Line).
|
|
24
|
+
- **Banned Borders & Shadows:** Generic 1px solid gray borders. Harsh dark drop shadows (`rgba(0,0,0,0.3)`).
|
|
25
|
+
- **Banned Layouts:** Edge-to-edge sticky navbars glued to the top. Symmetrical 3-column Bootstrap-style grids without massive whitespace.
|
|
26
|
+
- **Banned Motion:** Standard `linear` or `ease-in-out` transitions. Instant state changes without interpolation.
|
|
27
|
+
|
|
28
|
+
### 2. The Creative Variance Engine
|
|
29
|
+
|
|
30
|
+
Before writing code, consciously pick ONE combination:
|
|
31
|
+
|
|
32
|
+
#### Vibe & Texture Archetypes
|
|
33
|
+
|
|
34
|
+
1. **Ethereal Glass (SaaS / AI / Tech):** Deep OLED black (`#050505`), subtle radial mesh gradients, vantablack cards with `backdrop-blur-2xl` and white/10 hairlines.
|
|
35
|
+
2. **Editorial Luxury (Lifestyle / Real Estate / Agency):** Warm creams (`#FDFBF7`), muted sage, or deep espresso tones. Variable serif headings with subtle CSS noise overlay (`opacity-[0.03]`).
|
|
36
|
+
3. **Soft Structuralism (Consumer / Health / Portfolio):** Silver-grey or pure white backgrounds, bold grotesk typography, airy floating components with ultra-diffuse ambient shadows.
|
|
37
|
+
|
|
38
|
+
#### Layout Archetypes
|
|
39
|
+
|
|
40
|
+
1. **The Asymmetrical Bento:** Masonry CSS Grid of varying card spans. (Collapses to single-column `grid-cols-1 gap-6` on mobile).
|
|
41
|
+
2. **The Z-Axis Cascade:** Stacked cards with varying depth of field and subtle `-2deg` or `3deg` rotations. (Rotations removed on mobile).
|
|
42
|
+
3. **The Editorial Split:** Massive typography on the left half (`w-1/2`), with horizontal interactive card ribbons on the right.
|
|
43
|
+
|
|
44
|
+
### 3. Haptic Micro-Aesthetics
|
|
45
|
+
|
|
46
|
+
- **The Double-Bezel (Doppelrand):**
|
|
47
|
+
- **Outer Shell:** Wrapper `div` with subtle background (`bg-black/5` or `bg-white/5`), hairline border (`border border-white/10`), padding (`p-2`), and large outer radius (`rounded-[2rem]`).
|
|
48
|
+
- **Inner Core:** Nested card inside shell with distinct background, inner highlight (`shadow-[inset_0_1px_1px_rgba(255,255,255,0.15)]`), and mathematically concentric smaller radius (`rounded-[calc(2rem-0.5rem)]`).
|
|
49
|
+
- **Button-in-Button Trailing Icon:** Pill-shaped primary buttons (`rounded-full px-6 py-3`) with trailing arrows nested inside their own dedicated circular badge (`w-8 h-8 rounded-full bg-black/5 flex items-center justify-center`).
|
|
50
|
+
- **Macro-Whitespace:** Minimum `py-24` to `py-40` for section padding.
|
|
51
|
+
|
|
52
|
+
### 4. Motion Choreography & Performance Guardrails
|
|
53
|
+
|
|
54
|
+
- **Custom Physics:** All transitions use custom cubic-beziers: `transition-all duration-700 ease-[cubic-bezier(0.32,0.72,0,1)]`.
|
|
55
|
+
- **GPU-Safe Animation:** Animate exclusively via `transform` and `opacity`. Never animate `top`, `left`, `width`, or `height`.
|
|
56
|
+
- **Blur Discipline:** Restrict `backdrop-blur` to fixed or sticky elements (navbars, modals). Never apply to scrolling containers.
|
|
57
|
+
|
|
58
|
+
## Code Examples
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
export function DoubleBezelCard({ title, subtitle, tag }: { title: string; subtitle: string; tag: string }) {
|
|
62
|
+
return (
|
|
63
|
+
// Outer Shell
|
|
64
|
+
<div className="p-2 rounded-[2rem] bg-black/5 dark:bg-white/5 border border-black/10 dark:border-white/10 transition-all duration-700 ease-[cubic-bezier(0.32,0.72,0,1)] hover:shadow-2xl">
|
|
65
|
+
// Inner Core
|
|
66
|
+
<div className="p-8 rounded-[calc(2rem-0.5rem)] bg-[#FFFFFF] dark:bg-[#0E0E0E] shadow-[inset_0_1px_1px_rgba(255,255,255,0.15)] flex flex-col justify-between min-h-[320px]">
|
|
67
|
+
<div>
|
|
68
|
+
<span className="inline-block px-3 py-1 rounded-full text-[10px] uppercase tracking-[0.2em] font-medium bg-black/5 dark:bg-white/10 text-neutral-600 dark:text-neutral-400 mb-4">
|
|
69
|
+
{tag}
|
|
70
|
+
</span>
|
|
71
|
+
<h3 className="text-2xl font-bold tracking-tight text-neutral-900 dark:text-white mb-2">{title}</h3>
|
|
72
|
+
<p className="text-sm text-neutral-500 dark:text-neutral-400 leading-relaxed">{subtitle}</p>
|
|
73
|
+
</div>
|
|
74
|
+
<button
|
|
75
|
+
type="button"
|
|
76
|
+
className="group mt-6 inline-flex items-center justify-between pl-6 pr-2 py-2 rounded-full bg-neutral-900 dark:bg-white text-white dark:text-neutral-950 font-medium text-sm active:scale-[0.98] transition-all duration-300"
|
|
77
|
+
>
|
|
78
|
+
<span>Explore Experience</span>
|
|
79
|
+
<span className="w-8 h-8 rounded-full bg-white/10 dark:bg-black/10 flex items-center justify-center transition-transform duration-300 group-hover:translate-x-0.5 group-hover:-translate-y-0.5">
|
|
80
|
+
↗
|
|
81
|
+
</span>
|
|
82
|
+
</button>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Validation Checklist
|
|
90
|
+
|
|
91
|
+
- [ ] All major cards and interactive modules use the Double-Bezel concentric architecture.
|
|
92
|
+
- [ ] Primary buttons feature the nested button-in-button trailing icon pattern.
|
|
93
|
+
- [ ] Section vertical padding is at minimum `py-24`.
|
|
94
|
+
- [ ] Transitions use spring or custom cubic-bezier curves (no default linear transitions).
|
|
95
|
+
- [ ] Layout collapses gracefully to single-column on mobile viewports (<768px).
|
|
96
|
+
- [ ] Animations use only `transform` and `opacity`.
|
|
97
|
+
|
|
98
|
+
## Common Mistakes
|
|
99
|
+
|
|
100
|
+
- Using standard `shadow-md` or harsh dark drop shadows instead of soft ambient shadows.
|
|
101
|
+
- Failing to recalculate concentric inner border-radii (`calc(outer - padding)`).
|
|
102
|
+
- Applying `backdrop-blur` on large scrolling sections, triggering GPU repaints.
|
|
103
|
+
- Sticking to generic 3-column Bootstrap grids.
|
|
104
|
+
|
|
105
|
+
## Integration Notes
|
|
106
|
+
|
|
107
|
+
- Complements `impeccable-design` for QA and anti-pattern enforcement.
|
|
108
|
+
- Pairs with `ui-ux-pro` for color palette harmony and accessibility compliance.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# State Management Examples — Anti-patterns vs ContextOS Standard
|
|
2
|
+
|
|
3
|
+
## Example 1: Selecting State from Zustand
|
|
4
|
+
|
|
5
|
+
### Anti-pattern: Anti-pattern (Subscribing to full store causes unnecessary renders)
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// BAD: component re-renders whenever ANY property in the store changes!
|
|
9
|
+
function CartBadge() {
|
|
10
|
+
const store = useCartStore(); // subscribes to entire object!
|
|
11
|
+
return <span>{store.items.length}</span>;
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Best practice: ContextOS Standard (Atomic granular selector)
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// GOOD: component ONLY re-renders when itemCount changes
|
|
19
|
+
function CartBadge() {
|
|
20
|
+
const itemCount = useCartStore((state) => state.items.length);
|
|
21
|
+
return <span>{itemCount}</span>;
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Example 2: Server State Invalidation
|
|
28
|
+
|
|
29
|
+
### Anti-pattern: Anti-pattern (Manually syncing server data into global state with useEffect)
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
// BAD: manual sync, race conditions, stale cache bugs
|
|
33
|
+
function UserProfile({ userId }) {
|
|
34
|
+
const { setUser } = useUserStore();
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
fetch(`/api/users/${userId}`).then(res => res.json()).then(setUser);
|
|
37
|
+
}, [userId]);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Best practice: ContextOS Standard (Declarative TanStack Query caching)
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
// GOOD: automatic caching, deduplication, background revalidation
|
|
45
|
+
function UserProfile({ userId }: { userId: string }) {
|
|
46
|
+
const { data: user, isLoading, error } = useQuery({
|
|
47
|
+
queryKey: ['users', userId],
|
|
48
|
+
queryFn: () => fetchUserById(userId),
|
|
49
|
+
staleTime: 1000 * 60 * 5, // 5 minutes fresh
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (isLoading) return <SkeletonLoader />;
|
|
53
|
+
if (error) return <ErrorMessage error={error} />;
|
|
54
|
+
return <UserDetails user={user} />;
|
|
55
|
+
}
|
|
56
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: state-management
|
|
3
|
+
description: Client and server state management standards using Zustand and TanStack Query. Enforces minimal global state, optimistic updates, and clean query invalidation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# State Management
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Global client state and server state management in modern React and Next.js applications using Zustand and TanStack Query.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
Activate when managing asynchronous server data fetching/caching, optimistic UI updates, or global UI client state (modals, filters, wizards).
|
|
15
|
+
|
|
16
|
+
## Rules & Patterns
|
|
17
|
+
|
|
18
|
+
### The Rule of Two States
|
|
19
|
+
|
|
20
|
+
- **SERVER STATE (Async)**: Managed exclusively by TanStack Query (`useQuery`, `useMutation`). Caching, background refetching, pagination, and invalidation.
|
|
21
|
+
- **CLIENT STATE (Sync)**: Managed by Zustand. Modal visibility, active filters, wizard step, theme.
|
|
22
|
+
|
|
23
|
+
### Negative Constraints (What NOT to Do)
|
|
24
|
+
|
|
25
|
+
1. **NEVER store server-fetched data in Zustand or Redux stores**: Store ONLY client-local UI state in Zustand. All API data belongs in TanStack Query.
|
|
26
|
+
2. **NEVER duplicate derived state**: Compute values inline or via `useMemo` from existing state instead of storing redundant state variables.
|
|
27
|
+
3. **NEVER subscribe to entire store objects in components**: Always use atomic selector functions (e.g. `useStore(state => state.isOpen)`) to prevent unnecessary component re-renders.
|
|
28
|
+
4. **NEVER mutate state directly**: Always return new immutable state objects in Zustand setters.
|
|
29
|
+
5. **NEVER ignore optimistic rollback on mutation failure**: When implementing optimistic UI, always capture `previousData` in `onMutate` and restore it in `onError`.
|
|
30
|
+
|
|
31
|
+
## Code Examples
|
|
32
|
+
|
|
33
|
+
See `EXAMPLES.md` for Zustand store patterns and optimistic TanStack mutations.
|
|
34
|
+
|
|
35
|
+
## Validation Checklist
|
|
36
|
+
|
|
37
|
+
- [ ] Clear separation between Server (TanStack Query) and Client (Zustand) state
|
|
38
|
+
- [ ] Atomic selectors used on all Zustand hook calls
|
|
39
|
+
- [ ] Optimistic updates implement rollback on error
|
|
40
|
+
- [ ] Zero duplicated derived state
|
|
41
|
+
|
|
42
|
+
## Common Mistakes
|
|
43
|
+
|
|
44
|
+
- Subscribing to full store objects causing cascading re-renders. See `TROUBLESHOOTING.md`.
|
|
45
|
+
|
|
46
|
+
## Integration Notes
|
|
47
|
+
|
|
48
|
+
Interacts with `react`, `nextjs`, and `typescript`.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# State Management Troubleshooting Guide
|
|
2
|
+
|
|
3
|
+
## Common Issues & Fixes
|
|
4
|
+
|
|
5
|
+
### 1. Infinite re-renders when calling `useStore` with an inline object selector
|
|
6
|
+
|
|
7
|
+
- **Cause**: Returning a new object reference from a selector without a custom equality check.
|
|
8
|
+
- **Fix**: Use `useShallow` from `zustand/react/shallow` or select scalar values directly.
|
|
9
|
+
|
|
10
|
+
### 2. Stale data shown after mutation
|
|
11
|
+
|
|
12
|
+
- **Cause**: Missing `queryClient.invalidateQueries` in `onSettled` or `onSuccess`.
|
|
13
|
+
- **Fix**: Always invalidate the relevant query keys on mutation completion to trigger background refetch.
|
|
14
|
+
|
|
15
|
+
### 3. Server-Side Rendering (SSR) Hydration Mismatch in Next.js
|
|
16
|
+
|
|
17
|
+
- **Cause**: Reading localStorage-persisted Zustand store directly during initial SSR render.
|
|
18
|
+
- **Fix**: Use a custom `useHydratedStore` hook or render persisted components only after client mount.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill": "state-management",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"checks": [
|
|
5
|
+
"Strict separation between Server and Client state",
|
|
6
|
+
"No server API responses cached in Zustand",
|
|
7
|
+
"Granular atomic selectors used for component subscriptions",
|
|
8
|
+
"Optimistic mutations include rollback handler",
|
|
9
|
+
"Zero duplicated derived state"
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: state-management
|
|
2
|
+
description: Client and server state management standards using Zustand and TanStack Query. Enforces minimal global state, optimistic updates, and clean query invalidation.
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
category: frontend
|
|
5
|
+
requires:
|
|
6
|
+
- react
|
|
7
|
+
- typescript
|
|
8
|
+
triggers:
|
|
9
|
+
files:
|
|
10
|
+
- "*store*"
|
|
11
|
+
- "*state*"
|
|
12
|
+
- "use*Query.ts"
|
|
13
|
+
- "use*Mutation.ts"
|
|
14
|
+
keywords:
|
|
15
|
+
- "zustand"
|
|
16
|
+
- "tanstack"
|
|
17
|
+
- "react-query"
|
|
18
|
+
- "state"
|
|
19
|
+
- "store"
|
|
20
|
+
- "optimistic"
|
|
21
|
+
- "mutation"
|
|
22
|
+
- "cache"
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: subagent-orchestrator
|
|
3
|
+
description: >
|
|
4
|
+
Subagent delegation and parallel coordination skill. Implements task decomposition,
|
|
5
|
+
context hand-offs, blast-radius boundary isolation, and conflict-free merge synthesis.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# subagent-orchestrator
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Multi-agent coordination protocol inspired by [obra/superpowers](https://github.com/obra/superpowers). Enables a primary orchestrating agent to decompose complex workflows into isolated, parallel sub-tasks, delegate them with precise context boundaries, monitor execution, and synthesize outputs with zero merge conflicts.
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
|
|
16
|
+
Activate whenever:
|
|
17
|
+
|
|
18
|
+
- A task can be parallelized across distinct modules, services, or test suites.
|
|
19
|
+
- Long-running exploratory research or multi-file refactoring exceeds single-context budget.
|
|
20
|
+
- Running autonomous subagent workers for specialized roles (e.g. specialized QA tester, Security auditor, Docs generator).
|
|
21
|
+
|
|
22
|
+
## Rules & Patterns
|
|
23
|
+
|
|
24
|
+
### 1. The Blast Radius Boundary Rule
|
|
25
|
+
|
|
26
|
+
Before delegating any subagent task:
|
|
27
|
+
|
|
28
|
+
- **Zero File Overlap**: Each subagent MUST have a mutually exclusive list of target files. Two subagents must never be instructed to edit the same file concurrently.
|
|
29
|
+
- **Explicit Inputs & Outputs**: Provide only the minimal schema, contract, or mock that the subagent needs. Do not dump the entire workspace into subagent prompts.
|
|
30
|
+
|
|
31
|
+
### 2. The 4-Step Delegation Lifecycle
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
[ Orchestrator ]
|
|
35
|
+
│
|
|
36
|
+
├─▶ 1. DECOMPOSE: Break into orthogonal tasks with non-overlapping file sets
|
|
37
|
+
│
|
|
38
|
+
├─▶ 2. DISPATCH: Launch subagent with precise goal, constraints, and finish criteria
|
|
39
|
+
│
|
|
40
|
+
├─▶ 3. AWAIT & VERIFY: Validate subagent output against its individual quality gate
|
|
41
|
+
│
|
|
42
|
+
└─▶ 4. SYNTHESIZE: Merge subagent results into the main branch and run global regression suite
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 3. Context Hand-off Specification
|
|
46
|
+
|
|
47
|
+
Every subagent dispatch prompt must contain:
|
|
48
|
+
|
|
49
|
+
1. **Target Objective**: Single, verifiable deliverable.
|
|
50
|
+
2. **Read-Only Context**: Files to consult as reference without modifying.
|
|
51
|
+
3. **Write Scope**: Exact file paths the subagent is permitted to create or modify.
|
|
52
|
+
4. **Completion Signal**: Explicit instruction to report `DONE` with test evidence or `BLOCKED` with reason.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Code Examples
|
|
57
|
+
|
|
58
|
+
### Orchestrator Task Dispatch Template
|
|
59
|
+
|
|
60
|
+
```markdown
|
|
61
|
+
**Subagent Task: Order Validation Service**
|
|
62
|
+
|
|
63
|
+
- **Role**: `[ROLE: Senior Developer]`
|
|
64
|
+
- **Goal**: Implement Zod validation schema and unit tests for order payloads.
|
|
65
|
+
- **Write Scope**:
|
|
66
|
+
- `src/services/order/validation.ts`
|
|
67
|
+
- `tests/services/order/validation.test.ts`
|
|
68
|
+
- **Read-Only Reference**:
|
|
69
|
+
- `src/types/order.ts`
|
|
70
|
+
- **Quality Gate**:
|
|
71
|
+
- Run `npx vitest run tests/services/order/validation.test.ts`
|
|
72
|
+
- All tests must pass with 100% coverage of validation rules.
|
|
73
|
+
- **Finish Criteria**:
|
|
74
|
+
- Report exact test output and finish with `DONE`.
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Validation Checklist
|
|
80
|
+
|
|
81
|
+
- [ ] All delegated tasks have disjoint, non-overlapping file sets.
|
|
82
|
+
- [ ] Every subagent prompt has explicit read vs write boundaries.
|
|
83
|
+
- [ ] Subagent results verified individually before merging.
|
|
84
|
+
- [ ] Global regression suite executed across the entire repository after all subagents finish.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Common Mistakes
|
|
89
|
+
|
|
90
|
+
- **Concurrent file collisions**: Assigning two subagents to modify the same route handler or lockfile.
|
|
91
|
+
- **Unbounded delegation**: Asking a subagent to "improve the codebase" without specific file limits.
|
|
92
|
+
- **Trusting without verification**: Assuming subagent code works without executing the test gate in the parent context.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Integration Notes
|
|
97
|
+
|
|
98
|
+
- Integrates with `engineering-workflow` during the PLAN and BUILD phases.
|
|
99
|
+
- Works directly with `gstack-roles` to assign specific specialist personas to each subagent.
|
|
100
|
+
- Employs `ponytail-mindset` to keep subagent implementations minimal.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
name: subagent-orchestrator
|
|
2
|
+
description: Subagent delegation and parallel coordination skill. Implements task decomposition, context hand-offs, blast-radius boundary isolation, and conflict-free merge synthesis.
|
|
3
|
+
tags:
|
|
4
|
+
- subagents
|
|
5
|
+
- orchestration
|
|
6
|
+
- multi-agent
|
|
7
|
+
- workflow
|
|
8
|
+
version: 1.0.0
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# system-design Examples — Anti-patterns vs ContextOS Standard
|
|
2
|
+
|
|
3
|
+
## Example 1: Database Caching Strategy
|
|
4
|
+
|
|
5
|
+
### Anti-pattern: Cache-Aside with Unbounded Thundering Herd
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// BAD: When cache expires, 10,000 concurrent requests hit PostgreSQL simultaneously
|
|
9
|
+
async function getUserProfile(id: string) {
|
|
10
|
+
const cached = await redis.get(`user:${id}`);
|
|
11
|
+
if (cached) return JSON.parse(cached);
|
|
12
|
+
const user = await db.user.findUnique({ where: { id } });
|
|
13
|
+
await redis.set(`user:${id}`, JSON.stringify(user), 'EX', 300);
|
|
14
|
+
return user;
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Best practice: ContextOS Standard (Mutex Lock / Single-Flight Pattern)
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
// GOOD: Only one worker fetches from DB on cache miss; others wait
|
|
22
|
+
import { singleflight } from './singleflight';
|
|
23
|
+
|
|
24
|
+
async function getUserProfile(id: string) {
|
|
25
|
+
const cached = await redis.get(`user:${id}`);
|
|
26
|
+
if (cached) return JSON.parse(cached);
|
|
27
|
+
|
|
28
|
+
return singleflight.do(`user:${id}`, async () => {
|
|
29
|
+
const fresh = await redis.get(`user:${id}`);
|
|
30
|
+
if (fresh) return JSON.parse(fresh);
|
|
31
|
+
|
|
32
|
+
const user = await db.user.findUnique({ where: { id } });
|
|
33
|
+
if (user) {
|
|
34
|
+
await redis.set(`user:${id}`, JSON.stringify(user), 'EX', 300);
|
|
35
|
+
}
|
|
36
|
+
return user;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Example 2: Outbox Pattern for Distributed Consistency
|
|
44
|
+
|
|
45
|
+
### Anti-pattern: Dual-Write Anti-pattern (Direct DB write + Kafka publish)
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
// BAD: If Kafka publish fails, DB change is committed but event is lost forever
|
|
49
|
+
async function createOrder(data: OrderInput) {
|
|
50
|
+
const order = await db.order.create({ data });
|
|
51
|
+
await kafkaProducer.send({ topic: 'orders', messages: [{ value: JSON.stringify(order) }] });
|
|
52
|
+
return order;
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Best practice: ContextOS Standard (Transactional Outbox)
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
// GOOD: Order and Outbox record committed in a single atomic DB transaction
|
|
60
|
+
async function createOrder(data: OrderInput) {
|
|
61
|
+
return await db.$transaction(async (tx) => {
|
|
62
|
+
const order = await tx.order.create({ data });
|
|
63
|
+
await tx.outbox.create({
|
|
64
|
+
data: {
|
|
65
|
+
aggregateType: 'Order',
|
|
66
|
+
aggregateId: order.id,
|
|
67
|
+
eventType: 'OrderCreated',
|
|
68
|
+
payload: JSON.stringify(order),
|
|
69
|
+
status: 'PENDING',
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
return order;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
```
|