@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,236 @@
|
|
|
1
|
+
# Testing Patterns Reference
|
|
2
|
+
|
|
3
|
+
Quick reference for common testing patterns across the stack. Use alongside the `test-driven-development` skill.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Test Structure (Arrange-Act-Assert)](#test-structure-arrange-act-assert)
|
|
8
|
+
- [Test Naming Conventions](#test-naming-conventions)
|
|
9
|
+
- [Common Assertions](#common-assertions)
|
|
10
|
+
- [Mocking Patterns](#mocking-patterns)
|
|
11
|
+
- [React/Component Testing](#reactcomponent-testing)
|
|
12
|
+
- [API / Integration Testing](#api--integration-testing)
|
|
13
|
+
- [E2E Testing (Playwright)](#e2e-testing-playwright)
|
|
14
|
+
- [Test Anti-Patterns](#test-anti-patterns)
|
|
15
|
+
|
|
16
|
+
## Test Structure (Arrange-Act-Assert)
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
it('describes expected behavior', () => {
|
|
20
|
+
// Arrange: Set up test data and preconditions
|
|
21
|
+
const input = { title: 'Test Task', priority: 'high' };
|
|
22
|
+
|
|
23
|
+
// Act: Perform the action being tested
|
|
24
|
+
const result = createTask(input);
|
|
25
|
+
|
|
26
|
+
// Assert: Verify the outcome
|
|
27
|
+
expect(result.title).toBe('Test Task');
|
|
28
|
+
expect(result.priority).toBe('high');
|
|
29
|
+
expect(result.status).toBe('pending');
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Test Naming Conventions
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// Pattern: [unit] [expected behavior] [condition]
|
|
37
|
+
describe('TaskService.createTask', () => {
|
|
38
|
+
it('creates a task with default pending status', () => {});
|
|
39
|
+
it('throws ValidationError when title is empty', () => {});
|
|
40
|
+
it('trims whitespace from title', () => {});
|
|
41
|
+
it('generates a unique ID for each task', () => {});
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Common Assertions
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
// Equality
|
|
49
|
+
expect(result).toBe(expected); // Strict equality (===)
|
|
50
|
+
expect(result).toEqual(expected); // Deep equality (objects/arrays)
|
|
51
|
+
expect(result).toStrictEqual(expected); // Deep equality + type matching
|
|
52
|
+
|
|
53
|
+
// Truthiness
|
|
54
|
+
expect(result).toBeTruthy();
|
|
55
|
+
expect(result).toBeFalsy();
|
|
56
|
+
expect(result).toBeNull();
|
|
57
|
+
expect(result).toBeDefined();
|
|
58
|
+
expect(result).toBeUndefined();
|
|
59
|
+
|
|
60
|
+
// Numbers
|
|
61
|
+
expect(result).toBeGreaterThan(5);
|
|
62
|
+
expect(result).toBeLessThanOrEqual(10);
|
|
63
|
+
expect(result).toBeCloseTo(0.3, 5); // Floating point
|
|
64
|
+
|
|
65
|
+
// Strings
|
|
66
|
+
expect(result).toMatch(/pattern/);
|
|
67
|
+
expect(result).toContain('substring');
|
|
68
|
+
|
|
69
|
+
// Arrays / Objects
|
|
70
|
+
expect(array).toContain(item);
|
|
71
|
+
expect(array).toHaveLength(3);
|
|
72
|
+
expect(object).toHaveProperty('key', 'value');
|
|
73
|
+
|
|
74
|
+
// Errors
|
|
75
|
+
expect(() => fn()).toThrow();
|
|
76
|
+
expect(() => fn()).toThrow(ValidationError);
|
|
77
|
+
expect(() => fn()).toThrow('specific message');
|
|
78
|
+
|
|
79
|
+
// Async
|
|
80
|
+
await expect(asyncFn()).resolves.toBe(value);
|
|
81
|
+
await expect(asyncFn()).rejects.toThrow(Error);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Mocking Patterns
|
|
85
|
+
|
|
86
|
+
### Mock Functions
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
const mockFn = jest.fn();
|
|
90
|
+
mockFn.mockReturnValue(42);
|
|
91
|
+
mockFn.mockResolvedValue({ data: 'test' });
|
|
92
|
+
mockFn.mockImplementation((x) => x * 2);
|
|
93
|
+
|
|
94
|
+
expect(mockFn).toHaveBeenCalled();
|
|
95
|
+
expect(mockFn).toHaveBeenCalledWith('arg1', 'arg2');
|
|
96
|
+
expect(mockFn).toHaveBeenCalledTimes(3);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Mock Modules
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
// Mock an entire module
|
|
103
|
+
jest.mock('./database', () => ({
|
|
104
|
+
query: jest.fn().mockResolvedValue([{ id: 1, title: 'Test' }]),
|
|
105
|
+
}));
|
|
106
|
+
|
|
107
|
+
// Mock specific exports
|
|
108
|
+
jest.mock('./utils', () => ({
|
|
109
|
+
...jest.requireActual('./utils'),
|
|
110
|
+
generateId: jest.fn().mockReturnValue('test-id'),
|
|
111
|
+
}));
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Mock at Boundaries Only
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
Mock these: Don't mock these:
|
|
118
|
+
├── Database calls ├── Internal utility functions
|
|
119
|
+
├── HTTP requests ├── Business logic
|
|
120
|
+
├── File system operations ├── Data transformations
|
|
121
|
+
├── External API calls ├── Validation functions
|
|
122
|
+
└── Time/Date (when needed) └── Pure functions
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## React/Component Testing
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
129
|
+
|
|
130
|
+
describe('TaskForm', () => {
|
|
131
|
+
it('submits the form with entered data', async () => {
|
|
132
|
+
const onSubmit = jest.fn();
|
|
133
|
+
render(<TaskForm onSubmit={onSubmit} />);
|
|
134
|
+
|
|
135
|
+
// Find elements by accessible role/label (not test IDs)
|
|
136
|
+
await screen.findByRole('textbox', { name: /title/i });
|
|
137
|
+
fireEvent.change(screen.getByRole('textbox', { name: /title/i }), {
|
|
138
|
+
target: { value: 'New Task' },
|
|
139
|
+
});
|
|
140
|
+
fireEvent.click(screen.getByRole('button', { name: /create/i }));
|
|
141
|
+
|
|
142
|
+
await waitFor(() => {
|
|
143
|
+
expect(onSubmit).toHaveBeenCalledWith({ title: 'New Task' });
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('shows validation error for empty title', async () => {
|
|
148
|
+
render(<TaskForm onSubmit={jest.fn()} />);
|
|
149
|
+
|
|
150
|
+
fireEvent.click(screen.getByRole('button', { name: /create/i }));
|
|
151
|
+
|
|
152
|
+
expect(await screen.findByText(/title is required/i)).toBeInTheDocument();
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## API / Integration Testing
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import request from 'supertest';
|
|
161
|
+
import { app } from '../src/app';
|
|
162
|
+
|
|
163
|
+
describe('POST /api/tasks', () => {
|
|
164
|
+
it('creates a task and returns 201', async () => {
|
|
165
|
+
const response = await request(app)
|
|
166
|
+
.post('/api/tasks')
|
|
167
|
+
.send({ title: 'Test Task' })
|
|
168
|
+
.set('Authorization', `Bearer ${testToken}`)
|
|
169
|
+
.expect(201);
|
|
170
|
+
|
|
171
|
+
expect(response.body).toMatchObject({
|
|
172
|
+
id: expect.any(String),
|
|
173
|
+
title: 'Test Task',
|
|
174
|
+
status: 'pending',
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('returns 422 for invalid input', async () => {
|
|
179
|
+
const response = await request(app)
|
|
180
|
+
.post('/api/tasks')
|
|
181
|
+
.send({ title: '' })
|
|
182
|
+
.set('Authorization', `Bearer ${testToken}`)
|
|
183
|
+
.expect(422);
|
|
184
|
+
|
|
185
|
+
expect(response.body.error.code).toBe('VALIDATION_ERROR');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('returns 401 without authentication', async () => {
|
|
189
|
+
await request(app)
|
|
190
|
+
.post('/api/tasks')
|
|
191
|
+
.send({ title: 'Test' })
|
|
192
|
+
.expect(401);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## E2E Testing (Playwright)
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
import { test, expect } from '@playwright/test';
|
|
201
|
+
|
|
202
|
+
test('user can create and complete a task', async ({ page }) => {
|
|
203
|
+
// Navigate and authenticate
|
|
204
|
+
await page.goto('/');
|
|
205
|
+
await page.fill('[name="email"]', 'test@example.com');
|
|
206
|
+
await page.fill('[name="password"]', 'testpass123');
|
|
207
|
+
await page.click('button:has-text("Log in")');
|
|
208
|
+
|
|
209
|
+
// Create a task
|
|
210
|
+
await page.click('button:has-text("New Task")');
|
|
211
|
+
await page.fill('[name="title"]', 'Buy groceries');
|
|
212
|
+
await page.click('button:has-text("Create")');
|
|
213
|
+
|
|
214
|
+
// Verify task appears
|
|
215
|
+
await expect(page.locator('text=Buy groceries')).toBeVisible();
|
|
216
|
+
|
|
217
|
+
// Complete the task
|
|
218
|
+
await page.click('[aria-label="Complete Buy groceries"]');
|
|
219
|
+
await expect(page.locator('text=Buy groceries')).toHaveCSS(
|
|
220
|
+
'text-decoration-line', 'line-through'
|
|
221
|
+
);
|
|
222
|
+
});
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Test Anti-Patterns
|
|
226
|
+
|
|
227
|
+
| Anti-Pattern | Problem | Better Approach |
|
|
228
|
+
|---|---|---|
|
|
229
|
+
| Testing implementation details | Breaks on refactor | Test inputs/outputs |
|
|
230
|
+
| Snapshot everything | No one reviews snapshot diffs | Assert specific values |
|
|
231
|
+
| Shared mutable state | Tests pollute each other | Setup/teardown per test |
|
|
232
|
+
| Testing third-party code | Wastes time, not your bug | Mock the boundary |
|
|
233
|
+
| Skipping tests to pass CI | Hides real bugs | Fix or delete the test |
|
|
234
|
+
| Using `test.skip` permanently | Dead code | Remove or fix it |
|
|
235
|
+
| Overly broad assertions | Doesn't catch regressions | Be specific |
|
|
236
|
+
| No async error handling | Swallowed errors, false passes | Always `await` async tests |
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: adr-skill
|
|
3
|
+
description: Records decisions and documentation. Use when making architectural decisions, changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.
|
|
4
|
+
hints:
|
|
5
|
+
- Document the 'why' (context, constraints, trade-offs) behind a change, not just the 'what'.
|
|
6
|
+
- Write an ADR (Architecture Decision Record) for any decision that would be expensive to reverse.
|
|
7
|
+
- Review openSrc/ directories or existing ADRs under docs/decisions/ for structure and style guidelines.
|
|
8
|
+
- Store ADRs in docs/decisions/ with sequential, three-digit numbering (e.g., ADR-001).
|
|
9
|
+
- Keep public API and inline documentation clean, type-annotated, and free of commented-out code.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Documentation and ADRs
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
Document decisions, not just code. The most valuable documentation captures the *why* — the context, constraints, and trade-offs that led to a decision. Code shows *what* was built; documentation explains *why it was built this way* and *what alternatives were considered*. This context is essential for future humans and agents working in the codebase.
|
|
17
|
+
|
|
18
|
+
## When to Use
|
|
19
|
+
|
|
20
|
+
- Making a significant architectural decision
|
|
21
|
+
- Choosing between competing approaches
|
|
22
|
+
- Adding or changing a public API
|
|
23
|
+
- Shipping a feature that changes user-facing behavior
|
|
24
|
+
- Onboarding new team members (or agents) to the project
|
|
25
|
+
- When you find yourself explaining the same thing repeatedly
|
|
26
|
+
|
|
27
|
+
**When NOT to use:** Don't document obvious code. Don't add comments that restate what the code already says. Don't write docs for throwaway prototypes.
|
|
28
|
+
|
|
29
|
+
## Architecture Decision Records (ADRs)
|
|
30
|
+
|
|
31
|
+
ADRs capture the reasoning behind significant technical decisions. They're the highest-value documentation you can write.
|
|
32
|
+
|
|
33
|
+
### When to Write an ADR
|
|
34
|
+
|
|
35
|
+
- Choosing a framework, library, or major dependency
|
|
36
|
+
- Designing a data model or database schema
|
|
37
|
+
- Selecting an authentication strategy
|
|
38
|
+
- Deciding on an API architecture (REST vs. GraphQL vs. tRPC)
|
|
39
|
+
- Choosing between build tools, hosting platforms, or infrastructure
|
|
40
|
+
- Any decision that would be expensive to reverse
|
|
41
|
+
|
|
42
|
+
### ADR Template
|
|
43
|
+
|
|
44
|
+
Store ADRs in `docs/decisions/` with sequential numbering:
|
|
45
|
+
|
|
46
|
+
```markdown
|
|
47
|
+
# ADR-001: Use PostgreSQL for primary database
|
|
48
|
+
|
|
49
|
+
## Status
|
|
50
|
+
Accepted | Superseded by ADR-XXX | Deprecated
|
|
51
|
+
|
|
52
|
+
## Date
|
|
53
|
+
2025-01-15
|
|
54
|
+
|
|
55
|
+
## Context
|
|
56
|
+
We need a primary database for the task management application. Key requirements:
|
|
57
|
+
- Relational data model (users, tasks, teams with relationships)
|
|
58
|
+
- ACID transactions for task state changes
|
|
59
|
+
- Support for full-text search on task content
|
|
60
|
+
- Managed hosting available (for small team, limited ops capacity)
|
|
61
|
+
|
|
62
|
+
## Decision
|
|
63
|
+
Use PostgreSQL with Prisma ORM.
|
|
64
|
+
|
|
65
|
+
## Alternatives Considered
|
|
66
|
+
|
|
67
|
+
### MongoDB
|
|
68
|
+
- Pros: Flexible schema, easy to start with
|
|
69
|
+
- Cons: Our data is inherently relational; would need to manage relationships manually
|
|
70
|
+
- Rejected: Relational data in a document store leads to complex joins or data duplication
|
|
71
|
+
|
|
72
|
+
### SQLite
|
|
73
|
+
- Pros: Zero configuration, embedded, fast for reads
|
|
74
|
+
- Cons: Limited concurrent write support, no managed hosting for production
|
|
75
|
+
- Rejected: Not suitable for multi-user web application in production
|
|
76
|
+
|
|
77
|
+
### MySQL
|
|
78
|
+
- Pros: Mature, widely supported
|
|
79
|
+
- Cons: PostgreSQL has better JSON support, full-text search, and ecosystem tooling
|
|
80
|
+
- Rejected: PostgreSQL is the better fit for our feature requirements
|
|
81
|
+
|
|
82
|
+
## Consequences
|
|
83
|
+
- Prisma provides type-safe database access and migration management
|
|
84
|
+
- We can use PostgreSQL's full-text search instead of adding Elasticsearch
|
|
85
|
+
- Team needs PostgreSQL knowledge (standard skill, low risk)
|
|
86
|
+
- Hosting on managed service (Supabase, Neon, or RDS)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### ADR Lifecycle
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
PROPOSED → ACCEPTED → (SUPERSEDED or DEPRECATED)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
- **Don't delete old ADRs.** They capture historical context.
|
|
96
|
+
- When a decision changes, write a new ADR that references and supersedes the old one.
|
|
97
|
+
|
|
98
|
+
## Inline Documentation
|
|
99
|
+
|
|
100
|
+
### When to Comment
|
|
101
|
+
|
|
102
|
+
Comment the *why*, not the *what*:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
// BAD: Restates the code
|
|
106
|
+
// Increment counter by 1
|
|
107
|
+
counter += 1;
|
|
108
|
+
|
|
109
|
+
// GOOD: Explains non-obvious intent
|
|
110
|
+
// Rate limit uses a sliding window — reset counter at window boundary,
|
|
111
|
+
// not on a fixed schedule, to prevent burst attacks at window edges
|
|
112
|
+
if (now - windowStart > WINDOW_SIZE_MS) {
|
|
113
|
+
counter = 0;
|
|
114
|
+
windowStart = now;
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### When NOT to Comment
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// Don't comment self-explanatory code
|
|
122
|
+
function calculateTotal(items: CartItem[]): number {
|
|
123
|
+
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Don't leave TODO comments for things you should just do now
|
|
127
|
+
// TODO: add error handling ← Just add it
|
|
128
|
+
|
|
129
|
+
// Don't leave commented-out code
|
|
130
|
+
// const oldImplementation = () => { ... } ← Delete it, git has history
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Document Known Gotchas
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
/**
|
|
137
|
+
* IMPORTANT: This function must be called before the first render.
|
|
138
|
+
* If called after hydration, it causes a flash of unstyled content
|
|
139
|
+
* because the theme context isn't available during SSR.
|
|
140
|
+
*
|
|
141
|
+
* See ADR-003 for the full design rationale.
|
|
142
|
+
*/
|
|
143
|
+
export function initializeTheme(theme: Theme): void {
|
|
144
|
+
// ...
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## API Documentation
|
|
149
|
+
|
|
150
|
+
For public APIs (REST, GraphQL, library interfaces):
|
|
151
|
+
|
|
152
|
+
### Inline with Types (Preferred for TypeScript)
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
/**
|
|
156
|
+
* Creates a new task.
|
|
157
|
+
*
|
|
158
|
+
* @param input - Task creation data (title required, description optional)
|
|
159
|
+
* @returns The created task with server-generated ID and timestamps
|
|
160
|
+
* @throws {ValidationError} If title is empty or exceeds 200 characters
|
|
161
|
+
* @throws {AuthenticationError} If the user is not authenticated
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* const task = await createTask({ title: 'Buy groceries' });
|
|
165
|
+
* console.log(task.id); // "task_abc123"
|
|
166
|
+
*/
|
|
167
|
+
export async function createTask(input: CreateTaskInput): Promise<Task> {
|
|
168
|
+
// ...
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### OpenAPI / Swagger for REST APIs
|
|
173
|
+
|
|
174
|
+
```yaml
|
|
175
|
+
paths:
|
|
176
|
+
/api/tasks:
|
|
177
|
+
post:
|
|
178
|
+
summary: Create a task
|
|
179
|
+
requestBody:
|
|
180
|
+
required: true
|
|
181
|
+
content:
|
|
182
|
+
application/json:
|
|
183
|
+
schema:
|
|
184
|
+
$ref: '#/components/schemas/CreateTaskInput'
|
|
185
|
+
responses:
|
|
186
|
+
'201':
|
|
187
|
+
description: Task created
|
|
188
|
+
content:
|
|
189
|
+
application/json:
|
|
190
|
+
schema:
|
|
191
|
+
$ref: '#/components/schemas/Task'
|
|
192
|
+
'422':
|
|
193
|
+
description: Validation error
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## README Structure
|
|
197
|
+
|
|
198
|
+
Every project should have a README that covers:
|
|
199
|
+
|
|
200
|
+
```markdown
|
|
201
|
+
# Project Name
|
|
202
|
+
|
|
203
|
+
One-paragraph description of what this project does.
|
|
204
|
+
|
|
205
|
+
## Quick Start
|
|
206
|
+
1. Clone the repo
|
|
207
|
+
2. Install dependencies: `npm install`
|
|
208
|
+
3. Set up environment: `cp .env.example .env`
|
|
209
|
+
4. Run the dev server: `npm run dev`
|
|
210
|
+
|
|
211
|
+
## Commands
|
|
212
|
+
| Command | Description |
|
|
213
|
+
|---------|-------------|
|
|
214
|
+
| `npm run dev` | Start development server |
|
|
215
|
+
| `npm test` | Run tests |
|
|
216
|
+
| `npm run build` | Production build |
|
|
217
|
+
| `npm run lint` | Run linter |
|
|
218
|
+
|
|
219
|
+
## Architecture
|
|
220
|
+
Brief overview of the project structure and key design decisions.
|
|
221
|
+
Link to ADRs for details.
|
|
222
|
+
|
|
223
|
+
## Contributing
|
|
224
|
+
How to contribute, coding standards, PR process.
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Changelog Maintenance
|
|
228
|
+
|
|
229
|
+
For shipped features:
|
|
230
|
+
|
|
231
|
+
```markdown
|
|
232
|
+
# Changelog
|
|
233
|
+
|
|
234
|
+
## [1.2.0] - 2025-01-20
|
|
235
|
+
### Added
|
|
236
|
+
- Task sharing: users can share tasks with team members (#123)
|
|
237
|
+
- Email notifications for task assignments (#124)
|
|
238
|
+
|
|
239
|
+
### Fixed
|
|
240
|
+
- Duplicate tasks appearing when rapidly clicking create button (#125)
|
|
241
|
+
|
|
242
|
+
### Changed
|
|
243
|
+
- Task list now loads 50 items per page (was 20) for better UX (#126)
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Documentation for Agents
|
|
247
|
+
|
|
248
|
+
Special consideration for AI agent context:
|
|
249
|
+
|
|
250
|
+
- **CLAUDE.md / rules files** — Document project conventions so agents follow them
|
|
251
|
+
- **Spec files** — Keep specs updated so agents build the right thing
|
|
252
|
+
- **ADRs** — Help agents understand why past decisions were made (prevents re-deciding)
|
|
253
|
+
- **Inline gotchas** — Prevent agents from falling into known traps
|
|
254
|
+
|
|
255
|
+
## Common Rationalizations
|
|
256
|
+
|
|
257
|
+
| Rationalization | Reality |
|
|
258
|
+
|---|---|
|
|
259
|
+
| "The code is self-documenting" | Code shows what. It doesn't show why, what alternatives were rejected, or what constraints apply. |
|
|
260
|
+
| "We'll write docs when the API stabilizes" | APIs stabilize faster when you document them. The doc is the first test of the design. |
|
|
261
|
+
| "Nobody reads docs" | Agents do. Future engineers do. Your 3-months-later self does. |
|
|
262
|
+
| "ADRs are overhead" | A 10-minute ADR prevents a 2-hour debate about the same decision six months later. |
|
|
263
|
+
| "Comments get outdated" | Comments on *why* are stable. Comments on *what* get outdated — that's why you only write the former. |
|
|
264
|
+
|
|
265
|
+
## Red Flags
|
|
266
|
+
|
|
267
|
+
- Architectural decisions with no written rationale
|
|
268
|
+
- Public APIs with no documentation or types
|
|
269
|
+
- README that doesn't explain how to run the project
|
|
270
|
+
- Commented-out code instead of deletion
|
|
271
|
+
- TODO comments that have been there for weeks
|
|
272
|
+
- No ADRs in a project with significant architectural choices
|
|
273
|
+
- Documentation that restates the code instead of explaining intent
|
|
274
|
+
|
|
275
|
+
## Required Checks
|
|
276
|
+
|
|
277
|
+
After documenting:
|
|
278
|
+
|
|
279
|
+
- [ ] ADRs exist for all significant architectural decisions
|
|
280
|
+
- [ ] README covers quick start, commands, and architecture overview
|
|
281
|
+
- [ ] API functions have parameter and return type documentation
|
|
282
|
+
- [ ] Known gotchas are documented inline where they matter
|
|
283
|
+
- [ ] No commented-out code remains
|
|
284
|
+
- [ ] Rules files (CLAUDE.md etc.) are current and accurate
|
|
285
|
+
|
|
286
|
+
## Workflow
|
|
287
|
+
|
|
288
|
+
1. **Identify Significant Decisions:** Recognize when a change impacts API structure, package dependencies, data model/schema, or deployment architecture.
|
|
289
|
+
2. **Draft the Architecture Decision Record (ADR):** Create a new markdown file under `docs/decisions/` prefixed with a sequential index (e.g., `ADR-005-redis-caching.md`).
|
|
290
|
+
3. **Analyze Alternatives:** Outline at least 2 distinct alternatives, detailing explicit pros/cons and clear reasons for rejection.
|
|
291
|
+
4. **Define Consequences:** Explicitly capture downstream engineering impacts, risks, and onboarding implications.
|
|
292
|
+
5. **Verify and Update:** Review against similar historical decisions (checking `openSrc/` patterns if an openSrc/ directory is present) before finalizing.
|
|
293
|
+
|
|
294
|
+
## Verification
|
|
295
|
+
|
|
296
|
+
After executing this skill, confirm:
|
|
297
|
+
- [ ] ADR file is correctly formatted and located in `docs/decisions/`.
|
|
298
|
+
- [ ] No un-analyzed alternatives or vague rationalizations exist in the record.
|
|
299
|
+
- [ ] Code references to the decision are updated to cross-reference the ADR.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentic-engineering-workflow
|
|
3
|
+
description: Provides an end-to-end operating system for building software with AI agents. Use when starting any non-trivial feature, MVP, or tool build with an AI coding agent. Use when you want a repeatable workflow instead of ad-hoc prompting.
|
|
4
|
+
hints: |
|
|
5
|
+
- Keep each task small and PR-sized — one feature or fix at a time.
|
|
6
|
+
- Build the minimal working version first, then run a cleanup pass.
|
|
7
|
+
- Never guess APIs — reference official docs or the openSrc/ folder (if present) before coding.
|
|
8
|
+
- Run a review-fix loop after every PR until tests pass and review is clean.
|
|
9
|
+
- Launch earlier than feels comfortable. Feedback beats perfection.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Agentic Engineering Workflow
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
A repeatable operating system for building software with AI coding agents. The human decides the outcome, the agent does the mechanical work, and tight feedback loops keep the result honest. This is not "ask the AI to build everything and hope" — it is a disciplined process where every step is small, verifiable, and reversible.
|
|
17
|
+
|
|
18
|
+
## When to Use
|
|
19
|
+
|
|
20
|
+
- You are building an MVP, feature, internal tool, or AI-assisted product.
|
|
21
|
+
- You want a repeatable AI coding workflow instead of random prompting.
|
|
22
|
+
- You are using Cursor, Claude Code, Codex, Hermes, or another coding harness.
|
|
23
|
+
|
|
24
|
+
**When NOT to use:** One-off tiny edits where a normal direct prompt is sufficient.
|
|
25
|
+
|
|
26
|
+
## Workflow
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
HARNESS → SMALL TASK → SOURCE CONTEXT → BUILD MINIMAL → CLEANUP → REVIEW LOOP → LAUNCH → SECURITY
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
1. **Pick the strongest harness/model you can access.** The harness is the wrapper around the model: file search, terminal, browser, tools, system prompt, and project memory. The model matters, but the harness determines what the model can actually do.
|
|
33
|
+
|
|
34
|
+
2. **Keep the task small.** Ask for one feature, one fix, or one reviewable unit at a time. If a plan is too large, ask the agent to split it into smaller PR-sized chunks.
|
|
35
|
+
|
|
36
|
+
3. **Give source code as context when docs are not enough.** If you are using a package, SDK, framework, or open-source tool, tell the agent to search it before coding. If an `openSrc/` folder is present in the workspace, check its reference repositories for high-quality implementation examples. See `source-driven-skill` for the full pattern.
|
|
37
|
+
|
|
38
|
+
4. **Build the minimal feature first.** Do not refactor the whole app while building the feature. Get the smallest working version running.
|
|
39
|
+
|
|
40
|
+
5. **Run a cleanup pass.** After the feature works, ask the agent to find duplicated runtime mechanics and move them into reusable service-layer modules. See `code-structure-cleanup`.
|
|
41
|
+
|
|
42
|
+
6. **Run a review-fix loop.** Use tests, typechecks, and AI/human review. Feed review feedback back into the coding agent. Keep fixing until the PR is clean or a human decision is needed. See `code-review-and-quality`.
|
|
43
|
+
|
|
44
|
+
7. **Launch earlier than feels comfortable.** A semi-functional MVP with real user feedback beats a perfect private project every time.
|
|
45
|
+
|
|
46
|
+
8. **Apply security guardrails.** Never install a package less than 14 days old without human approval. Use 2FA via authenticator app, not SMS. Never paste secrets into prompts. When a package breach trends, ask the agent to scan your local projects for that package/version.
|
|
47
|
+
|
|
48
|
+
## Copy-Paste Starter Prompt
|
|
49
|
+
|
|
50
|
+
```md
|
|
51
|
+
We are going to build this using an agentic engineering workflow.
|
|
52
|
+
|
|
53
|
+
Rules:
|
|
54
|
+
1. Keep the change small and reviewable.
|
|
55
|
+
2. Search the existing code before creating new abstractions.
|
|
56
|
+
3. If using a package/framework, reference its local source or official repo before guessing APIs.
|
|
57
|
+
4. Build the minimal working version first.
|
|
58
|
+
5. After it works, run a code-structure cleanup pass.
|
|
59
|
+
6. Run relevant tests/typechecks.
|
|
60
|
+
7. Summarize what changed, what was tested, and what still needs human judgment.
|
|
61
|
+
|
|
62
|
+
Task:
|
|
63
|
+
<describe the feature or fix here>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Common Rationalizations
|
|
67
|
+
|
|
68
|
+
| Rationalization | Reality |
|
|
69
|
+
|---|---|
|
|
70
|
+
| "Let the agent decide the approach" | The agent is a worker, not the product owner. You decide the outcome — the agent executes it. |
|
|
71
|
+
| "More context is always better" | Context overload degrades output quality. Give only the files and specs relevant to the current task. |
|
|
72
|
+
| "One big PR is faster" | Review loops break down on large diffs. Split into small, reviewable units. |
|
|
73
|
+
| "I'll do the cleanup later" | Working code with duplicated mechanics is technical debt that slows every future agent working in that area. |
|
|
74
|
+
| "It just needs one more feature before launch" | Waiting for perfect is how competitors ship before you. Ship now, improve with feedback. |
|
|
75
|
+
|
|
76
|
+
## Red Flags
|
|
77
|
+
|
|
78
|
+
- Starting a task without defining what "done" means.
|
|
79
|
+
- Asking the agent to build multiple features in a single session without a plan.
|
|
80
|
+
- PRs with thousands of changed lines — the review loop will break down.
|
|
81
|
+
- Agent inventing API names instead of referencing source or docs.
|
|
82
|
+
- No cleanup pass after a feature ships.
|
|
83
|
+
- Secrets in prompts, screenshots, or code comments.
|
|
84
|
+
|
|
85
|
+
## Verification
|
|
86
|
+
|
|
87
|
+
After completing a feature using this workflow, confirm:
|
|
88
|
+
|
|
89
|
+
- [ ] Task was scoped to a single small, reviewable unit.
|
|
90
|
+
- [ ] Agent searched relevant existing code before editing.
|
|
91
|
+
- [ ] External package/framework behavior was checked against source or official docs.
|
|
92
|
+
- [ ] Feature works locally.
|
|
93
|
+
- [ ] Cleanup pass was run and obvious duplication was removed.
|
|
94
|
+
- [ ] Tests/typechecks ran, or the reason they could not is stated.
|
|
95
|
+
- [ ] Security-sensitive changes were explicitly reviewed by a human.
|