@kinqs/brainrouter-mcp-server 0.3.4
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/.env.example +144 -0
- package/README.md +56 -0
- package/agents/README.md +120 -0
- package/agents/code-reviewer.md +97 -0
- package/agents/security-auditor.md +101 -0
- package/agents/test-engineer.md +95 -0
- package/dist/__tests__/agent_mode.test.d.ts +1 -0
- package/dist/__tests__/api-routes.test.d.ts +1 -0
- package/dist/__tests__/api-routes.test.js +170 -0
- package/dist/__tests__/crypto.test.d.ts +1 -0
- package/dist/__tests__/crypto.test.js +28 -0
- package/dist/__tests__/host-integrations.test.d.ts +1 -0
- package/dist/__tests__/host-integrations.test.js +82 -0
- package/dist/__tests__/integration.test.d.ts +1 -0
- package/dist/__tests__/integration.test.js +50 -0
- package/dist/__tests__/loader.test.d.ts +1 -0
- package/dist/__tests__/loader.test.js +89 -0
- package/dist/__tests__/neural-spark.test.d.ts +1 -0
- package/dist/__tests__/neural-spark.test.js +112 -0
- package/dist/__tests__/pagination.test.d.ts +1 -0
- package/dist/__tests__/pagination.test.js +23 -0
- package/dist/__tests__/redaction.test.d.ts +1 -0
- package/dist/__tests__/redaction.test.js +17 -0
- package/dist/__tests__/registry.test.d.ts +1 -0
- package/dist/__tests__/registry.test.js +56 -0
- package/dist/__tests__/retry.test.d.ts +1 -0
- package/dist/__tests__/retry.test.js +30 -0
- package/dist/__tests__/skill-activation.test.d.ts +1 -0
- package/dist/__tests__/skill-activation.test.js +112 -0
- package/dist/__tests__/working-memory.test.d.ts +1 -0
- package/dist/__tests__/working-memory.test.js +200 -0
- package/dist/__tests__/workspace-paths.test.d.ts +1 -0
- package/dist/__tests__/workspace-paths.test.js +56 -0
- package/dist/__tests__/writer.test.d.ts +1 -0
- package/dist/__tests__/writer.test.js +94 -0
- package/dist/api/auth/crypto.d.ts +4 -0
- package/dist/api/auth/crypto.js +54 -0
- package/dist/api/middleware/auth.d.ts +12 -0
- package/dist/api/middleware/auth.js +90 -0
- package/dist/api/pagination.d.ts +18 -0
- package/dist/api/pagination.js +32 -0
- package/dist/api/routes/auth.d.ts +1 -0
- package/dist/api/routes/auth.js +130 -0
- package/dist/api/routes/chat-completions.d.ts +7 -0
- package/dist/api/routes/chat-completions.js +474 -0
- package/dist/api/routes/contradictions.d.ts +1 -0
- package/dist/api/routes/contradictions.js +28 -0
- package/dist/api/routes/evidence.d.ts +1 -0
- package/dist/api/routes/evidence.js +59 -0
- package/dist/api/routes/governance.d.ts +1 -0
- package/dist/api/routes/governance.js +95 -0
- package/dist/api/routes/graph.d.ts +1 -0
- package/dist/api/routes/graph.js +25 -0
- package/dist/api/routes/hooks.d.ts +1 -0
- package/dist/api/routes/hooks.js +88 -0
- package/dist/api/routes/memories.d.ts +1 -0
- package/dist/api/routes/memories.js +92 -0
- package/dist/api/routes/persona.d.ts +1 -0
- package/dist/api/routes/persona.js +9 -0
- package/dist/api/routes/scenes.d.ts +1 -0
- package/dist/api/routes/scenes.js +35 -0
- package/dist/api/routes/skills.d.ts +1 -0
- package/dist/api/routes/skills.js +14 -0
- package/dist/api/routes/stats.d.ts +1 -0
- package/dist/api/routes/stats.js +8 -0
- package/dist/api/routes/users.d.ts +1 -0
- package/dist/api/routes/users.js +82 -0
- package/dist/api/routes/working.d.ts +1 -0
- package/dist/api/routes/working.js +88 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +492 -0
- package/dist/integrations/claude-code.d.ts +12 -0
- package/dist/integrations/claude-code.js +35 -0
- package/dist/integrations/codex.d.ts +12 -0
- package/dist/integrations/codex.js +34 -0
- package/dist/integrations/generic-mcp.d.ts +52 -0
- package/dist/integrations/generic-mcp.js +118 -0
- package/dist/loader.d.ts +29 -0
- package/dist/loader.js +200 -0
- package/dist/memory/capture.d.ts +35 -0
- package/dist/memory/capture.js +230 -0
- package/dist/memory/config.d.ts +2 -0
- package/dist/memory/config.js +3 -0
- package/dist/memory/engine.d.ts +203 -0
- package/dist/memory/engine.js +626 -0
- package/dist/memory/llm-semaphore.d.ts +41 -0
- package/dist/memory/llm-semaphore.js +81 -0
- package/dist/memory/memory-type-config.d.ts +11 -0
- package/dist/memory/memory-type-config.js +65 -0
- package/dist/memory/pipeline/cognitive-contradiction.d.ts +7 -0
- package/dist/memory/pipeline/cognitive-contradiction.js +59 -0
- package/dist/memory/pipeline/cognitive-dedup.d.ts +23 -0
- package/dist/memory/pipeline/cognitive-dedup.js +38 -0
- package/dist/memory/pipeline/cognitive-extractor.d.ts +21 -0
- package/dist/memory/pipeline/cognitive-extractor.js +183 -0
- package/dist/memory/pipeline/contextual-focus-builder.d.ts +13 -0
- package/dist/memory/pipeline/contextual-focus-builder.js +135 -0
- package/dist/memory/pipeline/focus-direction-shift.d.ts +10 -0
- package/dist/memory/pipeline/focus-direction-shift.js +27 -0
- package/dist/memory/pipeline/graph-builder.d.ts +11 -0
- package/dist/memory/pipeline/graph-builder.js +88 -0
- package/dist/memory/pipeline/graph-recall.d.ts +13 -0
- package/dist/memory/pipeline/graph-recall.js +55 -0
- package/dist/memory/pipeline/identity-distiller.d.ts +15 -0
- package/dist/memory/pipeline/identity-distiller.js +40 -0
- package/dist/memory/pipeline/l1-contradiction.d.ts +7 -0
- package/dist/memory/pipeline/l1-contradiction.js +66 -0
- package/dist/memory/pipeline/l1-dedup.d.ts +23 -0
- package/dist/memory/pipeline/l1-dedup.js +39 -0
- package/dist/memory/pipeline/l1-extractor.d.ts +21 -0
- package/dist/memory/pipeline/l1-extractor.js +180 -0
- package/dist/memory/pipeline/l2-direction-shift.d.ts +10 -0
- package/dist/memory/pipeline/l2-direction-shift.js +27 -0
- package/dist/memory/pipeline/l2-scene.d.ts +15 -0
- package/dist/memory/pipeline/l2-scene.js +140 -0
- package/dist/memory/pipeline/l3-distiller.d.ts +15 -0
- package/dist/memory/pipeline/l3-distiller.js +40 -0
- package/dist/memory/pipeline/neural-spark.d.ts +27 -0
- package/dist/memory/pipeline/neural-spark.js +78 -0
- package/dist/memory/pipeline/skill-prewarm.d.ts +63 -0
- package/dist/memory/pipeline/skill-prewarm.js +127 -0
- package/dist/memory/pipeline/task-queue.d.ts +54 -0
- package/dist/memory/pipeline/task-queue.js +117 -0
- package/dist/memory/prompts/cognitive-contradiction.d.ts +1 -0
- package/dist/memory/prompts/cognitive-contradiction.js +25 -0
- package/dist/memory/prompts/cognitive-extraction.d.ts +10 -0
- package/dist/memory/prompts/cognitive-extraction.js +114 -0
- package/dist/memory/prompts/core-identity.d.ts +6 -0
- package/dist/memory/prompts/core-identity.js +60 -0
- package/dist/memory/prompts/focus-direction-shift.d.ts +5 -0
- package/dist/memory/prompts/focus-direction-shift.js +32 -0
- package/dist/memory/prompts/focus-scene-cluster.d.ts +2 -0
- package/dist/memory/prompts/focus-scene-cluster.js +33 -0
- package/dist/memory/prompts/focus-scene.d.ts +7 -0
- package/dist/memory/prompts/focus-scene.js +40 -0
- package/dist/memory/prompts/graph-extraction-batch.d.ts +14 -0
- package/dist/memory/prompts/graph-extraction-batch.js +54 -0
- package/dist/memory/prompts/graph-extraction.d.ts +2 -0
- package/dist/memory/prompts/graph-extraction.js +53 -0
- package/dist/memory/prompts/l1-contradiction-batch.d.ts +16 -0
- package/dist/memory/prompts/l1-contradiction-batch.js +47 -0
- package/dist/memory/prompts/l1-contradiction.d.ts +1 -0
- package/dist/memory/prompts/l1-contradiction.js +25 -0
- package/dist/memory/prompts/l1-extraction.d.ts +10 -0
- package/dist/memory/prompts/l1-extraction.js +114 -0
- package/dist/memory/prompts/l2-direction-shift.d.ts +5 -0
- package/dist/memory/prompts/l2-direction-shift.js +32 -0
- package/dist/memory/prompts/l2-scene-cluster.d.ts +2 -0
- package/dist/memory/prompts/l2-scene-cluster.js +33 -0
- package/dist/memory/prompts/l2-scene.d.ts +7 -0
- package/dist/memory/prompts/l2-scene.js +40 -0
- package/dist/memory/prompts/l3-persona.d.ts +6 -0
- package/dist/memory/prompts/l3-persona.js +60 -0
- package/dist/memory/recall.d.ts +47 -0
- package/dist/memory/recall.js +427 -0
- package/dist/memory/redaction.d.ts +1 -0
- package/dist/memory/redaction.js +24 -0
- package/dist/memory/retry.d.ts +13 -0
- package/dist/memory/retry.js +53 -0
- package/dist/memory/scheduler.d.ts +9 -0
- package/dist/memory/scheduler.js +16 -0
- package/dist/memory/skill-hints-loader.d.ts +30 -0
- package/dist/memory/skill-hints-loader.js +100 -0
- package/dist/memory/store/embedding.d.ts +16 -0
- package/dist/memory/store/embedding.js +68 -0
- package/dist/memory/store/reranker.d.ts +24 -0
- package/dist/memory/store/reranker.js +83 -0
- package/dist/memory/store/sqlite.d.ts +167 -0
- package/dist/memory/store/sqlite.js +1816 -0
- package/dist/memory/store/types.d.ts +101 -0
- package/dist/memory/store/types.js +1 -0
- package/dist/memory/types.d.ts +207 -0
- package/dist/memory/types.js +7 -0
- package/dist/memory/validation.d.ts +441 -0
- package/dist/memory/validation.js +129 -0
- package/dist/memory/working/canvas.d.ts +5 -0
- package/dist/memory/working/canvas.js +43 -0
- package/dist/memory/working/offload.d.ts +71 -0
- package/dist/memory/working/offload.js +211 -0
- package/dist/memory/working/step-log.d.ts +16 -0
- package/dist/memory/working/step-log.js +35 -0
- package/dist/registry.d.ts +34 -0
- package/dist/registry.js +305 -0
- package/dist/resolver.d.ts +17 -0
- package/dist/resolver.js +126 -0
- package/dist/scripts/validate-foreign-workspace-path.d.ts +1 -0
- package/dist/scripts/validate-foreign-workspace-path.js +39 -0
- package/dist/tools/agent_memory_tools.d.ts +485 -0
- package/dist/tools/agent_memory_tools.js +793 -0
- package/dist/tools/create_skill.d.ts +46 -0
- package/dist/tools/create_skill.js +46 -0
- package/dist/tools/get_doc.d.ts +21 -0
- package/dist/tools/get_doc.js +24 -0
- package/dist/tools/get_persona.d.ts +15 -0
- package/dist/tools/get_persona.js +20 -0
- package/dist/tools/get_reference.d.ts +15 -0
- package/dist/tools/get_reference.js +20 -0
- package/dist/tools/get_skill.d.ts +34 -0
- package/dist/tools/get_skill.js +65 -0
- package/dist/tools/get_template_doc.d.ts +21 -0
- package/dist/tools/get_template_doc.js +24 -0
- package/dist/tools/list_docs.d.ts +15 -0
- package/dist/tools/list_docs.js +16 -0
- package/dist/tools/list_skills.d.ts +18 -0
- package/dist/tools/list_skills.js +17 -0
- package/dist/tools/list_template_docs.d.ts +15 -0
- package/dist/tools/list_template_docs.js +16 -0
- package/dist/tools/memory-engineering.d.ts +225 -0
- package/dist/tools/memory-engineering.js +284 -0
- package/dist/tools/memory-explain.d.ts +34 -0
- package/dist/tools/memory-explain.js +109 -0
- package/dist/tools/memory-governance.d.ts +171 -0
- package/dist/tools/memory-governance.js +224 -0
- package/dist/tools/memory-hooks.d.ts +67 -0
- package/dist/tools/memory-hooks.js +102 -0
- package/dist/tools/memory-working.d.ts +98 -0
- package/dist/tools/memory-working.js +101 -0
- package/dist/tools/memory_capture_turn.d.ts +66 -0
- package/dist/tools/memory_capture_turn.js +85 -0
- package/dist/tools/memory_consolidate.d.ts +55 -0
- package/dist/tools/memory_consolidate.js +176 -0
- package/dist/tools/memory_contradictions.d.ts +53 -0
- package/dist/tools/memory_contradictions.js +52 -0
- package/dist/tools/memory_graph_query.d.ts +51 -0
- package/dist/tools/memory_graph_query.js +35 -0
- package/dist/tools/memory_mark_cited.d.ts +43 -0
- package/dist/tools/memory_mark_cited.js +63 -0
- package/dist/tools/memory_recall.d.ts +77 -0
- package/dist/tools/memory_recall.js +81 -0
- package/dist/tools/memory_register_skill_hints.d.ts +49 -0
- package/dist/tools/memory_register_skill_hints.js +55 -0
- package/dist/tools/memory_resolve_session.d.ts +24 -0
- package/dist/tools/memory_resolve_session.js +133 -0
- package/dist/tools/memory_search.d.ts +146 -0
- package/dist/tools/memory_search.js +84 -0
- package/dist/tools/search_skills.d.ts +18 -0
- package/dist/tools/search_skills.js +17 -0
- package/dist/tools/update_doc.d.ts +24 -0
- package/dist/tools/update_doc.js +35 -0
- package/dist/tools/update_skill.d.ts +30 -0
- package/dist/tools/update_skill.js +80 -0
- package/dist/types.d.ts +81 -0
- package/dist/types.js +4 -0
- package/dist/writer.d.ts +30 -0
- package/dist/writer.js +220 -0
- package/docs/TEMPLATE ONLY +1 -0
- package/docs/api/API.md +64 -0
- package/docs/api/security/SECURITY.md +58 -0
- package/docs/deployment/DockerDeployment.md +30 -0
- package/docs/design/Design.md +59 -0
- package/docs/design/themes/apple.md +101 -0
- package/docs/design/themes/dieter-grid.md +100 -0
- package/docs/design/themes/gallery-white.md +100 -0
- package/docs/design/themes/pinterest.md +101 -0
- package/docs/design/themes/realty-open-house.md +101 -0
- package/docs/design/themes/vodafone.md +101 -0
- package/docs/hooks/Hooks.md +30 -0
- package/docs/schema/Schema.md +35 -0
- package/docs/strategy/ScalingStrategy.md +19 -0
- package/package.json +88 -0
- package/references/accessibility-checklist.md +160 -0
- package/references/orchestration-patterns.md +370 -0
- package/references/performance-checklist.md +153 -0
- package/references/security-checklist.md +134 -0
- package/references/testing-patterns.md +236 -0
- package/skills/agent/adr-skill/SKILL.md +299 -0
- package/skills/agent/agentic-engineering-workflow/SKILL.md +95 -0
- package/skills/agent/bootstrap-skill/SKILL.md +103 -0
- package/skills/agent/context-engineering/SKILL.md +307 -0
- package/skills/agent/debugging-and-error-recovery/SKILL.md +308 -0
- package/skills/agent/developer-growth-analysis/SKILL.md +328 -0
- package/skills/agent/doubt-driven-skill/SKILL.md +249 -0
- package/skills/agent/handover-skill/SKILL.md +112 -0
- package/skills/agent/idea-refine-skill/SKILL.md +185 -0
- package/skills/agent/idea-refine-skill/examples.md +238 -0
- package/skills/agent/idea-refine-skill/frameworks.md +99 -0
- package/skills/agent/idea-refine-skill/refinement-criteria.md +113 -0
- package/skills/agent/interview-skill/SKILL.md +226 -0
- package/skills/agent/planning-skill/SKILL.md +270 -0
- package/skills/agent/skill-authoring/SKILL.md +189 -0
- package/skills/agent/source-driven-skill/SKILL.md +197 -0
- package/skills/agent/spec-driven-skill/SKILL.md +221 -0
- package/skills/agent/sync-skill/SKILL.md +92 -0
- package/skills/agent/using-agent-skills/SKILL.md +189 -0
- package/skills/api/a11y-skill/SKILL.md +88 -0
- package/skills/api/api-skill/SKILL.md +123 -0
- package/skills/api/auth-skill/SKILL.md +80 -0
- package/skills/api/debug-skill/SKILL.md +535 -0
- package/skills/api/performance-skill/SKILL.md +100 -0
- package/skills/api/testing-skill/SKILL.md +100 -0
- package/skills/codebase/code-review-and-quality/SKILL.md +228 -0
- package/skills/codebase/code-simplification/SKILL.md +352 -0
- package/skills/codebase/code-structure-cleanup/SKILL.md +142 -0
- package/skills/codebase/concerns-skill/SKILL.md +89 -0
- package/skills/codebase/conventions-skill/SKILL.md +95 -0
- package/skills/codebase/doc-management-skill/SKILL.md +47 -0
- package/skills/codebase/git-workflow-skill/SKILL.md +312 -0
- package/skills/communication/1-3-1-rule/SKILL.md +120 -0
- package/skills/design/brutalist-skill/SKILL.md +131 -0
- package/skills/design/concept-diagrams/SKILL.md +387 -0
- package/skills/design/concept-diagrams/examples/apartment-floor-plan-conversion.md +244 -0
- package/skills/design/concept-diagrams/examples/automated-password-reset-flow.md +276 -0
- package/skills/design/concept-diagrams/examples/autonomous-llm-research-agent-flow.md +240 -0
- package/skills/design/concept-diagrams/examples/banana-journey-tree-to-smoothie.md +161 -0
- package/skills/design/concept-diagrams/examples/commercial-aircraft-structure.md +209 -0
- package/skills/design/concept-diagrams/examples/cpu-ooo-microarchitecture.md +236 -0
- package/skills/design/concept-diagrams/examples/electricity-grid-flow.md +182 -0
- package/skills/design/concept-diagrams/examples/feature-film-production-pipeline.md +172 -0
- package/skills/design/concept-diagrams/examples/hospital-emergency-department-flow.md +165 -0
- package/skills/design/concept-diagrams/examples/ml-benchmark-grouped-bar-chart.md +114 -0
- package/skills/design/concept-diagrams/examples/place-order-uml-sequence.md +325 -0
- package/skills/design/concept-diagrams/examples/smart-city-infrastructure.md +173 -0
- package/skills/design/concept-diagrams/examples/smartphone-layer-anatomy.md +154 -0
- package/skills/design/concept-diagrams/examples/sn2-reaction-mechanism.md +247 -0
- package/skills/design/concept-diagrams/examples/wind-turbine-structure.md +338 -0
- package/skills/design/concept-diagrams/references/dashboard-patterns.md +43 -0
- package/skills/design/concept-diagrams/references/infrastructure-patterns.md +144 -0
- package/skills/design/concept-diagrams/references/physical-shape-cookbook.md +42 -0
- package/skills/design/concept-diagrams/templates/template.html +174 -0
- package/skills/design/gpt-tasteskill/SKILL.md +114 -0
- package/skills/design/minimalist-skill/SKILL.md +116 -0
- package/skills/design/output-skill/SKILL.md +87 -0
- package/skills/design/redesign-skill/SKILL.md +213 -0
- package/skills/design/soft-skill/SKILL.md +132 -0
- package/skills/design/stitch-skill/EXAMPLE.md +121 -0
- package/skills/design/stitch-skill/SKILL.md +222 -0
- package/skills/design/taste-skill/SKILL.md +269 -0
- package/skills/devops/ci-cd-skill/SKILL.md +402 -0
- package/skills/devops/docker-skill/SKILL.md +297 -0
- package/skills/devops/domain-skill/SKILL.md +234 -0
- package/skills/lifecycle/changelog-generator/SKILL.md +135 -0
- package/skills/lifecycle/incremental-skill/SKILL.md +257 -0
- package/skills/lifecycle/migration-skill/SKILL.md +218 -0
- package/skills/lifecycle/shipping-skill/SKILL.md +321 -0
- package/skills/memory/agent-memory/SKILL.md +122 -0
- package/skills/qa/browser-testing-skill/SKILL.md +314 -0
- package/skills/ux/adversarial-ux-skill/SKILL.md +168 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sync-skill
|
|
3
|
+
description: Synchronizes documentation with the actual codebase. Use when code has changed but docs are outdated, before shipping a feature, or when you notice a mismatch between docs (API, Schema, Design) and reality.
|
|
4
|
+
hints: |
|
|
5
|
+
- Always identify which documentation file (e.g., API.md, Schema.md, README.md) is the primary target for changes.
|
|
6
|
+
- Review route validation logic (like Zod or Joi schemas) to accurately document constraints.
|
|
7
|
+
- Parse ORM models or database migrations to capture relationships and field limits in Schema.md.
|
|
8
|
+
- Scan CSS variables and tailwind/theme configurations to align Design.md design tokens.
|
|
9
|
+
- Double check if related auxiliary files (like .env.example or package.json) require matching updates.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Documentation Sync Skill
|
|
13
|
+
|
|
14
|
+
This skill ensures that your project's "Source of Truth" documents accurately reflect the current state of the codebase.
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
17
|
+
|
|
18
|
+
Documentation rot is one of the most common issues in fast-moving engineering projects. When code and documentation diverge, developers build integrations on false assumptions, leading to runtime failures and wasted hours. This skill establishes high-fidelity documentation syncing as a standard part of the implementation flow.
|
|
19
|
+
|
|
20
|
+
## When to Use
|
|
21
|
+
|
|
22
|
+
- A route, controller, or public interface signature has been added, modified, or deleted.
|
|
23
|
+
- Database schema changes (migrations, ORM models, or raw SQL structures) have occurred.
|
|
24
|
+
- Environment variables or initialization requirements have been introduced or altered.
|
|
25
|
+
- Styling system design tokens (colors, margins, font hierarchies) have been updated in code.
|
|
26
|
+
|
|
27
|
+
**When NOT to use:**
|
|
28
|
+
- Internal refactorings or small bug fixes that do not alter the public API, database schemas, or project setup.
|
|
29
|
+
- Writing temporary scripts or local scratch files.
|
|
30
|
+
|
|
31
|
+
## Workflow
|
|
32
|
+
|
|
33
|
+
1. **Analyze & Detect**:
|
|
34
|
+
- Identify which document needs syncing (`API.md`, `Schema.md`, `Design.md`, `README.md`, etc.).
|
|
35
|
+
- Scan the relevant source files (e.g., routes files for API, prisma/sql for Schema, CSS/React for Design).
|
|
36
|
+
- Identify specific discrepancies (missing fields, changed endpoints, new colors).
|
|
37
|
+
|
|
38
|
+
2. **Propose Changes**:
|
|
39
|
+
- Show the user the detected changes and the proposed updates to the documentation.
|
|
40
|
+
- Ask: "I've detected new endpoints in `routes/user.ts`. Should I add them to `API.md`?"
|
|
41
|
+
|
|
42
|
+
3. **Execute Sync**:
|
|
43
|
+
- Update the documentation files using `replace_file_content` or `multi_replace_file_content`.
|
|
44
|
+
- Ensure formatting remains consistent with the project's standards.
|
|
45
|
+
|
|
46
|
+
4. **Verify**:
|
|
47
|
+
- Do a final cross-check to ensure no information was missed.
|
|
48
|
+
- Check if related documents also need updates (e.g., changing a DB field in `Schema.md` might require an update to `API.md`).
|
|
49
|
+
|
|
50
|
+
## Detailed Instructions
|
|
51
|
+
|
|
52
|
+
You are the "Chronicler." Your goal is to eliminate "Documentation Rot."
|
|
53
|
+
|
|
54
|
+
### High-Fidelity API Syncing
|
|
55
|
+
When updating `API.md`:
|
|
56
|
+
- Don't just list the route. Include the required headers, request body structure, and successful/error response examples.
|
|
57
|
+
- Read the validation logic (e.g., Zod, Joi) to ensure the docs list the correct field constraints.
|
|
58
|
+
|
|
59
|
+
### High-Fidelity Schema Syncing
|
|
60
|
+
When updating `Schema.md`:
|
|
61
|
+
- Read the ORM files (Prisma, TypeORM) or raw SQL migrations.
|
|
62
|
+
- Capture relationships (1:1, 1:N, N:M) accurately in the documentation.
|
|
63
|
+
- Note any default values or constraints (e.g., `isUnique`, `isNullable`).
|
|
64
|
+
|
|
65
|
+
### High-Fidelity Design Syncing
|
|
66
|
+
When updating `Design.md`:
|
|
67
|
+
- Scan the root CSS or Theme configuration files.
|
|
68
|
+
- If a new color or spacing token was added to the code but isn't in `Design.md`, add it.
|
|
69
|
+
- Ensure the `Active Baseline Configuration` (Variance, Intensity, Density) still reflects the current vibe of the app.
|
|
70
|
+
|
|
71
|
+
## Common Rationalizations
|
|
72
|
+
|
|
73
|
+
| Rationalization | Reality |
|
|
74
|
+
|---|---|
|
|
75
|
+
| "The code is self-documenting, so docs are optional." | Self-documenting code explains *how* it works, but not *why*. External developers, AI agents, and non-technical stakeholders cannot read raw code efficiently. |
|
|
76
|
+
| "I will update the documentation in a subsequent pull request." | Stale documentation starts immediately. By separating documentation from implementation, it is highly likely to be forgotten or postponed indefinitely. |
|
|
77
|
+
| "It takes too long to document schemas manually." | Manual correctness prevents hours of downstream integration issues. Always sync API/DB changes alongside the code that introduces them. |
|
|
78
|
+
|
|
79
|
+
## Red Flags
|
|
80
|
+
|
|
81
|
+
- Modifying route signatures or request payloads without checking if `API.md` requires updates.
|
|
82
|
+
- Running database migrations or changing ORM schemas without matching updates to `Schema.md` or dependency docs.
|
|
83
|
+
- Introducing new environment variables without adding them to `.env.example` or updating setup instructions in `README.md`.
|
|
84
|
+
- Leaving standard template placeholder comments or empty sections inside updated documentation.
|
|
85
|
+
|
|
86
|
+
## Verification
|
|
87
|
+
|
|
88
|
+
After completing the sync, verify:
|
|
89
|
+
- [ ] Documentation accurately reflects the current state of the codebase.
|
|
90
|
+
- [ ] No placeholder values or boilerplate remains in the synchronized sections.
|
|
91
|
+
- [ ] All request/response payloads, headers, and schemas are complete.
|
|
92
|
+
- [ ] Auxiliary files (e.g., `README.md`, `.env.example`) have been reviewed for consistency.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: using-agent-skills
|
|
3
|
+
description: Discovers and invokes agent skills. Use when starting a session or when you need to discover which skill applies to the current task. This is the meta-skill that governs how all other skills are discovered and invoked.
|
|
4
|
+
hints: |
|
|
5
|
+
- Always consult this skill map first when starting any new development phase.
|
|
6
|
+
- Make explicit assumptions using the "ASSUMPTIONS I'M MAKING" format before coding.
|
|
7
|
+
- Present trade-offs immediately when noticing conflicting requirements or specs.
|
|
8
|
+
- Prioritize code simplicity and write surgical diffs that only touch requested files.
|
|
9
|
+
- Ensure every step of the lifecycle sequence is verified with concrete runtime evidence.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Using Agent Skills
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
Agent Skills is a collection of engineering workflow skills organized by development phase. Each skill encodes a specific process that senior engineers follow. This meta-skill helps you discover and apply the right skill for your current task.
|
|
17
|
+
|
|
18
|
+
## Skill Discovery
|
|
19
|
+
|
|
20
|
+
When a task arrives, identify the development phase and apply the corresponding skill:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
Task arrives
|
|
24
|
+
│
|
|
25
|
+
├── Don't know what you want yet? ──────→ interview-me
|
|
26
|
+
├── Have a rough concept, need variants? → idea-refine
|
|
27
|
+
├── New project/feature/change? ──→ spec-driven-development
|
|
28
|
+
├── Have a spec, need tasks? ──────→ planning-and-task-breakdown
|
|
29
|
+
├── Implementing code? ────────────→ incremental-implementation
|
|
30
|
+
│ ├── UI work? ─────────────────→ frontend-ui-engineering
|
|
31
|
+
│ ├── API work? ────────────────→ api-and-interface-design
|
|
32
|
+
│ ├── Need better context? ─────→ context-engineering
|
|
33
|
+
│ ├── Need doc-verified code? ───→ source-driven-development
|
|
34
|
+
│ └── Stakes high / unfamiliar code? ──→ doubt-driven-development
|
|
35
|
+
├── Writing/running tests? ────────→ test-driven-development
|
|
36
|
+
│ └── Browser-based? ───────────→ browser-testing-with-devtools
|
|
37
|
+
├── Something broke? ──────────────→ debugging-and-error-recovery
|
|
38
|
+
├── Reviewing code? ───────────────→ code-review-and-quality
|
|
39
|
+
│ ├── Security concerns? ───────→ security-and-hardening
|
|
40
|
+
│ └── Performance concerns? ────→ performance-optimization
|
|
41
|
+
├── Committing/branching? ─────────→ git-workflow-and-versioning
|
|
42
|
+
├── CI/CD pipeline work? ──────────→ ci-cd-and-automation
|
|
43
|
+
├── Writing docs/ADRs? ───────────→ documentation-and-adrs
|
|
44
|
+
├── Finishing a task/feature? ────→ project-handover-and-walkthrough
|
|
45
|
+
└── Deploying/launching? ─────────→ shipping-and-launch
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Core Operating Behaviors
|
|
49
|
+
|
|
50
|
+
These behaviors apply at all times, across all skills. They are non-negotiable.
|
|
51
|
+
|
|
52
|
+
### 1. Surface Assumptions
|
|
53
|
+
|
|
54
|
+
Before implementing anything non-trivial, explicitly state your assumptions:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
ASSUMPTIONS I'M MAKING:
|
|
58
|
+
1. [assumption about requirements]
|
|
59
|
+
2. [assumption about architecture]
|
|
60
|
+
3. [assumption about scope]
|
|
61
|
+
→ Correct me now or I'll proceed with these.
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Don't silently fill in ambiguous requirements. The most common failure mode is making wrong assumptions and running with them unchecked. Surface uncertainty early — it's cheaper than rework.
|
|
65
|
+
|
|
66
|
+
### 2. Manage Confusion Actively
|
|
67
|
+
|
|
68
|
+
When you encounter inconsistencies, conflicting requirements, or unclear specifications:
|
|
69
|
+
|
|
70
|
+
1. **STOP.** Do not proceed with a guess.
|
|
71
|
+
2. Name the specific confusion.
|
|
72
|
+
3. Present the tradeoff or ask the clarifying question.
|
|
73
|
+
4. Wait for resolution before continuing.
|
|
74
|
+
|
|
75
|
+
**Bad:** Silently picking one interpretation and hoping it's right.
|
|
76
|
+
**Good:** "I see X in the spec but Y in the existing code. Which takes precedence?"
|
|
77
|
+
|
|
78
|
+
### 3. Push Back When Warranted
|
|
79
|
+
|
|
80
|
+
You are not a yes-machine. When an approach has clear problems:
|
|
81
|
+
|
|
82
|
+
- Point out the issue directly
|
|
83
|
+
- Explain the concrete downside (quantify when possible — "this adds ~200ms latency" not "this might be slower")
|
|
84
|
+
- Propose an alternative
|
|
85
|
+
- Accept the human's decision if they override with full information
|
|
86
|
+
|
|
87
|
+
Sycophancy is a failure mode. "Of course!" followed by implementing a bad idea helps no one. Honest technical disagreement is more valuable than false agreement.
|
|
88
|
+
|
|
89
|
+
### 4. Enforce Simplicity
|
|
90
|
+
|
|
91
|
+
Your natural tendency is to overcomplicate. Actively resist it.
|
|
92
|
+
|
|
93
|
+
Before finishing any implementation, ask:
|
|
94
|
+
- Can this be done in fewer lines?
|
|
95
|
+
- Are these abstractions earning their complexity?
|
|
96
|
+
- Would a staff engineer look at this and say "why didn't you just..."?
|
|
97
|
+
|
|
98
|
+
If you build 1000 lines and 100 would suffice, you have failed. Prefer the boring, obvious solution. Cleverness is expensive.
|
|
99
|
+
|
|
100
|
+
### 5. Maintain Scope Discipline
|
|
101
|
+
|
|
102
|
+
Touch only what you're asked to touch.
|
|
103
|
+
|
|
104
|
+
Do NOT:
|
|
105
|
+
- Remove comments you don't understand
|
|
106
|
+
- "Clean up" code orthogonal to the task
|
|
107
|
+
- Refactor adjacent systems as a side effect
|
|
108
|
+
- Delete code that seems unused without explicit approval
|
|
109
|
+
- Add features not in the spec because they "seem useful"
|
|
110
|
+
|
|
111
|
+
Your job is surgical precision, not unsolicited renovation.
|
|
112
|
+
|
|
113
|
+
### 6. Verify, Don't Assume
|
|
114
|
+
|
|
115
|
+
Every skill includes a verification step. A task is not complete until verification passes. "Seems right" is never sufficient — there must be evidence (passing tests, build output, runtime data).
|
|
116
|
+
|
|
117
|
+
## Failure Modes to Avoid
|
|
118
|
+
|
|
119
|
+
These are the subtle errors that look like productivity but create problems:
|
|
120
|
+
|
|
121
|
+
1. Making wrong assumptions without checking
|
|
122
|
+
2. Not managing your own confusion — plowing ahead when lost
|
|
123
|
+
3. Not surfacing inconsistencies you notice
|
|
124
|
+
4. Not presenting tradeoffs on non-obvious decisions
|
|
125
|
+
5. Being sycophantic ("Of course!") to approaches with clear problems
|
|
126
|
+
6. Overcomplicating code and APIs
|
|
127
|
+
7. Modifying code or comments orthogonal to the task
|
|
128
|
+
8. Removing things you don't fully understand
|
|
129
|
+
9. Building without a spec because "it's obvious"
|
|
130
|
+
10. Skipping verification because "it looks right"
|
|
131
|
+
|
|
132
|
+
## Skill Rules
|
|
133
|
+
|
|
134
|
+
1. **Check for an applicable skill before starting work.** Skills encode processes that prevent common mistakes.
|
|
135
|
+
|
|
136
|
+
2. **Skills are workflows, not suggestions.** Follow the steps in order. Don't skip verification steps.
|
|
137
|
+
|
|
138
|
+
3. **Multiple skills can apply.** A feature implementation might involve `idea-refine` → `spec-driven-development` → `planning-and-task-breakdown` → `incremental-implementation` → `test-driven-development` → `code-review-and-quality` → `shipping-and-launch` in sequence.
|
|
139
|
+
|
|
140
|
+
4. **When in doubt, start with a spec.** If the task is non-trivial and there's no spec, begin with `spec-driven-development`.
|
|
141
|
+
|
|
142
|
+
## Lifecycle Sequence
|
|
143
|
+
|
|
144
|
+
For a complete feature, the typical skill sequence is:
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
1. interview-me → Extract what the user actually wants
|
|
148
|
+
2. idea-refine → Refine vague ideas
|
|
149
|
+
3. spec-driven-development → Define what we're building
|
|
150
|
+
4. planning-and-task-breakdown → Break into verifiable chunks
|
|
151
|
+
5. context-engineering → Load the right context
|
|
152
|
+
6. source-driven-development → Verify against official docs
|
|
153
|
+
7. incremental-implementation → Build slice by slice
|
|
154
|
+
8. doubt-driven-development → Cross-examine non-trivial decisions in-flight
|
|
155
|
+
9. test-driven-development → Prove each slice works
|
|
156
|
+
10. code-review-and-quality → Review before merge
|
|
157
|
+
11. git-workflow-and-versioning → Clean commit history
|
|
158
|
+
12. documentation-and-adrs → Document decisions
|
|
159
|
+
13. project-handover-and-walkthrough → Summarize work with walkthrough.md
|
|
160
|
+
14. shipping-and-launch → Deploy safely
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Not every task needs every skill. A bug fix might only need: `debugging-and-error-recovery` → `test-driven-development` → `code-review-and-quality`.
|
|
164
|
+
|
|
165
|
+
## Quick Reference
|
|
166
|
+
|
|
167
|
+
| Phase | Skill | One-Line Summary |
|
|
168
|
+
|-------|-------|-----------------|
|
|
169
|
+
| Define | [interview-skill](../interview-skill/SKILL.md) | Surface what the user actually wants before any plan, spec, or code exists |
|
|
170
|
+
| Define | [idea-refine-skill](../idea-refine-skill/SKILL.md) | Refine ideas through structured divergent and convergent thinking |
|
|
171
|
+
| Define | [spec-driven-skill](../spec-driven-skill/SKILL.md) | Requirements and acceptance criteria before code |
|
|
172
|
+
| Plan | [planning-skill](../planning-skill/SKILL.md) | Decompose into tasks and track progress via task.md |
|
|
173
|
+
| Build | [incremental-skill](../../lifecycle/incremental-skill/SKILL.md) | Thin vertical slices, test each before expanding |
|
|
174
|
+
| Build | [source-driven-skill](../source-driven-skill/SKILL.md) | Verify against official docs before implementing |
|
|
175
|
+
| Build | [doubt-driven-skill](../doubt-driven-skill/SKILL.md) | Adversarial fresh-context review of every non-trivial decision |
|
|
176
|
+
| Build | [taste-skill](../../design/taste-skill/SKILL.md) | Production-quality UI with accessibility |
|
|
177
|
+
| Build | [api-skill](../../api/api-skill/SKILL.md) | Stable interfaces with clear contracts |
|
|
178
|
+
| Verify | [testing-skill](../../api/testing-skill/SKILL.md) | Failing test first, then make it pass |
|
|
179
|
+
| Verify | [browser-testing-skill](../../qa/browser-testing-skill/SKILL.md) | Chrome DevTools MCP for runtime verification |
|
|
180
|
+
| Verify | [debugging-and-error-recovery](../debugging-and-error-recovery/SKILL.md) | Reproduce → localize → fix → guard |
|
|
181
|
+
| Review | [code-reviewer](../../../agents/code-reviewer.md) | Five-axis review with quality gates |
|
|
182
|
+
| Review | [security-auditor](../../../agents/security-auditor.md) | OWASP prevention, input validation, least privilege |
|
|
183
|
+
| Review | [performance-skill](../../api/performance-skill/SKILL.md) | Measure first, optimize only what matters |
|
|
184
|
+
| Ship | [git-workflow-skill](../../codebase/git-workflow-skill/SKILL.md) | Atomic commits, clean history |
|
|
185
|
+
| Ship | [ci-cd-skill](../../devops/ci-cd-skill/SKILL.md) | Automated quality gates on every change |
|
|
186
|
+
| Ship | [adr-skill](../adr-skill/SKILL.md) | Document the why, not just the what |
|
|
187
|
+
| Ship | [handover-skill](../handover-skill/SKILL.md) | Final walkthrough and handover via walkthrough.md |
|
|
188
|
+
| Ship | [shipping-skill](../../lifecycle/shipping-skill/SKILL.md) | Pre-launch checklist, monitoring, rollback plan |
|
|
189
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: a11y-skill
|
|
3
|
+
description: WCAG 2.1 AA accessibility mandates for the frontend. Use when implementing or reviewing user interface components, form inputs, modals, or motion effects.
|
|
4
|
+
hints: |
|
|
5
|
+
- Always use semantic HTML tags (like button, main, nav, section) instead of styled divs.
|
|
6
|
+
- Ensure every interactive element is keyboard-focusable with visible focus-visible indicators.
|
|
7
|
+
- Associate all input fields with clear label tags and connect error messages via aria-describedby.
|
|
8
|
+
- Implement focus-traps for modals and popovers, restoring focus on close.
|
|
9
|
+
- Audit color contrast ratios and respect prefers-reduced-motion media queries for transitions.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Accessibility (A11Y) Skill
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
User interfaces must meet WCAG 2.1 Level AA standards. Accessibility is a first-class citizen in modern interface design, ensuring that apps are robust, accessible, and compliant for all users, including those using assistive technologies.
|
|
17
|
+
|
|
18
|
+
## Workflow
|
|
19
|
+
|
|
20
|
+
- **Semantic HTML Only**
|
|
21
|
+
- Use `<button>` for actions, `<a>` for navigation.
|
|
22
|
+
- Never use `div` or `span` for interactive elements without proper ARIA roles and keyboard listeners.
|
|
23
|
+
- Maintain a logical heading hierarchy (`h1` -> `h2` -> `h3`).
|
|
24
|
+
|
|
25
|
+
- **Interactive Elements**
|
|
26
|
+
- Every interactive element must be keyboard-reachable (Tab) and operable (Enter/Space).
|
|
27
|
+
- Use `aria-label` for icon-only buttons.
|
|
28
|
+
- Never remove focus outlines without providing a high-contrast `:focus-visible` alternative.
|
|
29
|
+
|
|
30
|
+
- **Forms & Inputs**
|
|
31
|
+
- Every input must have an associated `<label>`.
|
|
32
|
+
- Use `aria-describedby` to link error messages to their respective inputs.
|
|
33
|
+
- Use `aria-invalid="true"` for fields with errors.
|
|
34
|
+
|
|
35
|
+
- **Visual & Motion**
|
|
36
|
+
- Maintain a 4.5:1 contrast ratio for normal text.
|
|
37
|
+
- Respect `prefers-reduced-motion` for all animations.
|
|
38
|
+
- Do not rely on color alone to convey status (use icons or text labels).
|
|
39
|
+
|
|
40
|
+
- **Focus Management**
|
|
41
|
+
- Modals must trap focus while open.
|
|
42
|
+
- Focus must return to the triggering element upon modal closure.
|
|
43
|
+
|
|
44
|
+
## Implementation Pattern (React)
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
<button
|
|
48
|
+
aria-label="Close modal"
|
|
49
|
+
className="focus-visible:ring-2 focus-visible:ring-dd-accent"
|
|
50
|
+
onClick={onClose}
|
|
51
|
+
>
|
|
52
|
+
<XIcon aria-hidden="true" />
|
|
53
|
+
</button>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## When to Use
|
|
57
|
+
|
|
58
|
+
- Designing, building, or refactoring user interfaces, navigation menus, and page structures.
|
|
59
|
+
- Creating interactive components such as modals, dropdowns, popovers, or forms.
|
|
60
|
+
- Adding custom styling focus effects, animations, or state indicators.
|
|
61
|
+
|
|
62
|
+
**When NOT to use:**
|
|
63
|
+
- Developing purely headless CLI tools, server backend APIs, or cron jobs that lack user interfaces.
|
|
64
|
+
- Running internal unit tests that do not involve DOM rendering or browser-based UI.
|
|
65
|
+
|
|
66
|
+
## Common Rationalizations
|
|
67
|
+
|
|
68
|
+
| Rationalization | Reality |
|
|
69
|
+
|---|---|
|
|
70
|
+
| "Accessibility is a nice-to-have we can add later." | Retrofitting accessibility is extremely expensive as it requires changing DOM structures and component behaviors. Day-one accessibility ensures robust interfaces. |
|
|
71
|
+
| "A styled div with an onClick handler is good enough." | Styled divs lack default keyboard interactivity (Tab focus, Enter/Space activation) and screen reader support, completely blocking disabled users. |
|
|
72
|
+
| "Default browser focus outlines look ugly, so I'll disable them." | Disabling focus outlines makes the app unusable for keyboard-only users. Always replace default outlines with premium custom `:focus-visible` styles. |
|
|
73
|
+
|
|
74
|
+
## Red Flags
|
|
75
|
+
|
|
76
|
+
- Interactive elements constructed from `<div>` or `<span>` without ARIA roles, `tabindex="0"`, or keyboard event listeners.
|
|
77
|
+
- Using `outline: none` or `outline: 0` in CSS without providing a visible focus alternative.
|
|
78
|
+
- Icon-only buttons lacking `aria-label` or descriptive visually-hidden text.
|
|
79
|
+
- Form inputs without corresponding `<label>` tags or using placeholder attributes as the sole label.
|
|
80
|
+
|
|
81
|
+
## Verification
|
|
82
|
+
|
|
83
|
+
After completing the UI implementation, verify:
|
|
84
|
+
- [ ] Tab key navigation succeeds through all interactive elements in logical order.
|
|
85
|
+
- [ ] No keyboard focus traps exist (user can navigate into and out of all controls).
|
|
86
|
+
- [ ] Screen reader roles and accessibility trees are checked (using Chrome DevTools or axe audits).
|
|
87
|
+
- [ ] All inputs have associated labels and announce error states correctly using ARIA attributes.
|
|
88
|
+
- [ ] Interactive modals restrict focus to their active contents and restore focus on exit.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-skill
|
|
3
|
+
description: Mandatory middleware, validation boilerplate, error safe-listing, and performance rules for fast, consistent, and secure endpoints.
|
|
4
|
+
hints: |
|
|
5
|
+
- Verify existing API routes, schemas, and specs in the project before drafting new endpoints.
|
|
6
|
+
- Implement a strong validation layer (e.g. Zod, Joi) covering all incoming body, query, and path parameters.
|
|
7
|
+
- Apply security middleware, rate-limiting, and authentication gates to all non-public endpoints.
|
|
8
|
+
- Safe-list user-visible errors and never leak database stack traces or internal secrets to the client.
|
|
9
|
+
- Optimize query performance by selecting explicit columns and using cursor-based pagination for lists.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# API Standards Skill
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
This skill ensures every network endpoint is fast, consistent, secure, and well-designed. Standardizing input validation, error mapping, rate limiting, and database interactions prevents security vulnerabilities and performance bottlenecks at the entry point of the application.
|
|
17
|
+
|
|
18
|
+
## Workflow
|
|
19
|
+
|
|
20
|
+
### 1. Document & Align Check
|
|
21
|
+
Before crafting or modifying any endpoint, review the project's active API specification files (e.g., `API.md`, `openapi.yaml`, or `docs/api/`). Ensure your endpoints adhere exactly to the defined naming schemes, payload structures, and architectural standards.
|
|
22
|
+
|
|
23
|
+
### 2. Implement the "Security Shield" Ingress
|
|
24
|
+
Use the following pattern for every new route to guarantee input hygiene, authentication, and rate limiting:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { Request, Response } from 'express';
|
|
28
|
+
import { z } from 'zod';
|
|
29
|
+
import { redisRateLimit } from '../../middleware/rateLimit';
|
|
30
|
+
import { requireAuth } from '../../middleware/auth';
|
|
31
|
+
import { sendSuccess, ErrorResponses } from '../../utils/response';
|
|
32
|
+
|
|
33
|
+
// 1. Define Input Schema
|
|
34
|
+
const InputSchema = z.object({
|
|
35
|
+
id: z.string().uuid(),
|
|
36
|
+
// ... other fields
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const myNewEndpoint = [
|
|
40
|
+
// 2. Apply Rate Limit
|
|
41
|
+
redisRateLimit({ windowMs: 60000, max: 10 }),
|
|
42
|
+
|
|
43
|
+
// 3. Authenticate
|
|
44
|
+
requireAuth,
|
|
45
|
+
|
|
46
|
+
async (req: Request, res: Response) => {
|
|
47
|
+
try {
|
|
48
|
+
// 4. Validate Input
|
|
49
|
+
const data = InputSchema.parse(req.body);
|
|
50
|
+
|
|
51
|
+
// 5. Derive Identity
|
|
52
|
+
const userId = req.user.id;
|
|
53
|
+
|
|
54
|
+
// ... Business Logic ...
|
|
55
|
+
|
|
56
|
+
return sendSuccess(res, { result });
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (error instanceof z.ZodError) {
|
|
59
|
+
return ErrorResponses.badRequest(res, 'Invalid input', 'VALIDATION_ERROR');
|
|
60
|
+
}
|
|
61
|
+
console.error('API Error:', error);
|
|
62
|
+
return ErrorResponses.internalError(res);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
];
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Error Safe-Listing
|
|
69
|
+
|
|
70
|
+
Map all internal system errors to secure, generic client-facing errors. Never leak raw database queries, connection failures, or environment details.
|
|
71
|
+
|
|
72
|
+
| Internal Code / Error Type | HTTP Status | Visible to Client? | Exposed Client Code |
|
|
73
|
+
|---|---|---|---|
|
|
74
|
+
| `ZodError` / Input validation | 400 Bad Request | Yes (with field details) | `VALIDATION_ERROR` |
|
|
75
|
+
| Missing Session Token / Expired | 401 Unauthorized | Yes | `AUTH_REQUIRED` |
|
|
76
|
+
| Insufficient Permissions / Roles | 403 Forbidden | Yes | `FORBIDDEN` |
|
|
77
|
+
| Database Entity Missing | 404 Not Found | Yes | `NOT_FOUND` |
|
|
78
|
+
| Raw Database Exception (`DB_ERROR`) | 500 Internal Error | **NO** | `INTERNAL_ERROR` |
|
|
79
|
+
| Third-Party API Failure | 500 Internal Error | **NO** | `INTERNAL_ERROR` |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Performance Rules
|
|
84
|
+
|
|
85
|
+
- **No `SELECT *`**: Always explicitly select the required columns. Scanning and returning unused database fields wastes database memory and network bandwidth.
|
|
86
|
+
- **Cursors Only**: Use cursor-based keys (`before`/`after` or comparable token indices) for list pagination. Avoid `OFFSET` pagination, which degrades rapidly as tables grow.
|
|
87
|
+
- **Cache-Aside Pattern**: Wrap resource-intensive, read-heavy query operations (like listings, configs, or stats) in cached gets/sets (e.g., Redis) with explicit TTLs.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## When to Use
|
|
92
|
+
|
|
93
|
+
- Implementing new REST, GraphQL, or RPC endpoints in backend routers.
|
|
94
|
+
- Modifying existing request/response structures or validation schemas.
|
|
95
|
+
- Refactoring data fetch APIs, database pagination, caching logic, or error handling.
|
|
96
|
+
|
|
97
|
+
**When NOT to use:**
|
|
98
|
+
- Internal utility functions, helper libraries, or offline CLI commands that do not expose public network endpoints.
|
|
99
|
+
- Developing pure client-side markup or styling layout elements.
|
|
100
|
+
|
|
101
|
+
## Common Rationalizations
|
|
102
|
+
|
|
103
|
+
| Rationalization | Reality |
|
|
104
|
+
|---|---|
|
|
105
|
+
| "I'll add validation and security middlewares later." | Security and input validation are baseline requirements, not post-implementation decorations. Out-of-order security leads to leaked data. |
|
|
106
|
+
| "Leaking internal stack traces helps me debug faster in staging." | Stack traces and DB messages leak structural details about database models, schemas, and packages, giving attackers vectors to exploit. |
|
|
107
|
+
| "Offset pagination is easier to implement." | Offset pagination (`LIMIT/OFFSET`) scales poorly. As datasets grow, the database must scan millions of rows to discard them, causing severe latency degradation. |
|
|
108
|
+
|
|
109
|
+
## Red Flags
|
|
110
|
+
|
|
111
|
+
- Request handler reading raw untrusted `req.body` variables without structural validation.
|
|
112
|
+
- Database query executing `SELECT *` or lack of explicit select fields.
|
|
113
|
+
- Returning raw server errors or database exceptions directly in JSON response blocks.
|
|
114
|
+
- Pagination endpoints that do not accept cursor boundaries or rely solely on page offsets.
|
|
115
|
+
|
|
116
|
+
## Verification
|
|
117
|
+
|
|
118
|
+
After completing the API endpoint, verify:
|
|
119
|
+
- [ ] Route uses the "Security Shield" pattern (Rate limits, Authentication, Validation).
|
|
120
|
+
- [ ] Zod or equivalent validation schemas strictly validate all parameters (body, query, params).
|
|
121
|
+
- [ ] Malformed or invalid payloads return safe `VALIDATION_ERROR` responses with 400 statuses.
|
|
122
|
+
- [ ] System logs stack traces on exceptions, but clients receive a generic `INTERNAL_ERROR` 500 status.
|
|
123
|
+
- [ ] Large list responses enforce cursor-based pagination and select explicit database columns.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: auth-skill
|
|
3
|
+
description: Identity, JWT rules, session management, and security logic for authentication. Use when building or modifying login, registration, password resets, token generation, or authentication middlewares.
|
|
4
|
+
hints: |
|
|
5
|
+
- Ensure JWT payloads remain clean of any Personally Identifiable Information (PII).
|
|
6
|
+
- Verify WebAuthn/Passkey signatures, origins, and authenticator counters strictly.
|
|
7
|
+
- Implement a session "Kill Switch" that blacklists active session IDs on password changes.
|
|
8
|
+
- Enforce httpOnly, secure, and sameSite cookie attributes for refresh tokens.
|
|
9
|
+
- Apply brute-force protection using rate limiters on all authentication and password reset routes.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Authentication & Security Skill
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
This skill governs the identity, session, and credential lifecycle of users. Authentication is the primary security gate of the application; failure to adhere to these rules results in severe security vulnerabilities `[SEC-202]`.
|
|
17
|
+
|
|
18
|
+
## Workflow
|
|
19
|
+
|
|
20
|
+
- **[AUTH-001] JWT Payload Hygiene**
|
|
21
|
+
- Only include: `sub` (userId), `sid` (sessionId), `role`, and `exp`.
|
|
22
|
+
- **Never** include: Email, full name, phone number, or any other Personally Identifiable Information (PII) in the JWT.
|
|
23
|
+
|
|
24
|
+
- **[AUTH-002] Passkey Lifecycle**
|
|
25
|
+
- Use `@simplewebauthn/server` or an equivalent secure library for all WebAuthn flows.
|
|
26
|
+
- Registration: Verify `challenge` and matching hostname `origin`.
|
|
27
|
+
- Authentication: Verify the signature and ensure the `counter` is strictly incrementing to detect cloned authenticators.
|
|
28
|
+
|
|
29
|
+
- **[AUTH-003] The "Kill Switch" Mechanism**
|
|
30
|
+
- If a user changes their password or requests "Log out from all devices," all active sessions (`user_sessions` table) must be immediately deleted.
|
|
31
|
+
- Admins can revoke any session by `sessionId`, which must immediately block the associated Access Token via a real-time Redis blacklist.
|
|
32
|
+
|
|
33
|
+
- **[AUTH-004] Brute-Force Shield**
|
|
34
|
+
- Apply `redisRateLimit` or standard IP rate-limiting to all Auth routes (login, register, password reset).
|
|
35
|
+
- Failed attempts should trigger exponential backoff to prevent automated dictionary attacks.
|
|
36
|
+
|
|
37
|
+
## Implementation Details
|
|
38
|
+
|
|
39
|
+
### Session Revocation Pattern
|
|
40
|
+
When revoking a session, perform these steps:
|
|
41
|
+
1. Delete the row from the active sessions table (e.g., `user_sessions`).
|
|
42
|
+
2. Add `sid` to a Redis `revoked_sessions` set with a TTL matching the remaining JWT expiry.
|
|
43
|
+
3. Middleware `requireAuth` must check this Redis set on every request to block revoked but not-yet-expired tokens.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## When to Use
|
|
48
|
+
|
|
49
|
+
- Building or modifying authentication systems (OAuth, standard login/signup, Passkeys/WebAuthn).
|
|
50
|
+
- Designing session lifecycles, refresh token rotations, or JWT signing strategies.
|
|
51
|
+
- Setting up access control gates, route guards, and identity middlewares.
|
|
52
|
+
- Implementing password recovery, email verification, or account deletion flows.
|
|
53
|
+
|
|
54
|
+
**When NOT to use:**
|
|
55
|
+
- Internal communications between microservices inside a secure VPC where authentication is managed at the network or service-mesh layer.
|
|
56
|
+
- Static client-side routing where page access control is handled solely as a UX/UI enhancement rather than a security boundary.
|
|
57
|
+
|
|
58
|
+
## Common Rationalizations
|
|
59
|
+
|
|
60
|
+
| Rationalization | Reality |
|
|
61
|
+
|---|---|
|
|
62
|
+
| "Storing the user email in the JWT makes it easy to read in the frontend." | JWTs are base64-encoded, not encrypted. Storing emails or names in a JWT exposes PII to anyone inspecting the token, violating data privacy regulations. |
|
|
63
|
+
| "A session table is enough; we don't need real-time revocation checking." | Access tokens (JWTs) remain valid until they expire. Without a real-time Redis blacklist or short-lived token validation, active attackers cannot be locked out. |
|
|
64
|
+
| "I'll store the refresh token in LocalStorage for simplicity." | Storing session secrets in LocalStorage makes them fully accessible to cross-site scripting (XSS) attacks. Refresh tokens must only live in httpOnly cookies. |
|
|
65
|
+
|
|
66
|
+
## Red Flags
|
|
67
|
+
|
|
68
|
+
- Refresh tokens stored in standard cookies without `httpOnly: true` or `secure: true` attributes.
|
|
69
|
+
- Storing full names, phone numbers, or passwords inside JWT payload bodies.
|
|
70
|
+
- Failing to increment or verify WebAuthn authenticator counters during Passkey authentication.
|
|
71
|
+
- Auth endpoints (login, register, reset) that do not enforce active rate-limiting middleware.
|
|
72
|
+
|
|
73
|
+
## Verification
|
|
74
|
+
|
|
75
|
+
After completing the authentication setup, verify:
|
|
76
|
+
- [ ] JWT payloads are inspected and confirm they only contain non-sensitive identifiers (`sub`, `sid`, `role`, `exp`).
|
|
77
|
+
- [ ] Password resets successfully revoke all active database sessions and invalidate outstanding access tokens.
|
|
78
|
+
- [ ] Refresh tokens are confirmed to be delivered via secure, httpOnly, sameSite cookies.
|
|
79
|
+
- [ ] Brute-force requests against auth endpoints are actively blocked by rate limiters.
|
|
80
|
+
- [ ] WebAuthn registration/authentication processes verify signatures, origins, and anti-cloning counters.
|