contextos-agents 2.0.0 → 2.1.1

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 (223) hide show
  1. package/.agents/AGENTS.md +53 -33
  2. package/.agents/adapters/aider/export.js +41 -14
  3. package/.agents/adapters/claude/export.js +54 -3
  4. package/.agents/adapters/copilot/export.js +1 -1
  5. package/.agents/adapters/cursor/export.js +1 -1
  6. package/.agents/adapters/drift-detector.js +86 -10
  7. package/.agents/adapters/gemini/export.js +1 -1
  8. package/.agents/adapters/pure-compiler.js +28 -6
  9. package/.agents/adapters/shared.js +13 -4
  10. package/.agents/adapters/zed/export.js +1 -1
  11. package/.agents/compiled/registry.v2.json +29 -25
  12. package/.agents/compiled/registry.v2.sha256 +1 -1
  13. package/.agents/core/skills/context-os/SKILL.md +34 -37
  14. package/.agents/core/skills/engineering-workflow/SKILL.md +24 -24
  15. package/.agents/core/skills/gemini-precision/EXAMPLES.md +72 -0
  16. package/.agents/core/skills/gemini-precision/SKILL.md +2 -1
  17. package/.agents/core/skills/gemini-precision/TROUBLESHOOTING.md +25 -0
  18. package/.agents/core/skills/gemini-precision/skill.yaml +2 -0
  19. package/.agents/core/skills/gstack-roles/SKILL.md +7 -6
  20. package/.agents/core/skills/security/SKILL.md +44 -16
  21. package/.agents/core/skills/security/skill.yaml +0 -1
  22. package/.agents/ctx.js +20 -14
  23. package/.agents/generated/claude/skills/context-os/SKILL.md +34 -37
  24. package/.agents/generated/claude/skills/engineering-workflow/SKILL.md +24 -24
  25. package/.agents/generated/claude/skills/gemini-precision/SKILL.md +102 -1
  26. package/.agents/generated/claude/skills/gstack-roles/SKILL.md +7 -6
  27. package/.agents/generated/claude/skills/security/SKILL.md +44 -16
  28. package/.agents/generated/gemini/skills/context-os/SKILL.md +34 -37
  29. package/.agents/generated/gemini/skills/engineering-workflow/SKILL.md +24 -24
  30. package/.agents/generated/gemini/skills/gemini-precision/SKILL.md +105 -1
  31. package/.agents/generated/gemini/skills/gstack-roles/SKILL.md +7 -6
  32. package/.agents/generated/gemini/skills/security/SKILL.md +44 -125
  33. package/.agents/plugins.js +105 -8
  34. package/.agents/profiles.js +32 -11
  35. package/.agents/resolver/canonical-resolver.js +7 -7
  36. package/.agents/validate.js +69 -1
  37. package/README.md +81 -24
  38. package/bin/commands/hook.js +167 -0
  39. package/bin/commands/scan.js +77 -0
  40. package/bin/commands.js +39 -1
  41. package/bin/index.js +151 -34
  42. package/bin/lib/gate.js +171 -0
  43. package/bin/lib/git-snapshot.js +214 -0
  44. package/bin/lib/scan.js +461 -0
  45. package/catalog/skills/adapters/EXAMPLES.md +19 -0
  46. package/catalog/skills/adapters/SKILL.md +101 -0
  47. package/catalog/skills/adapters/TROUBLESHOOTING.md +7 -0
  48. package/catalog/skills/adapters/VALIDATION.json +12 -0
  49. package/catalog/skills/adapters/skill.yaml +13 -0
  50. package/catalog/skills/api-design/EXAMPLES.md +91 -0
  51. package/catalog/skills/api-design/SKILL.md +63 -0
  52. package/catalog/skills/api-design/TROUBLESHOOTING.md +54 -0
  53. package/catalog/skills/api-design/VALIDATION.json +11 -0
  54. package/catalog/skills/api-design/skill.yaml +14 -0
  55. package/catalog/skills/architecture-diagrams/SKILL.md +108 -0
  56. package/catalog/skills/architecture-diagrams/VALIDATION.json +12 -0
  57. package/catalog/skills/architecture-diagrams/skill.yaml +9 -0
  58. package/catalog/skills/brutalist-design/EXAMPLES.md +59 -0
  59. package/catalog/skills/brutalist-design/SKILL.md +150 -0
  60. package/catalog/skills/brutalist-design/VALIDATION.json +12 -0
  61. package/catalog/skills/brutalist-design/skill.yaml +10 -0
  62. package/catalog/skills/ci-cd/EXAMPLES.md +79 -0
  63. package/catalog/skills/ci-cd/SKILL.md +69 -0
  64. package/catalog/skills/ci-cd/TROUBLESHOOTING.md +52 -0
  65. package/catalog/skills/ci-cd/VALIDATION.json +11 -0
  66. package/catalog/skills/ci-cd/skill.yaml +13 -0
  67. package/catalog/skills/database/EXAMPLES.md +74 -0
  68. package/catalog/skills/database/SKILL.md +101 -0
  69. package/catalog/skills/database/TROUBLESHOOTING.md +18 -0
  70. package/catalog/skills/database/VALIDATION.json +11 -0
  71. package/catalog/skills/database/skill.yaml +14 -0
  72. package/catalog/skills/ddd/EXAMPLES.md +42 -0
  73. package/catalog/skills/ddd/SKILL.md +247 -0
  74. package/catalog/skills/ddd/TROUBLESHOOTING.md +19 -0
  75. package/catalog/skills/ddd/VALIDATION.json +12 -0
  76. package/catalog/skills/ddd/skill.yaml +14 -0
  77. package/catalog/skills/decisions/EXAMPLES.md +35 -0
  78. package/catalog/skills/decisions/SKILL.md +90 -0
  79. package/catalog/skills/decisions/TROUBLESHOOTING.md +13 -0
  80. package/catalog/skills/decisions/VALIDATION.json +12 -0
  81. package/catalog/skills/decisions/skill.yaml +13 -0
  82. package/catalog/skills/docker/EXAMPLES.md +56 -0
  83. package/catalog/skills/docker/SKILL.md +169 -0
  84. package/catalog/skills/docker/TROUBLESHOOTING.md +18 -0
  85. package/catalog/skills/docker/VALIDATION.json +11 -0
  86. package/catalog/skills/docker/skill.yaml +13 -0
  87. package/catalog/skills/fastapi/EXAMPLES.md +36 -0
  88. package/catalog/skills/fastapi/SKILL.md +171 -0
  89. package/catalog/skills/fastapi/TROUBLESHOOTING.md +19 -0
  90. package/catalog/skills/fastapi/VALIDATION.json +12 -0
  91. package/catalog/skills/fastapi/skill.yaml +14 -0
  92. package/catalog/skills/generators/EXAMPLES.md +19 -0
  93. package/catalog/skills/generators/SKILL.md +110 -0
  94. package/catalog/skills/generators/TROUBLESHOOTING.md +7 -0
  95. package/catalog/skills/generators/VALIDATION.json +12 -0
  96. package/catalog/skills/generators/skill.yaml +22 -0
  97. package/catalog/skills/generators/templates/API.md +77 -0
  98. package/catalog/skills/generators/templates/ARCHITECTURE.md +70 -0
  99. package/catalog/skills/generators/templates/DATABASE.md +42 -0
  100. package/catalog/skills/generators/templates/DECISION.md +46 -0
  101. package/catalog/skills/generators/templates/PRD.md +67 -0
  102. package/catalog/skills/generators/templates/PROJECT_GRAPH.md +56 -0
  103. package/catalog/skills/generators/templates/ROADMAP.md +51 -0
  104. package/catalog/skills/generators/templates/TASKS.md +43 -0
  105. package/catalog/skills/generators/templates/UI.md +73 -0
  106. package/catalog/skills/graphify/EXAMPLES.md +73 -0
  107. package/catalog/skills/graphify/SKILL.md +130 -0
  108. package/catalog/skills/graphify/VALIDATION.json +12 -0
  109. package/catalog/skills/graphify/skill.yaml +13 -0
  110. package/catalog/skills/impeccable-design/EXAMPLES.md +26 -0
  111. package/catalog/skills/impeccable-design/SKILL.md +201 -0
  112. package/catalog/skills/impeccable-design/TROUBLESHOOTING.md +19 -0
  113. package/catalog/skills/impeccable-design/VALIDATION.json +12 -0
  114. package/catalog/skills/impeccable-design/skill.yaml +15 -0
  115. package/catalog/skills/interview-me/SKILL.md +97 -0
  116. package/catalog/skills/interview-me/VALIDATION.json +12 -0
  117. package/catalog/skills/interview-me/skill.yaml +9 -0
  118. package/catalog/skills/microservices/EXAMPLES.md +38 -0
  119. package/catalog/skills/microservices/SKILL.md +164 -0
  120. package/catalog/skills/microservices/TROUBLESHOOTING.md +19 -0
  121. package/catalog/skills/microservices/VALIDATION.json +12 -0
  122. package/catalog/skills/microservices/skill.yaml +14 -0
  123. package/catalog/skills/minimalist-design/EXAMPLES.md +58 -0
  124. package/catalog/skills/minimalist-design/SKILL.md +113 -0
  125. package/catalog/skills/minimalist-design/VALIDATION.json +12 -0
  126. package/catalog/skills/minimalist-design/skill.yaml +10 -0
  127. package/catalog/skills/nestjs/EXAMPLES.md +40 -0
  128. package/catalog/skills/nestjs/SKILL.md +139 -0
  129. package/catalog/skills/nestjs/TROUBLESHOOTING.md +19 -0
  130. package/catalog/skills/nestjs/VALIDATION.json +12 -0
  131. package/catalog/skills/nestjs/skill.yaml +14 -0
  132. package/catalog/skills/nextjs/EXAMPLES.md +40 -0
  133. package/catalog/skills/nextjs/SKILL.md +163 -0
  134. package/catalog/skills/nextjs/TROUBLESHOOTING.md +19 -0
  135. package/catalog/skills/nextjs/VALIDATION.json +12 -0
  136. package/catalog/skills/nextjs/skill.yaml +14 -0
  137. package/catalog/skills/node/EXAMPLES.md +80 -0
  138. package/catalog/skills/node/SKILL.md +128 -0
  139. package/catalog/skills/node/TROUBLESHOOTING.md +19 -0
  140. package/catalog/skills/node/VALIDATION.json +12 -0
  141. package/catalog/skills/node/skill.yaml +14 -0
  142. package/catalog/skills/performance/EXAMPLES.md +30 -0
  143. package/catalog/skills/performance/SKILL.md +75 -0
  144. package/catalog/skills/performance/TROUBLESHOOTING.md +19 -0
  145. package/catalog/skills/performance/VALIDATION.json +12 -0
  146. package/catalog/skills/performance/skill.yaml +14 -0
  147. package/catalog/skills/react/EXAMPLES.md +79 -0
  148. package/catalog/skills/react/SKILL.md +132 -0
  149. package/catalog/skills/react/TROUBLESHOOTING.md +19 -0
  150. package/catalog/skills/react/VALIDATION.json +12 -0
  151. package/catalog/skills/react/skill.yaml +14 -0
  152. package/catalog/skills/react-best-practices/SKILL.md +158 -0
  153. package/catalog/skills/react-best-practices/VALIDATION.json +12 -0
  154. package/catalog/skills/react-best-practices/skill.yaml +13 -0
  155. package/catalog/skills/redesign-audit/SKILL.md +117 -0
  156. package/catalog/skills/redesign-audit/VALIDATION.json +12 -0
  157. package/catalog/skills/redesign-audit/skill.yaml +9 -0
  158. package/catalog/skills/security-audit/EXAMPLES.md +79 -0
  159. package/catalog/skills/security-audit/SKILL.md +91 -0
  160. package/catalog/skills/security-audit/TROUBLESHOOTING.md +46 -0
  161. package/catalog/skills/security-audit/VALIDATION.json +11 -0
  162. package/catalog/skills/security-audit/skill.yaml +14 -0
  163. package/catalog/skills/soft-design/EXAMPLES.md +51 -0
  164. package/catalog/skills/soft-design/SKILL.md +108 -0
  165. package/catalog/skills/soft-design/VALIDATION.json +12 -0
  166. package/catalog/skills/soft-design/skill.yaml +10 -0
  167. package/catalog/skills/state-management/EXAMPLES.md +56 -0
  168. package/catalog/skills/state-management/SKILL.md +168 -0
  169. package/catalog/skills/state-management/TROUBLESHOOTING.md +18 -0
  170. package/catalog/skills/state-management/VALIDATION.json +11 -0
  171. package/catalog/skills/state-management/skill.yaml +14 -0
  172. package/catalog/skills/subagent-orchestrator/SKILL.md +117 -0
  173. package/catalog/skills/subagent-orchestrator/VALIDATION.json +12 -0
  174. package/catalog/skills/subagent-orchestrator/skill.yaml +9 -0
  175. package/catalog/skills/system-design/EXAMPLES.md +75 -0
  176. package/catalog/skills/system-design/SKILL.md +419 -0
  177. package/catalog/skills/system-design/TROUBLESHOOTING.md +19 -0
  178. package/catalog/skills/system-design/VALIDATION.json +12 -0
  179. package/catalog/skills/system-design/skill.yaml +14 -0
  180. package/catalog/skills/terraform/EXAMPLES.md +74 -0
  181. package/catalog/skills/terraform/SKILL.md +55 -0
  182. package/catalog/skills/terraform/TROUBLESHOOTING.md +53 -0
  183. package/catalog/skills/terraform/VALIDATION.json +11 -0
  184. package/catalog/skills/terraform/skill.yaml +14 -0
  185. package/catalog/skills/testing/EXAMPLES.md +122 -0
  186. package/catalog/skills/testing/SKILL.md +70 -0
  187. package/catalog/skills/testing/TROUBLESHOOTING.md +18 -0
  188. package/catalog/skills/testing/VALIDATION.json +11 -0
  189. package/catalog/skills/testing/skill.yaml +14 -0
  190. package/catalog/skills/typescript/EXAMPLES.md +64 -0
  191. package/catalog/skills/typescript/SKILL.md +112 -0
  192. package/catalog/skills/typescript/TROUBLESHOOTING.md +19 -0
  193. package/catalog/skills/typescript/VALIDATION.json +12 -0
  194. package/catalog/skills/typescript/skill.yaml +14 -0
  195. package/catalog/skills/ui-design/EXAMPLES.md +21 -0
  196. package/catalog/skills/ui-design/SKILL.md +124 -0
  197. package/catalog/skills/ui-design/TROUBLESHOOTING.md +19 -0
  198. package/catalog/skills/ui-design/VALIDATION.json +12 -0
  199. package/catalog/skills/ui-design/skill.yaml +16 -0
  200. package/catalog/skills/ui-ux-pro/EXAMPLES.md +62 -0
  201. package/catalog/skills/ui-ux-pro/SKILL.md +418 -0
  202. package/catalog/skills/ui-ux-pro/TROUBLESHOOTING.md +19 -0
  203. package/catalog/skills/ui-ux-pro/VALIDATION.json +12 -0
  204. package/catalog/skills/ui-ux-pro/skill.yaml +14 -0
  205. package/catalog/skills/ux-design/EXAMPLES.md +36 -0
  206. package/catalog/skills/ux-design/SKILL.md +116 -0
  207. package/catalog/skills/ux-design/TROUBLESHOOTING.md +19 -0
  208. package/catalog/skills/ux-design/VALIDATION.json +12 -0
  209. package/catalog/skills/ux-design/skill.yaml +16 -0
  210. package/catalog/skills/vercel-optimize/SKILL.md +83 -0
  211. package/catalog/skills/vercel-optimize/VALIDATION.json +12 -0
  212. package/catalog/skills/vercel-optimize/scripts/collect-signals.mjs +131 -0
  213. package/catalog/skills/vercel-optimize/scripts/gate-investigations.mjs +142 -0
  214. package/catalog/skills/vercel-optimize/scripts/merge-signals.mjs +143 -0
  215. package/catalog/skills/vercel-optimize/scripts/scan-codebase.mjs +174 -0
  216. package/catalog/skills/vercel-optimize/skill.yaml +15 -0
  217. package/catalog/skills/web-accessibility/EXAMPLES.md +39 -0
  218. package/catalog/skills/web-accessibility/SKILL.md +151 -0
  219. package/catalog/skills/web-accessibility/TROUBLESHOOTING.md +19 -0
  220. package/catalog/skills/web-accessibility/VALIDATION.json +12 -0
  221. package/catalog/skills/web-accessibility/skill.yaml +14 -0
  222. package/package.json +5 -2
  223. package/.agents/core/skills/security/security.md +0 -106
@@ -0,0 +1,163 @@
1
+ ---
2
+ name: Next.js
3
+ description: >
4
+ ContextOS skill for Next.js App Router, Server Components, Server Actions, performance optimization, and Vercel best practices.
5
+ ---
6
+
7
+ # Next.js App Router Best Practices
8
+
9
+ ## Overview
10
+
11
+ Enforces high-performance architectural patterns for Next.js App Router based on Vercel Engineering guidelines: React Server Components (RSC), zero-waterfall async pipelines, request deduplication via `React.cache()`, bundle optimization, and secure Server Actions.
12
+
13
+ ## When to Use
14
+
15
+ Activate whenever building, refactoring, or reviewing Next.js pages, layouts, Route Handlers (`app/api`), Server Actions, or components in the `app/` directory.
16
+
17
+ ## Negative Constraints (What NOT to Do)
18
+
19
+ 1. **NEVER use barrel imports for UI libraries**: Avoid `import { Button, Dialog } from '@/components'`. Import directly from the exact file (`import { Button } from '@/components/ui/button'`) to prevent bundler tree-shaking failures and trace bloat.
20
+ 2. **NEVER trust client-provided data or session state in Server Actions**: Always authenticate session and authorize tenant ownership inside the Server Action handler itself before mutating data.
21
+ 3. **NEVER introduce sequential `await` waterfalls for independent data**: Always use `Promise.all()` or parallel streaming `<Suspense>` boundaries.
22
+ 4. **NEVER pass large unneeded serialized data from Server to Client Components**: Only pass the specific primitive fields required by the client component (`server-dedup-props`).
23
+ 5. **NEVER use `useEffect` for data fetching**: Fetch directly in Server Components or use TanStack Query / SWR for client-side queries.
24
+ 6. **NEVER import server-only modules in client components**: Use the `server-only` package in data access layers to catch accidental client imports at build time.
25
+
26
+ ## Rules & Patterns
27
+
28
+ ### 1. Eliminating Async Waterfalls (Critical)
29
+
30
+ - **Parallel Fetching**: Fetch independent data concurrently at the top of the route or component.
31
+ - **Granular Streaming**: Wrap slow, non-critical subtrees in `<Suspense fallback={<Skeleton />}>` so critical above-the-fold content streams immediately.
32
+ - **Defer Awaits**: Check cheap synchronous conditions before awaiting remote resources.
33
+
34
+ ### 2. Request Deduplication & Caching (`server-cache-react`)
35
+
36
+ - Use `React.cache()` to deduplicate identical database or service calls across multiple components rendered in the same server request lifecycle.
37
+
38
+ ```tsx
39
+ import { cache } from 'react';
40
+ import { db } from '@/lib/db';
41
+
42
+ export const getCurrentUser = cache(async (userId: string) => {
43
+ return await db.user.findUnique({
44
+ where: { id: userId },
45
+ select: { id: true, name: true, role: true, email: true }
46
+ });
47
+ });
48
+ ```
49
+
50
+ ### 3. Secure Server Actions (`server-auth-actions`)
51
+
52
+ - Treat every Server Action as a public HTTP endpoint. Always validate session, authorization, and input schema with Zod.
53
+
54
+ ```tsx
55
+ 'use server';
56
+
57
+ import { z } from 'zod';
58
+ import { auth } from '@/lib/auth';
59
+ import { db } from '@/lib/db';
60
+ import { revalidatePath } from 'next/cache';
61
+
62
+ const UpdateProfileSchema = z.object({
63
+ name: z.string().min(2).max(50),
64
+ });
65
+
66
+ export async function updateProfile(formData: FormData) {
67
+ const session = await auth();
68
+ if (!session?.userId) throw new Error('Unauthorized');
69
+
70
+ const result = UpdateProfileSchema.safeParse({ name: formData.get('name') });
71
+ if (!result.success) return { error: 'Invalid input', issues: result.error.flatten() };
72
+
73
+ await db.user.update({
74
+ where: { id: session.userId },
75
+ data: { name: result.data.name },
76
+ });
77
+
78
+ revalidatePath('/settings');
79
+ return { success: true };
80
+ }
81
+ ```
82
+
83
+ ### 4. Bundle Optimization & Dynamic Imports (`bundle-dynamic-imports`)
84
+
85
+ - Heavy interactive client components (charts, rich-text editors, video players) must be dynamically loaded with `next/dynamic`.
86
+
87
+ ```tsx
88
+ import dynamic from 'next/dynamic';
89
+
90
+ const AnalyticsChart = dynamic(
91
+ () => import('@/components/analytics/chart').then(mod => mod.AnalyticsChart),
92
+ {
93
+ loading: () => <div className="h-64 animate-pulse bg-muted rounded-lg" />,
94
+ ssr: false,
95
+ }
96
+ );
97
+ ```
98
+
99
+ ### 5. Next.js 15+ Async Request APIs (`async-params`)
100
+
101
+ In Next.js 15+, `params`, `searchParams`, `cookies()`, and `headers()` are asynchronous and must be awaited:
102
+
103
+ ```tsx
104
+ // [GOOD] Next.js 15+ Page Component
105
+ interface PageProps {
106
+ params: Promise<{ id: string }>;
107
+ searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
108
+ }
109
+
110
+ export default async function UserPage({ params, searchParams }: PageProps) {
111
+ const { id } = await params;
112
+ const { tab } = await searchParams;
113
+ const user = await getUser(id);
114
+
115
+ return <UserProfile user={user} activeTab={tab as string} />;
116
+ }
117
+ ```
118
+
119
+ ### 6. Non-Blocking Background Tasks with `after()`
120
+
121
+ To execute logging, analytics, or cache priming without delaying the user's HTTP response:
122
+
123
+ ```typescript
124
+ import { after } from 'next/server';
125
+
126
+ export async function POST(request: Request) {
127
+ const data = await request.json();
128
+ const result = await processOrder(data);
129
+
130
+ // Executes asynchronously AFTER the response stream has completed
131
+ after(async () => {
132
+ await sendSlackNotification(result);
133
+ await indexOrderInSearch(result.id);
134
+ });
135
+
136
+ return Response.json({ success: true, orderId: result.id });
137
+ }
138
+ ```
139
+
140
+ ---
141
+
142
+ ## Code Examples
143
+
144
+ See `EXAMPLES.md` for detailed code examples and component templates.
145
+
146
+ ## Validation Checklist
147
+
148
+ - [ ] All database queries in RSC layers use `React.cache()` if called across multiple components.
149
+ - [ ] No barrel imports (`from '@/components'`); all imports point to exact component modules.
150
+ - [ ] Server Actions have explicit auth checks and Zod input validation.
151
+ - [ ] Heavy client widgets (charts, editors) use `next/dynamic`.
152
+ - [ ] Images use `next/image` with explicit `sizes` and `priority` on LCP elements.
153
+
154
+ ## Common Mistakes
155
+
156
+ - Using `'use client'` at page level instead of leaf components.
157
+ - Relying on client-side authentication checks for Server Actions without server-side validation.
158
+ - Chaining sequential awaits for independent data models.
159
+
160
+ ## Integration Notes
161
+
162
+ - Pairs with `react` and `ui-ux-pro` for component design and state management.
163
+ - Pairs with `security` for session authorization and input sanitization.
@@ -0,0 +1,19 @@
1
+ # nextjs Troubleshooting & Common Mistakes
2
+
3
+ ## 1. Hydration Mismatch Errors
4
+
5
+ - **Symptom**: "Text content does not match server-rendered HTML".
6
+ - **Root Cause**: Rendering dates, window dimensions, or local storage data that differs between server render and client hydration.
7
+ - **Fix**: Use suppressHydrationWarning on localized timestamps or load client-only state inside a useEffect after mount.
8
+
9
+ ## 2. Accidental Server Code Bundled to Client
10
+
11
+ - **Symptom**: "Module not found: Can't resolve 'fs' or 'pg' in client bundle".
12
+ - **Root Cause**: Client component importing a utility that transitively imports server-only database code.
13
+ - **Fix**: Separate server utilities into *.server.ts and install import 'server-only'; at the top of server files.
14
+
15
+ ## 3. Waterfall Fetches in Server Components
16
+
17
+ - **Symptom**: Page takes 3 seconds to load due to sequential await statements.
18
+ - **Root Cause**: Awaiting independent data sources one after another.
19
+ - **Fix**: Use Promise.all([fetchUsers(), fetchProducts()]) or separate into nested <Suspense> boundaries.
@@ -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,14 @@
1
+ schemaVersion: 2
2
+ id: nextjs
3
+ name: Next.js
4
+ category: frontend
5
+ type: instruction-only
6
+ requires: [react, typescript]
7
+ optional: [tailwind, prisma, next-auth, react-query]
8
+ conflicts: [vue, angular, remix]
9
+ weight: 9
10
+ resources:
11
+ - EXAMPLES.md
12
+ - SKILL.md
13
+ - TROUBLESHOOTING.md
14
+ - VALIDATION.json
@@ -0,0 +1,80 @@
1
+ # Node.js Examples - Anti-patterns vs ContextOS Standard
2
+
3
+ ## Example 1: Graceful Process Shutdown
4
+
5
+ ### Anti-pattern: Anti-pattern (Abruptly killing process and dropping in-flight requests)
6
+
7
+ ```javascript
8
+ // BAD: drops active database transactions and in-flight HTTP connections
9
+ process.on('SIGTERM', () => {
10
+ process.exit(0);
11
+ });
12
+ ```
13
+
14
+ ### Best practice: ContextOS Standard (Graceful connection draining)
15
+
16
+ ```typescript
17
+ // GOOD: drains active requests, closes database connections, and exits safely
18
+ import http from 'http';
19
+ import { prisma } from './db';
20
+ import { logger } from './logger';
21
+
22
+ export function setupGracefulShutdown(server: http.Server) {
23
+ const shutdown = async (signal: string) => {
24
+ logger.info(`Received ${signal}. Starting graceful shutdown...`);
25
+
26
+ server.close(async () => {
27
+ logger.info('HTTP server closed.');
28
+ try {
29
+ await prisma.$disconnect();
30
+ logger.info('Database pool closed.');
31
+ process.exit(0);
32
+ } catch (err) {
33
+ logger.error('Error during database disconnect:', err);
34
+ process.exit(1);
35
+ }
36
+ });
37
+
38
+ // Force shutdown after timeout if connections hang
39
+ setTimeout(() => {
40
+ logger.error('Forceful shutdown timeout reached.');
41
+ process.exit(1);
42
+ }, 10_000).unref();
43
+ };
44
+
45
+ process.on('SIGTERM', () => shutdown('SIGTERM'));
46
+ process.on('SIGINT', () => shutdown('SIGINT'));
47
+ }
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Example 2: Stream-based File Processing
53
+
54
+ ### Anti-pattern: Anti-pattern (Loading entire 500MB file into buffer)
55
+
56
+ ```typescript
57
+ // BAD: easily causes Out Of Memory (OOM) crashes under concurrency
58
+ app.get('/download/:file', async (req, res) => {
59
+ const data = await fs.promises.readFile(`/uploads/${req.params.file}`);
60
+ res.send(data);
61
+ });
62
+ ```
63
+
64
+ ### Best practice: ContextOS Standard (Piping read stream with pipeline)
65
+
66
+ ```typescript
67
+ // GOOD: constant memory usage (O(1) RAM) regardless of file size
68
+ import fs from 'fs';
69
+ import { pipeline } from 'stream/promises';
70
+
71
+ app.get('/download/:file', async (req, res, next) => {
72
+ try {
73
+ const filePath = `/uploads/${req.params.file}`;
74
+ const readStream = fs.createReadStream(filePath);
75
+ await pipeline(readStream, res);
76
+ } catch (err) {
77
+ next(err);
78
+ }
79
+ });
80
+ ```
@@ -0,0 +1,128 @@
1
+ ---
2
+ name: Node.js
3
+ description: >
4
+ ContextOS skill for Node.js
5
+ ---
6
+
7
+ # Node.js
8
+
9
+ ## Overview
10
+
11
+ Production-grade Node.js runtime and server standard. Enforces async event loop non-blocking hygiene, graceful shutdown, structured JSON logging with correlation IDs, and unhandled rejection guards.
12
+
13
+ ## When to Use
14
+
15
+ Activate when developing Node.js HTTP servers, Express/Fastify APIs, background workers, CLI tools, or stream-based data pipelines.
16
+
17
+ ## Negative Constraints (What NOT to Do)
18
+
19
+ 1. **NEVER execute synchronous filesystem/crypto calls in request handlers (`fs.readFileSync`)**: Always use async promises (`fs.promises.*`) to avoid blocking the event loop.
20
+ 2. **NEVER leave uncaught promise rejections**: Every async route must use `express-async-errors` or wrap operations in try/catch calling `next(err)`.
21
+ 3. **NEVER buffer large files/payloads entirely in memory (`fs.readFile`)**: Always use Streams or Pipelines (`stream.pipeline`) for processing large files.
22
+ 4. **NEVER store in-memory session or user state on a single process instance**: Use Redis or an external state store to allow multi-instance scaling.
23
+ 5. **NEVER ignore `SIGTERM` / `SIGINT` shutdown signals**: Always implement graceful shutdown to close open DB pools and drain active HTTP connections.
24
+
25
+ ## Rules & Patterns
26
+
27
+ ## Architecture
28
+
29
+ - **Layered architecture**: Routes → Controllers → Services → Repositories
30
+ - **Dependency injection** - don't import dependencies directly in services
31
+ - **Config from environment** - never hardcode secrets, use env variables
32
+ - **Graceful shutdown** - handle SIGTERM, close connections, drain requests
33
+
34
+ ## Error Handling
35
+
36
+ - **Never swallow errors** - always handle or re-throw
37
+ - **Custom error classes** - extend Error with HTTP status codes
38
+ - **Global error handler** - catch unhandled rejections and uncaught exceptions
39
+ - **Structured logging** - JSON logs with request ID, timestamp, level
40
+
41
+ ```typescript
42
+ class AppError extends Error {
43
+ constructor(
44
+ public message: string,
45
+ public statusCode: number = 500,
46
+ public code: string = 'INTERNAL_ERROR'
47
+ ) {
48
+ super(message);
49
+ this.name = 'AppError';
50
+ }
51
+ }
52
+ ```
53
+
54
+ ## API Design
55
+
56
+ - **RESTful conventions** - GET (read), POST (create), PUT (full update), PATCH (partial), DELETE
57
+ - **Consistent response format** - `{ data, error, pagination }`
58
+ - **Validation at the edge** - validate request body/params with Zod or Joi
59
+ - **Rate limiting** - protect against abuse
60
+ - **CORS** - configure explicitly, never use `*` in production
61
+
62
+ ## Security
63
+
64
+ - **Helmet.js** - security headers
65
+ - **Input validation** - never trust client input
66
+ - **SQL injection** - always use parameterized queries
67
+ - **XSS** - sanitize output, use Content-Security-Policy
68
+ - **Authentication** - JWT with short expiry + refresh tokens
69
+ - **Secrets** - environment variables, never in code
70
+
71
+ ## Database
72
+
73
+ - **Connection pooling** - don't create connections per request
74
+ - **Migrations** - version-controlled schema changes
75
+ - **Transactions** - for multi-step operations
76
+ - **Indexes** - add indexes for frequently queried columns
77
+
78
+ ## Performance
79
+
80
+ - **Async/await** - never block the event loop
81
+ - **Streaming** - for large files and data sets
82
+ - **Caching** - Redis for frequently accessed data
83
+ - **Clustering** - use PM2 or cluster module for multi-core
84
+
85
+ ## Testing
86
+
87
+ - **Unit tests** - services and utilities
88
+ - **Integration tests** - API endpoints with test database
89
+ - **Test isolation** - each test should be independent
90
+ - **Fixtures** - use factories, not shared state
91
+
92
+ ## File Structure
93
+
94
+ ```
95
+ src/
96
+ ├── config/ # Configuration
97
+ ├── modules/ # Feature modules
98
+ │ └── users/
99
+ │ ├── users.controller.ts
100
+ │ ├── users.service.ts
101
+ │ ├── users.repository.ts
102
+ │ ├── users.routes.ts
103
+ │ ├── users.types.ts
104
+ │ └── users.test.ts
105
+ ├── shared/ # Shared utilities
106
+ │ ├── middleware/
107
+ │ ├── errors/
108
+ │ └── utils/
109
+ ├── types/ # Global types
110
+ └── app.ts # App entry point
111
+ ```
112
+
113
+
114
+ ## Code Examples
115
+
116
+ See `EXAMPLES.md` for detailed code examples.
117
+
118
+ ## Validation Checklist
119
+
120
+ What to verify during the review phase before completing the task.
121
+
122
+ ## Common Mistakes
123
+
124
+ Anti-patterns and things to explicitly avoid. See `TROUBLESHOOTING.md`.
125
+
126
+ ## Integration Notes
127
+
128
+ How this skill interacts with other skills.
@@ -0,0 +1,19 @@
1
+ # node Troubleshooting & Common Mistakes
2
+
3
+ ## 1. Unhandled Promise Rejections Crashing the Process
4
+
5
+ - **Symptom**: Node process crashes abruptly without clear stack trace in production.
6
+ - **Root Cause**: Missing `process.on('unhandledRejection')` handler in Node.js >= 15.
7
+ - **Fix**: Always register top-level unhandledRejection and uncaughtException logging before exiting cleanly.
8
+
9
+ ## 2. Event Loop Starvation
10
+
11
+ - **Symptom**: API endpoints stop responding or latency spikes to 10+ seconds.
12
+ - **Root Cause**: Heavy synchronous operations (`JSON.parse` on a 50MB file, sync bcrypt hashing, or regex catastrophic backtracking).
13
+ - **Fix**: Offload CPU-heavy tasks to Worker Threads or use async worker queues.
14
+
15
+ ## 3. Memory Leaks in Event Emitters
16
+
17
+ - **Symptom**: "MaxListenersExceededWarning: Possible EventEmitter memory leak detected".
18
+ - **Root Cause**: Adding listeners inside request handlers without removing them on close.
19
+ - **Fix**: Remove listeners in cleanup callbacks or use `AbortController` signals.
@@ -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,14 @@
1
+ schemaVersion: 2
2
+ id: node
3
+ name: Node.js
4
+ category: backend
5
+ type: instruction-only
6
+ requires: [typescript]
7
+ optional: [postgres, redis, docker]
8
+ conflicts: []
9
+ weight: 7
10
+ resources:
11
+ - EXAMPLES.md
12
+ - SKILL.md
13
+ - TROUBLESHOOTING.md
14
+ - VALIDATION.json
@@ -0,0 +1,30 @@
1
+ # performance Examples - Anti-patterns vs ContextOS Standard
2
+
3
+ ## Example 1: Dynamic Imports for Heavy Libraries
4
+
5
+ ### Anti-pattern: Static Import of Heavy Visualizers in Initial Bundle
6
+
7
+ ```typescript
8
+ // BAD: Adds 800KB (Monaco editor or Three.js) to the critical first-paint bundle!
9
+ import { CodeEditor } from '@/components/CodeEditor';
10
+
11
+ export default function Page() {
12
+ return <div><CodeEditor /></div>;
13
+ }
14
+ ```
15
+
16
+ ### Best practice: ContextOS Standard (Lazy Load on Demand)
17
+
18
+ ```typescript
19
+ // GOOD: Dynamic import splits chunk, only downloads when component renders
20
+ import dynamic from 'next/dynamic';
21
+
22
+ const CodeEditor = dynamic(
23
+ () => import('@/components/CodeEditor'),
24
+ { loading: () => <EditorSkeleton />, ssr: false }
25
+ );
26
+
27
+ export default function Page() {
28
+ return <div><CodeEditor /></div>;
29
+ }
30
+ ```
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: Web Performance
3
+ description: >
4
+ ContextOS skill for Web Performance, Core Web Vitals, waterfall elimination, bundle size optimization, and caching strategies.
5
+ ---
6
+
7
+ # Web Performance & Core Web Vitals
8
+
9
+ ## Overview
10
+
11
+ Enforces high-efficiency frontend and full-stack performance standards to achieve exceptional Core Web Vitals: Largest Contentful Paint (LCP < 2.5s), Interaction to Next Paint (INP < 200ms), and Cumulative Layout Shift (CLS < 0.1).
12
+
13
+ ## When to Use
14
+
15
+ Activate whenever analyzing, profiling, writing, or optimizing page loading speeds, network waterfalls, script bundling, animation frame rates, or data caching.
16
+
17
+ ## Negative Constraints (What NOT to Do)
18
+
19
+ 1. **NEVER introduce async waterfalls**: Do not chain sequential `await` calls when requests can be executed concurrently via `Promise.all()`.
20
+ 2. **NEVER import large full libraries when only a utility is needed**: Never `import _ from 'lodash'`; use `import debounce from 'lodash/debounce'` or native alternatives.
21
+ 3. **NEVER render images or videos without explicit aspect ratios**: Always provide `width` and `height` or `aspect-ratio` to avoid Cumulative Layout Shift (CLS).
22
+ 4. **NEVER trigger synchronous layout thrashing**: Do not alternate between reading layout properties (`offsetHeight`, `getBoundingClientRect`) and writing styles in loops.
23
+ 5. **NEVER animate non-composited properties**: Animate only GPU-composited CSS properties (`transform`, `opacity`). Never animate `width`, `height`, `top`, `left`, or `margin`.
24
+
25
+ ## Rules & Patterns
26
+
27
+ ### 1. Vercel Optimization Hierarchy by Impact
28
+
29
+ | Priority | Category | Key Optimization Target | Expected Impact |
30
+ |:---|:---|:---|:---|
31
+ | **1. CRITICAL** | **Eliminating Waterfalls** | Parallel data fetching (`Promise.all`), Suspense streaming | **30-60% faster LCP** |
32
+ | **2. CRITICAL** | **Bundle Size Optimization** | Direct submodule imports, `next/dynamic`, deferring 3rd party scripts | **40-70% smaller initial JS** |
33
+ | **3. HIGH** | **Server-Side & RSC Caching** | `React.cache()` request deduplication, edge SSR caching | **Lower TTFB & DB load** |
34
+ | **4. MEDIUM-HIGH** | **Client Query Optimization** | SWR / TanStack Query stale-while-revalidate, deduplication | **Zero redundant network calls** |
35
+ | **5. MEDIUM** | **Render & DOM Optimization** | Virtualization for large lists, state colocation, `:focus-visible` | **Smooth 60 FPS / INP < 100ms** |
36
+
37
+ ### 2. Eliminating Network Waterfalls
38
+
39
+ ```ts
40
+ // [GOOD] Parallel execution
41
+ const [user, notifications] = await Promise.all([
42
+ fetchUser(),
43
+ fetchNotifications(),
44
+ ]);
45
+ const posts = await fetchPosts(user.id);
46
+ ```
47
+
48
+ ### 3. Layout Shift & Visual Stability (CLS < 0.1)
49
+
50
+ - **Images & Video**: Always supply `width`, `height`, and `sizes` or CSS `aspect-ratio: 16 / 9`.
51
+ - **Dynamic Content**: Reserve layout space for dynamically loaded widgets with min-height placeholders or skeletons.
52
+ - **Tabular Numbers**: Use `font-feature-settings: "tnum"` / `font-variant-numeric: tabular-nums` for counters, clocks, and tables to prevent number width jitter.
53
+
54
+ ## Code Examples
55
+
56
+ See `EXAMPLES.md` for detailed performance patterns and benchmark snippets.
57
+
58
+ ## Validation Checklist
59
+
60
+ - [ ] LCP target is < 2.5s with preloaded critical fonts and LCP image `priority`.
61
+ - [ ] No sequential `await` waterfalls in API routes or Server Components.
62
+ - [ ] All animated elements use only `transform` and `opacity`.
63
+ - [ ] `prefers-reduced-motion` media queries are respected.
64
+ - [ ] Large tables / lists (> 100 items) utilize virtualization.
65
+
66
+ ## Common Mistakes
67
+
68
+ - Chaining independent async requests instead of using `Promise.all`.
69
+ - Animating layout-triggering properties (`height`, `width`, `top`) causing jank.
70
+ - Missing image dimensions causing layout shift when images finish loading.
71
+
72
+ ## Integration Notes
73
+
74
+ - Pairs with `nextjs` and `react` for App Router caching and component lifecycle tuning.
75
+ - Pairs with `ui-ux-pro` for smooth animations and responsive design tokens.
@@ -0,0 +1,19 @@
1
+ # performance Troubleshooting & Common Mistakes
2
+
3
+ ## 1. Cumulative Layout Shift (CLS) from Images & Fonts
4
+
5
+ - **Symptom**: Page content jumps around as images and custom fonts load.
6
+ - **Root Cause**: Missing width and height attributes on image tags and FOUT (Flash of Unstyled Text).
7
+ - **Fix**: Always specify aspect-ratio or width/height on images, and use next/font to preload web fonts with fallback sizing.
8
+
9
+ ## 2. High Interaction to Next Paint (INP)
10
+
11
+ - **Symptom**: User clicks a button and the UI freezes for 200ms+ before responding.
12
+ - **Root Cause**: Long task blocking the main thread during event dispatch.
13
+ - **Fix**: Defer non-critical state updates using startTransition() or split heavy computation with Web Workers.
14
+
15
+ ## 3. Unoptimized SVG / Icon Overload
16
+
17
+ - **Symptom**: Huge DOM node count and slow initial render times.
18
+ - **Root Cause**: Rendering 500 inline SVG icons with complex paths.
19
+ - **Fix**: Use SVG sprite sheets, dynamic icon loaders, or lightweight canvas rendering for dense data visualizations.
@@ -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,14 @@
1
+ schemaVersion: 2
2
+ id: performance
3
+ name: Web Performance
4
+ category: frontend
5
+ type: instruction-only
6
+ requires: []
7
+ optional: [react, nextjs]
8
+ conflicts: []
9
+ weight: 6
10
+ resources:
11
+ - EXAMPLES.md
12
+ - SKILL.md
13
+ - TROUBLESHOOTING.md
14
+ - VALIDATION.json