contextos-agents 2.1.0 → 2.2.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 (192) hide show
  1. package/.agents/adapters/aider/export.js +2 -2
  2. package/.agents/adapters/claude/export.js +53 -2
  3. package/.agents/adapters/drift-detector.js +6 -3
  4. package/.agents/adapters/pure-compiler.js +18 -6
  5. package/.agents/ctx.js +13 -8
  6. package/.agents/plugins.js +347 -26
  7. package/.agents/profiles.js +32 -11
  8. package/README.md +38 -3
  9. package/bin/commands/hook.js +50 -12
  10. package/bin/commands/scan.js +10 -3
  11. package/bin/index.js +165 -53
  12. package/bin/lib/git-snapshot.js +70 -43
  13. package/bin/lib/scan.js +108 -27
  14. package/bin/lib/ui.js +140 -0
  15. package/catalog/skills/adapters/EXAMPLES.md +19 -0
  16. package/catalog/skills/adapters/SKILL.md +101 -0
  17. package/catalog/skills/adapters/TROUBLESHOOTING.md +7 -0
  18. package/catalog/skills/adapters/VALIDATION.json +12 -0
  19. package/catalog/skills/adapters/skill.yaml +13 -0
  20. package/catalog/skills/api-design/EXAMPLES.md +91 -0
  21. package/catalog/skills/api-design/SKILL.md +63 -0
  22. package/catalog/skills/api-design/TROUBLESHOOTING.md +54 -0
  23. package/catalog/skills/api-design/VALIDATION.json +11 -0
  24. package/catalog/skills/api-design/skill.yaml +14 -0
  25. package/catalog/skills/architecture-diagrams/SKILL.md +108 -0
  26. package/catalog/skills/architecture-diagrams/VALIDATION.json +12 -0
  27. package/catalog/skills/architecture-diagrams/skill.yaml +9 -0
  28. package/catalog/skills/brutalist-design/EXAMPLES.md +59 -0
  29. package/catalog/skills/brutalist-design/SKILL.md +150 -0
  30. package/catalog/skills/brutalist-design/VALIDATION.json +12 -0
  31. package/catalog/skills/brutalist-design/skill.yaml +10 -0
  32. package/catalog/skills/ci-cd/EXAMPLES.md +79 -0
  33. package/catalog/skills/ci-cd/SKILL.md +69 -0
  34. package/catalog/skills/ci-cd/TROUBLESHOOTING.md +52 -0
  35. package/catalog/skills/ci-cd/VALIDATION.json +11 -0
  36. package/catalog/skills/ci-cd/skill.yaml +13 -0
  37. package/catalog/skills/database/EXAMPLES.md +74 -0
  38. package/catalog/skills/database/SKILL.md +101 -0
  39. package/catalog/skills/database/TROUBLESHOOTING.md +18 -0
  40. package/catalog/skills/database/VALIDATION.json +11 -0
  41. package/catalog/skills/database/skill.yaml +14 -0
  42. package/catalog/skills/ddd/EXAMPLES.md +42 -0
  43. package/catalog/skills/ddd/SKILL.md +247 -0
  44. package/catalog/skills/ddd/TROUBLESHOOTING.md +19 -0
  45. package/catalog/skills/ddd/VALIDATION.json +12 -0
  46. package/catalog/skills/ddd/skill.yaml +14 -0
  47. package/catalog/skills/decisions/EXAMPLES.md +35 -0
  48. package/catalog/skills/decisions/SKILL.md +90 -0
  49. package/catalog/skills/decisions/TROUBLESHOOTING.md +13 -0
  50. package/catalog/skills/decisions/VALIDATION.json +12 -0
  51. package/catalog/skills/decisions/skill.yaml +13 -0
  52. package/catalog/skills/docker/EXAMPLES.md +56 -0
  53. package/catalog/skills/docker/SKILL.md +169 -0
  54. package/catalog/skills/docker/TROUBLESHOOTING.md +18 -0
  55. package/catalog/skills/docker/VALIDATION.json +11 -0
  56. package/catalog/skills/docker/skill.yaml +13 -0
  57. package/catalog/skills/fastapi/EXAMPLES.md +36 -0
  58. package/catalog/skills/fastapi/SKILL.md +171 -0
  59. package/catalog/skills/fastapi/TROUBLESHOOTING.md +19 -0
  60. package/catalog/skills/fastapi/VALIDATION.json +12 -0
  61. package/catalog/skills/fastapi/skill.yaml +14 -0
  62. package/catalog/skills/generators/EXAMPLES.md +19 -0
  63. package/catalog/skills/generators/SKILL.md +110 -0
  64. package/catalog/skills/generators/TROUBLESHOOTING.md +7 -0
  65. package/catalog/skills/generators/VALIDATION.json +12 -0
  66. package/catalog/skills/generators/skill.yaml +22 -0
  67. package/catalog/skills/generators/templates/API.md +77 -0
  68. package/catalog/skills/generators/templates/ARCHITECTURE.md +70 -0
  69. package/catalog/skills/generators/templates/DATABASE.md +42 -0
  70. package/catalog/skills/generators/templates/DECISION.md +46 -0
  71. package/catalog/skills/generators/templates/PRD.md +67 -0
  72. package/catalog/skills/generators/templates/PROJECT_GRAPH.md +56 -0
  73. package/catalog/skills/generators/templates/ROADMAP.md +51 -0
  74. package/catalog/skills/generators/templates/TASKS.md +43 -0
  75. package/catalog/skills/generators/templates/UI.md +73 -0
  76. package/catalog/skills/graphify/EXAMPLES.md +73 -0
  77. package/catalog/skills/graphify/SKILL.md +130 -0
  78. package/catalog/skills/graphify/VALIDATION.json +12 -0
  79. package/catalog/skills/graphify/skill.yaml +13 -0
  80. package/catalog/skills/impeccable-design/EXAMPLES.md +26 -0
  81. package/catalog/skills/impeccable-design/SKILL.md +201 -0
  82. package/catalog/skills/impeccable-design/TROUBLESHOOTING.md +19 -0
  83. package/catalog/skills/impeccable-design/VALIDATION.json +12 -0
  84. package/catalog/skills/impeccable-design/skill.yaml +15 -0
  85. package/catalog/skills/interview-me/SKILL.md +97 -0
  86. package/catalog/skills/interview-me/VALIDATION.json +12 -0
  87. package/catalog/skills/interview-me/skill.yaml +9 -0
  88. package/catalog/skills/microservices/EXAMPLES.md +38 -0
  89. package/catalog/skills/microservices/SKILL.md +164 -0
  90. package/catalog/skills/microservices/TROUBLESHOOTING.md +19 -0
  91. package/catalog/skills/microservices/VALIDATION.json +12 -0
  92. package/catalog/skills/microservices/skill.yaml +14 -0
  93. package/catalog/skills/minimalist-design/EXAMPLES.md +58 -0
  94. package/catalog/skills/minimalist-design/SKILL.md +113 -0
  95. package/catalog/skills/minimalist-design/VALIDATION.json +12 -0
  96. package/catalog/skills/minimalist-design/skill.yaml +10 -0
  97. package/catalog/skills/nestjs/EXAMPLES.md +40 -0
  98. package/catalog/skills/nestjs/SKILL.md +139 -0
  99. package/catalog/skills/nestjs/TROUBLESHOOTING.md +19 -0
  100. package/catalog/skills/nestjs/VALIDATION.json +12 -0
  101. package/catalog/skills/nestjs/skill.yaml +14 -0
  102. package/catalog/skills/nextjs/EXAMPLES.md +40 -0
  103. package/catalog/skills/nextjs/SKILL.md +163 -0
  104. package/catalog/skills/nextjs/TROUBLESHOOTING.md +19 -0
  105. package/catalog/skills/nextjs/VALIDATION.json +12 -0
  106. package/catalog/skills/nextjs/skill.yaml +14 -0
  107. package/catalog/skills/node/EXAMPLES.md +80 -0
  108. package/catalog/skills/node/SKILL.md +128 -0
  109. package/catalog/skills/node/TROUBLESHOOTING.md +19 -0
  110. package/catalog/skills/node/VALIDATION.json +12 -0
  111. package/catalog/skills/node/skill.yaml +14 -0
  112. package/catalog/skills/performance/EXAMPLES.md +30 -0
  113. package/catalog/skills/performance/SKILL.md +75 -0
  114. package/catalog/skills/performance/TROUBLESHOOTING.md +19 -0
  115. package/catalog/skills/performance/VALIDATION.json +12 -0
  116. package/catalog/skills/performance/skill.yaml +14 -0
  117. package/catalog/skills/react/EXAMPLES.md +79 -0
  118. package/catalog/skills/react/SKILL.md +132 -0
  119. package/catalog/skills/react/TROUBLESHOOTING.md +19 -0
  120. package/catalog/skills/react/VALIDATION.json +12 -0
  121. package/catalog/skills/react/skill.yaml +14 -0
  122. package/catalog/skills/react-best-practices/SKILL.md +158 -0
  123. package/catalog/skills/react-best-practices/VALIDATION.json +12 -0
  124. package/catalog/skills/react-best-practices/skill.yaml +13 -0
  125. package/catalog/skills/redesign-audit/SKILL.md +117 -0
  126. package/catalog/skills/redesign-audit/VALIDATION.json +12 -0
  127. package/catalog/skills/redesign-audit/skill.yaml +9 -0
  128. package/catalog/skills/security-audit/EXAMPLES.md +79 -0
  129. package/catalog/skills/security-audit/SKILL.md +91 -0
  130. package/catalog/skills/security-audit/TROUBLESHOOTING.md +46 -0
  131. package/catalog/skills/security-audit/VALIDATION.json +11 -0
  132. package/catalog/skills/security-audit/skill.yaml +14 -0
  133. package/catalog/skills/soft-design/EXAMPLES.md +51 -0
  134. package/catalog/skills/soft-design/SKILL.md +108 -0
  135. package/catalog/skills/soft-design/VALIDATION.json +12 -0
  136. package/catalog/skills/soft-design/skill.yaml +10 -0
  137. package/catalog/skills/state-management/EXAMPLES.md +56 -0
  138. package/catalog/skills/state-management/SKILL.md +168 -0
  139. package/catalog/skills/state-management/TROUBLESHOOTING.md +18 -0
  140. package/catalog/skills/state-management/VALIDATION.json +11 -0
  141. package/catalog/skills/state-management/skill.yaml +14 -0
  142. package/catalog/skills/subagent-orchestrator/SKILL.md +117 -0
  143. package/catalog/skills/subagent-orchestrator/VALIDATION.json +12 -0
  144. package/catalog/skills/subagent-orchestrator/skill.yaml +9 -0
  145. package/catalog/skills/system-design/EXAMPLES.md +75 -0
  146. package/catalog/skills/system-design/SKILL.md +419 -0
  147. package/catalog/skills/system-design/TROUBLESHOOTING.md +19 -0
  148. package/catalog/skills/system-design/VALIDATION.json +12 -0
  149. package/catalog/skills/system-design/skill.yaml +14 -0
  150. package/catalog/skills/terraform/EXAMPLES.md +74 -0
  151. package/catalog/skills/terraform/SKILL.md +55 -0
  152. package/catalog/skills/terraform/TROUBLESHOOTING.md +53 -0
  153. package/catalog/skills/terraform/VALIDATION.json +11 -0
  154. package/catalog/skills/terraform/skill.yaml +14 -0
  155. package/catalog/skills/testing/EXAMPLES.md +122 -0
  156. package/catalog/skills/testing/SKILL.md +70 -0
  157. package/catalog/skills/testing/TROUBLESHOOTING.md +18 -0
  158. package/catalog/skills/testing/VALIDATION.json +11 -0
  159. package/catalog/skills/testing/skill.yaml +14 -0
  160. package/catalog/skills/typescript/EXAMPLES.md +64 -0
  161. package/catalog/skills/typescript/SKILL.md +112 -0
  162. package/catalog/skills/typescript/TROUBLESHOOTING.md +19 -0
  163. package/catalog/skills/typescript/VALIDATION.json +12 -0
  164. package/catalog/skills/typescript/skill.yaml +14 -0
  165. package/catalog/skills/ui-design/EXAMPLES.md +21 -0
  166. package/catalog/skills/ui-design/SKILL.md +124 -0
  167. package/catalog/skills/ui-design/TROUBLESHOOTING.md +19 -0
  168. package/catalog/skills/ui-design/VALIDATION.json +12 -0
  169. package/catalog/skills/ui-design/skill.yaml +16 -0
  170. package/catalog/skills/ui-ux-pro/EXAMPLES.md +62 -0
  171. package/catalog/skills/ui-ux-pro/SKILL.md +418 -0
  172. package/catalog/skills/ui-ux-pro/TROUBLESHOOTING.md +19 -0
  173. package/catalog/skills/ui-ux-pro/VALIDATION.json +12 -0
  174. package/catalog/skills/ui-ux-pro/skill.yaml +14 -0
  175. package/catalog/skills/ux-design/EXAMPLES.md +36 -0
  176. package/catalog/skills/ux-design/SKILL.md +116 -0
  177. package/catalog/skills/ux-design/TROUBLESHOOTING.md +19 -0
  178. package/catalog/skills/ux-design/VALIDATION.json +12 -0
  179. package/catalog/skills/ux-design/skill.yaml +16 -0
  180. package/catalog/skills/vercel-optimize/SKILL.md +83 -0
  181. package/catalog/skills/vercel-optimize/VALIDATION.json +12 -0
  182. package/catalog/skills/vercel-optimize/scripts/collect-signals.mjs +131 -0
  183. package/catalog/skills/vercel-optimize/scripts/gate-investigations.mjs +142 -0
  184. package/catalog/skills/vercel-optimize/scripts/merge-signals.mjs +143 -0
  185. package/catalog/skills/vercel-optimize/scripts/scan-codebase.mjs +174 -0
  186. package/catalog/skills/vercel-optimize/skill.yaml +15 -0
  187. package/catalog/skills/web-accessibility/EXAMPLES.md +39 -0
  188. package/catalog/skills/web-accessibility/SKILL.md +151 -0
  189. package/catalog/skills/web-accessibility/TROUBLESHOOTING.md +19 -0
  190. package/catalog/skills/web-accessibility/VALIDATION.json +12 -0
  191. package/catalog/skills/web-accessibility/skill.yaml +14 -0
  192. package/package.json +3 -2
@@ -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,12 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "type": "object",
4
+ "properties": {
5
+ "rules_followed": {
6
+ "type": "boolean"
7
+ }
8
+ },
9
+ "required": [
10
+ "rules_followed"
11
+ ]
12
+ }
@@ -0,0 +1,10 @@
1
+ schemaVersion: 2
2
+ name: soft-design
3
+ category: design
4
+ type: instruction-only
5
+ description: High-end agency-grade UI architecture, haptic micro-aesthetics, and fluid spring motion choreography.
6
+ version: 1.0.0
7
+ resources:
8
+ - EXAMPLES.md
9
+ - SKILL.md
10
+ - VALIDATION.json
@@ -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,168 @@
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 asynchronous server state architecture in modern React and Next.js applications using Zustand and TanStack Query v5.
11
+
12
+ ## When to Use
13
+
14
+ Activate when managing asynchronous server data fetching, HTTP caching, optimistic UI updates, or global synchronous client UI state (modals, active filters, multi-step wizards, theme overrides).
15
+
16
+ ## Rules & Patterns
17
+
18
+ ### The Rule of Two States
19
+
20
+ 1. **SERVER STATE (Async)**: Managed exclusively by TanStack Query (`useQuery`, `useMutation`). Handles HTTP caching, stale-while-revalidate, deduplication, background refetching, pagination, and query invalidation.
21
+ 2. **CLIENT STATE (Sync)**: Managed by Zustand. Handles transient UI state: modal visibility, sidebar collapsed state, active filter values, wizard steps, and offline draft buffers.
22
+
23
+ ### Negative Constraints (What NOT to Do)
24
+
25
+ 1. **NEVER store server-fetched entity data in Zustand or Redux**: Store ONLY client-local UI state in Zustand. All API responses, lists, and entity records belong 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)`) or `useShallow` 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
+ 6. **NEVER use ad-hoc array strings for query keys**: Always define and use a centralized Query Key Factory to guarantee consistent cache invalidation.
31
+
32
+ ---
33
+
34
+ ### Pattern 1: Zustand Slices Architecture
35
+
36
+ Split large global stores into focused, typed slices that compose into a single unified hook:
37
+
38
+ ```typescript
39
+ import { create, StateCreator } from 'zustand';
40
+ import { devtools } from 'zustand/middleware';
41
+
42
+ interface UiSlice {
43
+ isSidebarOpen: boolean;
44
+ activeModal: string | null;
45
+ toggleSidebar: () => void;
46
+ openModal: (modalId: string) => void;
47
+ closeModal: () => void;
48
+ }
49
+
50
+ const createUiSlice: StateCreator<UiSlice> = (set) => ({
51
+ isSidebarOpen: true,
52
+ activeModal: null,
53
+ toggleSidebar: () => set((state) => ({ isSidebarOpen: !state.isSidebarOpen })),
54
+ openModal: (modalId) => set({ activeModal: modalId }),
55
+ closeModal: () => set({ activeModal: null }),
56
+ });
57
+
58
+ export const useAppStore = create<UiSlice>()(
59
+ devtools((...args) => ({
60
+ ...createUiSlice(...args),
61
+ }))
62
+ );
63
+ ```
64
+
65
+ ---
66
+
67
+ ### Pattern 2: Atomic Selectors & Re-render Prevention
68
+
69
+ Always pass specific selector functions to extract only the state your component needs:
70
+
71
+ ```typescript
72
+ // [BAD] Subscribes to the entire store; re-renders on ANY store change
73
+ const { isSidebarOpen, activeModal } = useAppStore();
74
+
75
+ // [GOOD] Subscribes only to isSidebarOpen; re-renders ONLY when it changes
76
+ const isSidebarOpen = useAppStore((state) => state.isSidebarOpen);
77
+
78
+ // [GOOD] Multiple values extracted without extra re-renders using useShallow
79
+ import { useShallow } from 'zustand/react/shallow';
80
+
81
+ const { isSidebarOpen, activeModal } = useAppStore(
82
+ useShallow((state) => ({
83
+ isSidebarOpen: state.isSidebarOpen,
84
+ activeModal: state.activeModal,
85
+ }))
86
+ );
87
+ ```
88
+
89
+ ---
90
+
91
+ ### Pattern 3: TanStack Query Key Factory Standard
92
+
93
+ Maintain a structured hierarchy of query keys for predictable invalidation:
94
+
95
+ ```typescript
96
+ export const projectKeys = {
97
+ all: ['projects'] as const,
98
+ lists: () => [...projectKeys.all, 'list'] as const,
99
+ list: (filters: ProjectFilters) => [...projectKeys.lists(), filters] as const,
100
+ details: () => [...projectKeys.all, 'detail'] as const,
101
+ detail: (id: string) => [...projectKeys.details(), id] as const,
102
+ };
103
+ ```
104
+
105
+ ---
106
+
107
+ ### Pattern 4: Optimistic Mutation with Rollback
108
+
109
+ Safely update UI instantly and roll back on network or server error:
110
+
111
+ ```typescript
112
+ import { useMutation, useQueryClient } from '@tanstack/react-query';
113
+ import { projectKeys } from './query-keys';
114
+
115
+ export function useUpdateProject() {
116
+ const queryClient = useQueryClient();
117
+
118
+ return useMutation({
119
+ mutationFn: (updated: { id: string; name: string }) => api.patch(`/projects/${updated.id}`, updated),
120
+ onMutate: async (newProject) => {
121
+ // 1. Cancel outgoing queries to avoid overwriting optimistic update
122
+ await queryClient.cancelQueries({ queryKey: projectKeys.detail(newProject.id) });
123
+
124
+ // 2. Snapshot the previous value
125
+ const previousProject = queryClient.getQueryData(projectKeys.detail(newProject.id));
126
+
127
+ // 3. Optimistically update the cache
128
+ queryClient.setQueryData(projectKeys.detail(newProject.id), (old: any) => ({
129
+ ...old,
130
+ ...newProject,
131
+ }));
132
+
133
+ // 4. Return context with snapshot for rollback
134
+ return { previousProject, projectId: newProject.id };
135
+ },
136
+ onError: (err, newProject, context) => {
137
+ // 5. Rollback to snapshot on failure
138
+ if (context?.previousProject) {
139
+ queryClient.setQueryData(projectKeys.detail(context.projectId), context.previousProject);
140
+ }
141
+ },
142
+ onSettled: (data, err, variables) => {
143
+ // 6. Always re-sync with server after error or success
144
+ queryClient.invalidateQueries({ queryKey: projectKeys.detail(variables.id) });
145
+ },
146
+ });
147
+ }
148
+ ```
149
+
150
+ ---
151
+
152
+ ## Validation Checklist
153
+
154
+ - [ ] Clear separation: Server state in TanStack Query, client UI state in Zustand.
155
+ - [ ] Atomic selectors or `useShallow` used on all store consumers.
156
+ - [ ] Centralized Query Key Factory used for all `queryKey` definitions.
157
+ - [ ] Optimistic mutations implement `onMutate`, `onError` rollback, and `onSettled` invalidation.
158
+ - [ ] Zero duplicated or redundant derived state stored in global stores.
159
+
160
+ ## Common Mistakes
161
+
162
+ - **Storing API collections in Zustand**: Results in stale data and duplicate caching layers. Use TanStack Query.
163
+ - **Missing query cancellation in onMutate**: Causes race conditions between ongoing fetches and optimistic updates.
164
+ - **Forgetting atomic selectors**: Causes every component reading one store value to re-render when an unrelated value changes.
165
+
166
+ ## Integration Notes
167
+
168
+ 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,14 @@
1
+ schemaVersion: 2
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
+ version: 1.0.0
5
+ category: frontend
6
+ type: instruction-only
7
+ requires:
8
+ - react
9
+ - typescript
10
+ resources:
11
+ - EXAMPLES.md
12
+ - SKILL.md
13
+ - TROUBLESHOOTING.md
14
+ - VALIDATION.json
@@ -0,0 +1,117 @@
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 must be backed by an immutable `TaskBrief`:
48
+
49
+ ```ts
50
+ type TaskBrief = Readonly<{
51
+ taskId: string;
52
+ baseSha: string;
53
+ objective: string;
54
+ writeScope: readonly string[];
55
+ testCommand: string;
56
+ expectedResult: string;
57
+ maxAttempts: number;
58
+ }>;
59
+ ```
60
+
61
+ Create the brief once before dispatch. Agents and retry loops must reuse it without
62
+ changing the base commit, scope, verification command, or acceptance result.
63
+ Every subagent dispatch prompt must contain:
64
+
65
+ 1. **Target Objective**: Single, verifiable deliverable.
66
+ 2. **Read-Only Context**: Files to consult as reference without modifying.
67
+ 3. **Write Scope**: Exact file paths the subagent is permitted to create or modify.
68
+ 4. **Completion Signal**: Explicit instruction to report `DONE` with test evidence or `BLOCKED` with reason.
69
+
70
+ ---
71
+
72
+ ## Code Examples
73
+
74
+ ### Orchestrator Task Dispatch Template
75
+
76
+ ```markdown
77
+ **Subagent Task: Order Validation Service**
78
+
79
+ - **Role**: `[ROLE: Senior Developer]`
80
+ - **Goal**: Implement Zod validation schema and unit tests for order payloads.
81
+ - **Write Scope**:
82
+ - `src/services/order/validation.ts`
83
+ - `tests/services/order/validation.test.ts`
84
+ - **Read-Only Reference**:
85
+ - `src/types/order.ts`
86
+ - **Quality Gate**:
87
+ - Run `npx vitest run tests/services/order/validation.test.ts`
88
+ - All tests must pass with 100% coverage of validation rules.
89
+ - **Finish Criteria**:
90
+ - Report exact test output and finish with `DONE`.
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Validation Checklist
96
+
97
+ - [ ] All delegated tasks have disjoint, non-overlapping file sets.
98
+ - [ ] Every worker received an immutable `TaskBrief` tied to the original `baseSha`.
99
+ - [ ] Every subagent prompt has explicit read vs write boundaries.
100
+ - [ ] Subagent results verified individually before merging.
101
+ - [ ] Global regression suite executed across the entire repository after all subagents finish.
102
+
103
+ ---
104
+
105
+ ## Common Mistakes
106
+
107
+ - **Concurrent file collisions**: Assigning two subagents to modify the same route handler or lockfile.
108
+ - **Unbounded delegation**: Asking a subagent to "improve the codebase" without specific file limits.
109
+ - **Trusting without verification**: Assuming subagent code works without executing the test gate in the parent context.
110
+
111
+ ---
112
+
113
+ ## Integration Notes
114
+
115
+ - Integrates with `engineering-workflow` during the PLAN and BUILD phases.
116
+ - Works directly with `gstack-roles` to assign specific specialist personas to each subagent.
117
+ - Employs `ponytail-mindset` to keep subagent implementations minimal.
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "type": "object",
4
+ "properties": {
5
+ "rules_followed": {
6
+ "type": "boolean"
7
+ }
8
+ },
9
+ "required": [
10
+ "rules_followed"
11
+ ]
12
+ }
@@ -0,0 +1,9 @@
1
+ schemaVersion: 2
2
+ name: subagent-orchestrator
3
+ category: engineering
4
+ type: runtime
5
+ description: Subagent delegation and parallel coordination skill. Implements task decomposition, context hand-offs, blast-radius boundary isolation, and conflict-free merge synthesis.
6
+ version: 1.0.0
7
+ resources:
8
+ - SKILL.md
9
+ - VALIDATION.json
@@ -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
+ ```