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,355 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Application Security
|
|
3
|
+
description: >
|
|
4
|
+
ContextOS skill for Application Security
|
|
5
|
+
---
|
|
6
|
+
# security
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Enforces zero-trust defense-in-depth, OWASP API Top 10 mitigation, cryptographic hardening, sensitive data leakage protection, and AI/LLM safety across all services, endpoints, and agent integrations.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
Activate whenever writing authentication, authorization, session management, database queries, cryptography, external API integrations, user input handling, or agent tool calling.
|
|
15
|
+
|
|
16
|
+
## Rules & Patterns
|
|
17
|
+
|
|
18
|
+
### Negative Constraints (What NOT to Do)
|
|
19
|
+
|
|
20
|
+
1. **NEVER use standard string comparison (`===`) for secrets/hashes**: Always use `crypto.timingSafeEqual` to prevent timing attacks.
|
|
21
|
+
2. **NEVER store sensitive JWT access/refresh tokens in `localStorage`**: Store tokens in `httpOnly`, `Secure`, `SameSite=Strict` cookies.
|
|
22
|
+
3. **NEVER return raw database/internal error messages or stack traces to the client**: Return standardized generic error codes (`INTERNAL_SERVER_ERROR`) and log details internally.
|
|
23
|
+
4. **NEVER trust client-provided IDs for authorization without tenant/ownership checks**: Always verify `where: { id, userId: session.userId }` to prevent Broken Object Level Authorization (BOLA/IDOR).
|
|
24
|
+
5. **NEVER disable CSRF protection, CORS allow-all (`*`), or TLS verification (`NODE_TLS_REJECT_UNAUTHORIZED=0`) in production**: Always enforce strict origin whitelists and HTTPS.
|
|
25
|
+
6. **NEVER pass un-sanitized third-party content directly into system prompts or shell execution**: Treat all external data as potentially adversarial.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### OWASP Top 10 for Modern APIs & Full-Stack
|
|
30
|
+
|
|
31
|
+
#### 1. Injection (SQL, NoSQL, Command)
|
|
32
|
+
|
|
33
|
+
- Always use parameterized queries — never concatenate user input into SQL or shell commands.
|
|
34
|
+
- Use ORMs (Prisma, Drizzle, SQLAlchemy) with strict schema validation.
|
|
35
|
+
- Validate and sanitize all user input before processing.
|
|
36
|
+
|
|
37
|
+
#### 2. Broken Object Level Authorization (BOLA / IDOR)
|
|
38
|
+
|
|
39
|
+
- Validate user ownership on EVERY database read, update, or delete:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// [GOOD] Scoped to authenticated user
|
|
43
|
+
const doc = await db.document.findFirst({
|
|
44
|
+
where: { id: documentId, tenantId: session.tenantId }
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### 3. Broken Authentication & Session Management
|
|
49
|
+
|
|
50
|
+
- Use Argon2id or bcrypt (cost factor ≥ 12) for password hashing.
|
|
51
|
+
- Short-lived access tokens (15 min) + secure HTTP-only refresh tokens.
|
|
52
|
+
- Enforce rate limiting and brute-force lockouts on auth endpoints.
|
|
53
|
+
|
|
54
|
+
#### 4. SSRF (Server-Side Request Forgery)
|
|
55
|
+
|
|
56
|
+
- Restrict server-side URL fetching: validate URL scheme (`https:` only), resolve IP, and block private CIDR blocks (`10.0.0.0/8`, `127.0.0.0/8`, `169.254.0.0/16`, `192.168.0.0/16`).
|
|
57
|
+
|
|
58
|
+
#### 5. Security Misconfiguration & Headers
|
|
59
|
+
|
|
60
|
+
Enforce modern production security headers:
|
|
61
|
+
|
|
62
|
+
```http
|
|
63
|
+
Content-Security-Policy: default-src 'self'
|
|
64
|
+
X-Content-Type-Options: nosniff
|
|
65
|
+
X-Frame-Options: DENY
|
|
66
|
+
Strict-Transport-Security: max-age=31536000; includeSubDomains
|
|
67
|
+
Referrer-Policy: strict-origin-when-cross-origin
|
|
68
|
+
Permissions-Policy: camera=(), microphone=(), geolocation=()
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
### AI Agent & LLM Security Invariants
|
|
74
|
+
|
|
75
|
+
When building AI workflows, tools, or MCP servers:
|
|
76
|
+
|
|
77
|
+
1. **Prompt Injection Defense**:
|
|
78
|
+
- Clearly delineate untrusted user/web content using boundary markers (e.g. `<untrusted_content>` tags).
|
|
79
|
+
- Never allow untrusted content to override system instructions or tool execution permissions.
|
|
80
|
+
2. **Tool Execution Boundaries**:
|
|
81
|
+
- Destructive operations (database drops, file deletions, payment triggers) MUST require explicit user confirmation.
|
|
82
|
+
- Restrict file system tools to the workspace root — block directory traversal (`../`).
|
|
83
|
+
3. **Secret Masking & Output Sanitization**:
|
|
84
|
+
- Scrub API keys (`sk-...`, `Bearer ...`), tokens, and credentials before writing to agent logs or step summaries.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Code Examples
|
|
89
|
+
|
|
90
|
+
### Timing-Safe Secret Verification
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
import crypto from 'node:crypto';
|
|
94
|
+
|
|
95
|
+
export function verifyWebhookSignature(payload, signature, secret) {
|
|
96
|
+
const hmac = crypto.createHmac('sha256', secret);
|
|
97
|
+
const digest = Buffer.from(hmac.update(payload).digest('hex'), 'utf8');
|
|
98
|
+
const sigBuffer = Buffer.from(signature, 'utf8');
|
|
99
|
+
|
|
100
|
+
if (digest.length !== sigBuffer.length) return false;
|
|
101
|
+
return crypto.timingSafeEqual(digest, sigBuffer);
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Safe SSRF Prevention Wrapper
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import dns from 'node:dns/promises';
|
|
109
|
+
|
|
110
|
+
export async function validateSafeUrl(urlString: string): Promise<URL> {
|
|
111
|
+
const parsed = new URL(urlString);
|
|
112
|
+
if (parsed.protocol !== 'https:') {
|
|
113
|
+
throw new Error('Only HTTPS protocol is permitted');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const { address } = await dns.lookup(parsed.hostname);
|
|
117
|
+
if (
|
|
118
|
+
address.startsWith('127.') ||
|
|
119
|
+
address.startsWith('10.') ||
|
|
120
|
+
address.startsWith('192.168.') ||
|
|
121
|
+
address === '169.254.169.254'
|
|
122
|
+
) {
|
|
123
|
+
throw new Error('Access to private/metadata IP addresses is blocked');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return parsed;
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Validation Checklist
|
|
133
|
+
|
|
134
|
+
- [ ] All database queries parameterized or managed by type-safe ORM.
|
|
135
|
+
- [ ] BOLA/IDOR prevented: all entity queries scoped by tenant/user id.
|
|
136
|
+
- [ ] Cookies set with `HttpOnly`, `Secure`, and `SameSite=Strict` or `Lax`.
|
|
137
|
+
- [ ] Passwords hashed with Argon2id / bcrypt.
|
|
138
|
+
- [ ] Security headers active in middleware/reverse proxy.
|
|
139
|
+
- [ ] No secrets or tokens checked into source control or exposed in logs.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Common Mistakes
|
|
144
|
+
|
|
145
|
+
- **Trusting client-side claims**: Checking role or permissions only on the frontend without server-side validation.
|
|
146
|
+
- **Timing attacks on tokens**: Comparing tokens with `token === expectedToken` instead of `timingSafeEqual`.
|
|
147
|
+
- **Exposing internal stack traces**: Returning full error objects to client in production.
|
|
148
|
+
- **Unvalidated redirects / URLs**: Allowing arbitrary URLs in redirect or fetch parameters.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Integration Notes
|
|
153
|
+
|
|
154
|
+
- Runs in the REVIEW phase for every backend route, auth flow, and database mutation.
|
|
155
|
+
- Integrates with `engineering-workflow` during Phase 5 (5-axis quality gate).
|
|
156
|
+
- Pairs with `system-design` to mandate secure network boundaries and authorization layers.
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
<!-- Source: security.md -->
|
|
160
|
+
|
|
161
|
+
# Application Security — Best Practices
|
|
162
|
+
|
|
163
|
+
## OWASP Top 10
|
|
164
|
+
|
|
165
|
+
### 1. Injection (SQL, NoSQL, Command)
|
|
166
|
+
|
|
167
|
+
- **Always use parameterized queries** — never concatenate user input into SQL
|
|
168
|
+
- Use ORM (Prisma, SQLAlchemy, TypeORM) — they parameterize by default
|
|
169
|
+
- Validate and sanitize all user input
|
|
170
|
+
|
|
171
|
+
### 2. Broken Authentication
|
|
172
|
+
|
|
173
|
+
- Use bcrypt/argon2 for password hashing (cost factor ≥ 12)
|
|
174
|
+
- JWT: short-lived access tokens (15min), refresh tokens (7 days)
|
|
175
|
+
- Rate limit login attempts
|
|
176
|
+
- Implement account lockout after N failed attempts
|
|
177
|
+
- MFA for sensitive operations
|
|
178
|
+
|
|
179
|
+
### 3. Sensitive Data Exposure
|
|
180
|
+
|
|
181
|
+
- HTTPS everywhere — redirect HTTP to HTTPS
|
|
182
|
+
- Encrypt sensitive data at rest (AES-256)
|
|
183
|
+
- Never log passwords, tokens, or PII
|
|
184
|
+
- Use environment variables for secrets
|
|
185
|
+
|
|
186
|
+
### 4. XML/XXE
|
|
187
|
+
|
|
188
|
+
- Disable external entity processing
|
|
189
|
+
- Use JSON instead of XML where possible
|
|
190
|
+
|
|
191
|
+
### 5. Broken Access Control
|
|
192
|
+
|
|
193
|
+
- Default deny — explicitly grant access
|
|
194
|
+
- RBAC (Role-Based Access Control) or ABAC (Attribute-Based)
|
|
195
|
+
- Check authorization on every request, not just UI
|
|
196
|
+
- Don't rely on client-side validation for security
|
|
197
|
+
|
|
198
|
+
### 6. Security Misconfiguration
|
|
199
|
+
|
|
200
|
+
- Remove default credentials
|
|
201
|
+
- Disable debug mode in production
|
|
202
|
+
- Security headers (see below)
|
|
203
|
+
- Keep dependencies updated
|
|
204
|
+
|
|
205
|
+
### 7. XSS (Cross-Site Scripting)
|
|
206
|
+
|
|
207
|
+
- Escape all output by default
|
|
208
|
+
- Content-Security-Policy header
|
|
209
|
+
- HttpOnly + Secure + SameSite cookies
|
|
210
|
+
- Use framework's built-in XSS protection
|
|
211
|
+
|
|
212
|
+
### 8. Insecure Deserialization
|
|
213
|
+
|
|
214
|
+
- Validate and schema-check all input (Zod, Pydantic, class-validator)
|
|
215
|
+
- Don't deserialize untrusted data
|
|
216
|
+
|
|
217
|
+
### 9. Insufficient Logging
|
|
218
|
+
|
|
219
|
+
- Log all authentication events
|
|
220
|
+
- Log authorization failures
|
|
221
|
+
- Log input validation failures
|
|
222
|
+
- Include request ID for tracing
|
|
223
|
+
|
|
224
|
+
### 10. SSRF (Server-Side Request Forgery)
|
|
225
|
+
|
|
226
|
+
- Validate and allowlist URLs
|
|
227
|
+
- Don't let users control server-side HTTP requests
|
|
228
|
+
|
|
229
|
+
## Security Headers
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
Content-Security-Policy: default-src 'self'
|
|
233
|
+
X-Content-Type-Options: nosniff
|
|
234
|
+
X-Frame-Options: DENY
|
|
235
|
+
Strict-Transport-Security: max-age=31536000; includeSubDomains
|
|
236
|
+
Referrer-Policy: strict-origin-when-cross-origin
|
|
237
|
+
Permissions-Policy: camera=(), microphone=(), geolocation=()
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Authentication Patterns
|
|
241
|
+
|
|
242
|
+
### JWT Flow
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
Login → Access Token (15min) + Refresh Token (7d, HttpOnly cookie)
|
|
246
|
+
Request → Authorization: Bearer <access_token>
|
|
247
|
+
Expired → POST /auth/refresh (sends refresh cookie) → new access token
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### OAuth2 Flow
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
Redirect → Provider (Google, GitHub) → Callback → Create/link user → JWT
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Checklist Before Deploy
|
|
257
|
+
|
|
258
|
+
- [ ] All secrets in environment variables
|
|
259
|
+
- [ ] HTTPS enabled
|
|
260
|
+
- [ ] Security headers configured
|
|
261
|
+
- [ ] Input validation on all endpoints
|
|
262
|
+
- [ ] Rate limiting enabled
|
|
263
|
+
- [ ] CORS configured (not `*`)
|
|
264
|
+
- [ ] Error messages don't leak internals
|
|
265
|
+
- [ ] Dependency audit (`npm audit`, `pip audit`)
|
|
266
|
+
- [ ] Logging for security events
|
|
267
|
+
|
|
268
|
+
<!-- Source: EXAMPLES.md -->
|
|
269
|
+
|
|
270
|
+
# Application Security Examples — Anti-patterns vs ContextOS Standard
|
|
271
|
+
|
|
272
|
+
## Example 1: Timing-Safe Secret Verification
|
|
273
|
+
|
|
274
|
+
### Anti-pattern: Anti-pattern (Vulnerable to side-channel timing attack)
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
// BAD: string comparison returns early on the first mismatched byte
|
|
278
|
+
export function verifyApiKey(providedKey: string, storedKey: string): boolean {
|
|
279
|
+
return providedKey === storedKey; // Vulnerable to timing analysis!
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Best practice: ContextOS Standard (Constant-time buffer comparison)
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
// GOOD: crypto.timingSafeEqual executes in constant time
|
|
287
|
+
import crypto from 'crypto';
|
|
288
|
+
|
|
289
|
+
export function verifyApiKey(providedKey: string, storedKey: string): boolean {
|
|
290
|
+
const providedBuffer = Buffer.from(providedKey, 'utf8');
|
|
291
|
+
const storedBuffer = Buffer.from(storedKey, 'utf8');
|
|
292
|
+
|
|
293
|
+
if (providedBuffer.length !== storedBuffer.length) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return crypto.timingSafeEqual(providedBuffer, storedBuffer);
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Example 2: Preventing IDOR (Insecure Direct Object Reference)
|
|
304
|
+
|
|
305
|
+
### Anti-pattern: Anti-pattern (Trusting client ID without ownership check)
|
|
306
|
+
|
|
307
|
+
```typescript
|
|
308
|
+
// BAD: any authenticated user can delete any other user's document!
|
|
309
|
+
app.delete('/api/documents/:id', requireAuth, async (req, res) => {
|
|
310
|
+
await prisma.document.delete({ where: { id: req.params.id } });
|
|
311
|
+
res.status(204).end();
|
|
312
|
+
});
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Best practice: ContextOS Standard (Multi-tenant scoped authorization check)
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
// GOOD: document deletion is strictly scoped to authenticated user or org
|
|
319
|
+
app.delete('/api/documents/:id', requireAuth, async (req, res) => {
|
|
320
|
+
const deleted = await prisma.document.deleteMany({
|
|
321
|
+
where: {
|
|
322
|
+
id: req.params.id,
|
|
323
|
+
organizationId: req.user.organizationId, // Tenant isolation
|
|
324
|
+
},
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
if (deleted.count === 0) {
|
|
328
|
+
return res.status(404).json({ error: 'Document not found or access denied' });
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return res.status(204).end();
|
|
332
|
+
});
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
<!-- Source: TROUBLESHOOTING.md -->
|
|
336
|
+
|
|
337
|
+
# security Troubleshooting & Common Mistakes
|
|
338
|
+
|
|
339
|
+
## 1. Insecure Direct Object References (IDOR)
|
|
340
|
+
|
|
341
|
+
- **Symptom**: User A can access User B's invoices by simply modifying the ID in the URL.
|
|
342
|
+
- **Root Cause**: Querying by record ID without scoping to the authenticated `user.id` or tenant ID.
|
|
343
|
+
- **Fix**: Always query with ownership predicate: `db.invoice.findFirst({ where: { id, userId: auth.user.id } })`.
|
|
344
|
+
|
|
345
|
+
## 2. SQL Injection via Raw String Concatenation
|
|
346
|
+
|
|
347
|
+
- **Symptom**: Database compromised through input fields.
|
|
348
|
+
- **Root Cause**: String templating in raw queries (`db.query("SELECT * FROM users WHERE id = " + id)`).
|
|
349
|
+
- **Fix**: Always use parameterized queries (`$1, $2`) or ORM/query-builder methods.
|
|
350
|
+
|
|
351
|
+
## 3. Storing Sensitive Secrets in Git or Client Bundles
|
|
352
|
+
|
|
353
|
+
- **Symptom**: API keys or JWT signing secrets exposed publicly.
|
|
354
|
+
- **Root Cause**: Hardcoding secrets in source files or prefixing server secrets with NEXT_PUBLIC_.
|
|
355
|
+
- **Fix**: Store all secrets in server-only environment variables; add git-secrets to pre-commit hooks.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: soft-design
|
|
3
|
+
description: >
|
|
4
|
+
High-end agency-grade UI architecture, haptic micro-aesthetics, and fluid spring motion choreography.
|
|
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.
|
|
109
|
+
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: state-management
|
|
3
|
+
description: >
|
|
4
|
+
Client and server state management standards using Zustand and TanStack Query. Enforces minimal global state, optimistic updates, and clean query invalidation.
|
|
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`.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
<!-- Source: EXAMPLES.md -->
|
|
52
|
+
|
|
53
|
+
# State Management Examples — Anti-patterns vs ContextOS Standard
|
|
54
|
+
|
|
55
|
+
## Example 1: Selecting State from Zustand
|
|
56
|
+
|
|
57
|
+
### Anti-pattern: Anti-pattern (Subscribing to full store causes unnecessary renders)
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
// BAD: component re-renders whenever ANY property in the store changes!
|
|
61
|
+
function CartBadge() {
|
|
62
|
+
const store = useCartStore(); // subscribes to entire object!
|
|
63
|
+
return <span>{store.items.length}</span>;
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Best practice: ContextOS Standard (Atomic granular selector)
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
// GOOD: component ONLY re-renders when itemCount changes
|
|
71
|
+
function CartBadge() {
|
|
72
|
+
const itemCount = useCartStore((state) => state.items.length);
|
|
73
|
+
return <span>{itemCount}</span>;
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Example 2: Server State Invalidation
|
|
80
|
+
|
|
81
|
+
### Anti-pattern: Anti-pattern (Manually syncing server data into global state with useEffect)
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// BAD: manual sync, race conditions, stale cache bugs
|
|
85
|
+
function UserProfile({ userId }) {
|
|
86
|
+
const { setUser } = useUserStore();
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
fetch(`/api/users/${userId}`).then(res => res.json()).then(setUser);
|
|
89
|
+
}, [userId]);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Best practice: ContextOS Standard (Declarative TanStack Query caching)
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
// GOOD: automatic caching, deduplication, background revalidation
|
|
97
|
+
function UserProfile({ userId }: { userId: string }) {
|
|
98
|
+
const { data: user, isLoading, error } = useQuery({
|
|
99
|
+
queryKey: ['users', userId],
|
|
100
|
+
queryFn: () => fetchUserById(userId),
|
|
101
|
+
staleTime: 1000 * 60 * 5, // 5 minutes fresh
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
if (isLoading) return <SkeletonLoader />;
|
|
105
|
+
if (error) return <ErrorMessage error={error} />;
|
|
106
|
+
return <UserDetails user={user} />;
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
<!-- Source: TROUBLESHOOTING.md -->
|
|
111
|
+
|
|
112
|
+
# State Management Troubleshooting Guide
|
|
113
|
+
|
|
114
|
+
## Common Issues & Fixes
|
|
115
|
+
|
|
116
|
+
### 1. Infinite re-renders when calling `useStore` with an inline object selector
|
|
117
|
+
|
|
118
|
+
- **Cause**: Returning a new object reference from a selector without a custom equality check.
|
|
119
|
+
- **Fix**: Use `useShallow` from `zustand/react/shallow` or select scalar values directly.
|
|
120
|
+
|
|
121
|
+
### 2. Stale data shown after mutation
|
|
122
|
+
|
|
123
|
+
- **Cause**: Missing `queryClient.invalidateQueries` in `onSettled` or `onSuccess`.
|
|
124
|
+
- **Fix**: Always invalidate the relevant query keys on mutation completion to trigger background refetch.
|
|
125
|
+
|
|
126
|
+
### 3. Server-Side Rendering (SSR) Hydration Mismatch in Next.js
|
|
127
|
+
|
|
128
|
+
- **Cause**: Reading localStorage-persisted Zustand store directly during initial SSR render.
|
|
129
|
+
- **Fix**: Use a custom `useHydratedStore` hook or render persisted components only after client mount.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: subagent-orchestrator
|
|
3
|
+
description: >
|
|
4
|
+
Subagent delegation and parallel coordination skill. Implements task decomposition, context hand-offs, blast-radius boundary isolation, and conflict-free merge synthesis.
|
|
5
|
+
---
|
|
6
|
+
# subagent-orchestrator
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
Activate whenever:
|
|
15
|
+
|
|
16
|
+
- A task can be parallelized across distinct modules, services, or test suites.
|
|
17
|
+
- Long-running exploratory research or multi-file refactoring exceeds single-context budget.
|
|
18
|
+
- Running autonomous subagent workers for specialized roles (e.g. specialized QA tester, Security auditor, Docs generator).
|
|
19
|
+
|
|
20
|
+
## Rules & Patterns
|
|
21
|
+
|
|
22
|
+
### 1. The Blast Radius Boundary Rule
|
|
23
|
+
|
|
24
|
+
Before delegating any subagent task:
|
|
25
|
+
|
|
26
|
+
- **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.
|
|
27
|
+
- **Explicit Inputs & Outputs**: Provide only the minimal schema, contract, or mock that the subagent needs. Do not dump the entire workspace into subagent prompts.
|
|
28
|
+
|
|
29
|
+
### 2. The 4-Step Delegation Lifecycle
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
[ Orchestrator ]
|
|
33
|
+
│
|
|
34
|
+
├─▶ 1. DECOMPOSE: Break into orthogonal tasks with non-overlapping file sets
|
|
35
|
+
│
|
|
36
|
+
├─▶ 2. DISPATCH: Launch subagent with precise goal, constraints, and finish criteria
|
|
37
|
+
│
|
|
38
|
+
├─▶ 3. AWAIT & VERIFY: Validate subagent output against its individual quality gate
|
|
39
|
+
│
|
|
40
|
+
└─▶ 4. SYNTHESIZE: Merge subagent results into the main branch and run global regression suite
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 3. Context Hand-off Specification
|
|
44
|
+
|
|
45
|
+
Every subagent dispatch prompt must contain:
|
|
46
|
+
|
|
47
|
+
1. **Target Objective**: Single, verifiable deliverable.
|
|
48
|
+
2. **Read-Only Context**: Files to consult as reference without modifying.
|
|
49
|
+
3. **Write Scope**: Exact file paths the subagent is permitted to create or modify.
|
|
50
|
+
4. **Completion Signal**: Explicit instruction to report `DONE` with test evidence or `BLOCKED` with reason.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Code Examples
|
|
55
|
+
|
|
56
|
+
### Orchestrator Task Dispatch Template
|
|
57
|
+
|
|
58
|
+
```markdown
|
|
59
|
+
**Subagent Task: Order Validation Service**
|
|
60
|
+
|
|
61
|
+
- **Role**: `[ROLE: Senior Developer]`
|
|
62
|
+
- **Goal**: Implement Zod validation schema and unit tests for order payloads.
|
|
63
|
+
- **Write Scope**:
|
|
64
|
+
- `src/services/order/validation.ts`
|
|
65
|
+
- `tests/services/order/validation.test.ts`
|
|
66
|
+
- **Read-Only Reference**:
|
|
67
|
+
- `src/types/order.ts`
|
|
68
|
+
- **Quality Gate**:
|
|
69
|
+
- Run `npx vitest run tests/services/order/validation.test.ts`
|
|
70
|
+
- All tests must pass with 100% coverage of validation rules.
|
|
71
|
+
- **Finish Criteria**:
|
|
72
|
+
- Report exact test output and finish with `DONE`.
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Validation Checklist
|
|
78
|
+
|
|
79
|
+
- [ ] All delegated tasks have disjoint, non-overlapping file sets.
|
|
80
|
+
- [ ] Every subagent prompt has explicit read vs write boundaries.
|
|
81
|
+
- [ ] Subagent results verified individually before merging.
|
|
82
|
+
- [ ] Global regression suite executed across the entire repository after all subagents finish.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Common Mistakes
|
|
87
|
+
|
|
88
|
+
- **Concurrent file collisions**: Assigning two subagents to modify the same route handler or lockfile.
|
|
89
|
+
- **Unbounded delegation**: Asking a subagent to "improve the codebase" without specific file limits.
|
|
90
|
+
- **Trusting without verification**: Assuming subagent code works without executing the test gate in the parent context.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Integration Notes
|
|
95
|
+
|
|
96
|
+
- Integrates with `engineering-workflow` during the PLAN and BUILD phases.
|
|
97
|
+
- Works directly with `gstack-roles` to assign specific specialist personas to each subagent.
|
|
98
|
+
- Employs `ponytail-mindset` to keep subagent implementations minimal.
|
|
99
|
+
|