@zigrivers/scaffold 2.1.2 → 2.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +505 -119
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +94 -14
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/build.test.js +30 -5
- package/dist/cli/commands/build.test.js.map +1 -1
- package/dist/cli/commands/check.d.ts +12 -0
- package/dist/cli/commands/check.d.ts.map +1 -0
- package/dist/cli/commands/check.js +311 -0
- package/dist/cli/commands/check.js.map +1 -0
- package/dist/cli/commands/check.test.d.ts +2 -0
- package/dist/cli/commands/check.test.d.ts.map +1 -0
- package/dist/cli/commands/check.test.js +412 -0
- package/dist/cli/commands/check.test.js.map +1 -0
- package/dist/cli/commands/complete.d.ts +12 -0
- package/dist/cli/commands/complete.d.ts.map +1 -0
- package/dist/cli/commands/complete.js +101 -0
- package/dist/cli/commands/complete.js.map +1 -0
- package/dist/cli/commands/complete.test.d.ts +2 -0
- package/dist/cli/commands/complete.test.d.ts.map +1 -0
- package/dist/cli/commands/complete.test.js +133 -0
- package/dist/cli/commands/complete.test.js.map +1 -0
- package/dist/cli/commands/dashboard.d.ts.map +1 -1
- package/dist/cli/commands/dashboard.js +12 -8
- package/dist/cli/commands/dashboard.js.map +1 -1
- package/dist/cli/commands/info.d.ts.map +1 -1
- package/dist/cli/commands/info.js +4 -0
- package/dist/cli/commands/info.js.map +1 -1
- package/dist/cli/commands/knowledge.d.ts.map +1 -1
- package/dist/cli/commands/knowledge.js +6 -2
- package/dist/cli/commands/knowledge.js.map +1 -1
- package/dist/cli/commands/knowledge.test.js +16 -11
- package/dist/cli/commands/knowledge.test.js.map +1 -1
- package/dist/cli/commands/next.d.ts.map +1 -1
- package/dist/cli/commands/next.js +41 -13
- package/dist/cli/commands/next.js.map +1 -1
- package/dist/cli/commands/next.test.js +3 -0
- package/dist/cli/commands/next.test.js.map +1 -1
- package/dist/cli/commands/reset.d.ts +1 -0
- package/dist/cli/commands/reset.d.ts.map +1 -1
- package/dist/cli/commands/reset.js +179 -67
- package/dist/cli/commands/reset.js.map +1 -1
- package/dist/cli/commands/reset.test.js +360 -0
- package/dist/cli/commands/reset.test.js.map +1 -1
- package/dist/cli/commands/rework.d.ts +20 -0
- package/dist/cli/commands/rework.d.ts.map +1 -0
- package/dist/cli/commands/rework.js +332 -0
- package/dist/cli/commands/rework.js.map +1 -0
- package/dist/cli/commands/rework.test.d.ts +2 -0
- package/dist/cli/commands/rework.test.d.ts.map +1 -0
- package/dist/cli/commands/rework.test.js +297 -0
- package/dist/cli/commands/rework.test.js.map +1 -0
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +59 -31
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/run.test.js +288 -6
- package/dist/cli/commands/run.test.js.map +1 -1
- package/dist/cli/commands/skill.d.ts +12 -0
- package/dist/cli/commands/skill.d.ts.map +1 -0
- package/dist/cli/commands/skill.js +123 -0
- package/dist/cli/commands/skill.js.map +1 -0
- package/dist/cli/commands/skill.test.d.ts +2 -0
- package/dist/cli/commands/skill.test.d.ts.map +1 -0
- package/dist/cli/commands/skill.test.js +297 -0
- package/dist/cli/commands/skill.test.js.map +1 -0
- package/dist/cli/commands/skip.d.ts +1 -1
- package/dist/cli/commands/skip.d.ts.map +1 -1
- package/dist/cli/commands/skip.js +123 -57
- package/dist/cli/commands/skip.js.map +1 -1
- package/dist/cli/commands/skip.test.js +91 -0
- package/dist/cli/commands/skip.test.js.map +1 -1
- package/dist/cli/commands/status.d.ts +1 -0
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +57 -10
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/status.test.js +81 -0
- package/dist/cli/commands/status.test.js.map +1 -1
- package/dist/cli/commands/update.test.js +252 -0
- package/dist/cli/commands/update.test.js.map +1 -1
- package/dist/cli/commands/version.test.js +171 -1
- package/dist/cli/commands/version.test.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +8 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/core/adapters/adapter.d.ts +14 -0
- package/dist/core/adapters/adapter.d.ts.map +1 -1
- package/dist/core/adapters/adapter.js.map +1 -1
- package/dist/core/adapters/adapter.test.js +10 -0
- package/dist/core/adapters/adapter.test.js.map +1 -1
- package/dist/core/adapters/claude-code.d.ts.map +1 -1
- package/dist/core/adapters/claude-code.js +47 -10
- package/dist/core/adapters/claude-code.js.map +1 -1
- package/dist/core/adapters/claude-code.test.js +41 -20
- package/dist/core/adapters/claude-code.test.js.map +1 -1
- package/dist/core/adapters/codex.d.ts.map +1 -1
- package/dist/core/adapters/codex.js +5 -1
- package/dist/core/adapters/codex.js.map +1 -1
- package/dist/core/adapters/codex.test.js +5 -0
- package/dist/core/adapters/codex.test.js.map +1 -1
- package/dist/core/adapters/universal.d.ts.map +1 -1
- package/dist/core/adapters/universal.js +0 -1
- package/dist/core/adapters/universal.js.map +1 -1
- package/dist/core/adapters/universal.test.js +5 -0
- package/dist/core/adapters/universal.test.js.map +1 -1
- package/dist/core/assembly/context-gatherer.d.ts.map +1 -1
- package/dist/core/assembly/context-gatherer.js +5 -2
- package/dist/core/assembly/context-gatherer.js.map +1 -1
- package/dist/core/assembly/engine.d.ts.map +1 -1
- package/dist/core/assembly/engine.js +10 -2
- package/dist/core/assembly/engine.js.map +1 -1
- package/dist/core/assembly/engine.test.js +19 -0
- package/dist/core/assembly/engine.test.js.map +1 -1
- package/dist/core/assembly/knowledge-loader.d.ts +25 -0
- package/dist/core/assembly/knowledge-loader.d.ts.map +1 -1
- package/dist/core/assembly/knowledge-loader.js +75 -2
- package/dist/core/assembly/knowledge-loader.js.map +1 -1
- package/dist/core/assembly/knowledge-loader.test.js +388 -1
- package/dist/core/assembly/knowledge-loader.test.js.map +1 -1
- package/dist/core/assembly/meta-prompt-loader.d.ts +6 -0
- package/dist/core/assembly/meta-prompt-loader.d.ts.map +1 -1
- package/dist/core/assembly/meta-prompt-loader.js +41 -25
- package/dist/core/assembly/meta-prompt-loader.js.map +1 -1
- package/dist/core/assembly/preset-loader.d.ts +10 -0
- package/dist/core/assembly/preset-loader.d.ts.map +1 -1
- package/dist/core/assembly/preset-loader.js +26 -1
- package/dist/core/assembly/preset-loader.js.map +1 -1
- package/dist/core/assembly/preset-loader.test.js +65 -1
- package/dist/core/assembly/preset-loader.test.js.map +1 -1
- package/dist/core/assembly/update-mode.d.ts.map +1 -1
- package/dist/core/assembly/update-mode.js +10 -4
- package/dist/core/assembly/update-mode.js.map +1 -1
- package/dist/core/assembly/update-mode.test.js +47 -0
- package/dist/core/assembly/update-mode.test.js.map +1 -1
- package/dist/core/dependency/dependency.d.ts.map +1 -1
- package/dist/core/dependency/dependency.js +3 -2
- package/dist/core/dependency/dependency.js.map +1 -1
- package/dist/core/dependency/dependency.test.js +2 -0
- package/dist/core/dependency/dependency.test.js.map +1 -1
- package/dist/core/dependency/eligibility.js +3 -3
- package/dist/core/dependency/eligibility.js.map +1 -1
- package/dist/core/dependency/eligibility.test.js +2 -0
- package/dist/core/dependency/eligibility.test.js.map +1 -1
- package/dist/core/dependency/graph.d.ts.map +1 -1
- package/dist/core/dependency/graph.js +4 -0
- package/dist/core/dependency/graph.js.map +1 -1
- package/dist/core/dependency/graph.test.d.ts +2 -0
- package/dist/core/dependency/graph.test.d.ts.map +1 -0
- package/dist/core/dependency/graph.test.js +262 -0
- package/dist/core/dependency/graph.test.js.map +1 -0
- package/dist/core/rework/phase-selector.d.ts +24 -0
- package/dist/core/rework/phase-selector.d.ts.map +1 -0
- package/dist/core/rework/phase-selector.js +98 -0
- package/dist/core/rework/phase-selector.js.map +1 -0
- package/dist/core/rework/phase-selector.test.d.ts +2 -0
- package/dist/core/rework/phase-selector.test.d.ts.map +1 -0
- package/dist/core/rework/phase-selector.test.js +138 -0
- package/dist/core/rework/phase-selector.test.js.map +1 -0
- package/dist/dashboard/generator.d.ts +48 -17
- package/dist/dashboard/generator.d.ts.map +1 -1
- package/dist/dashboard/generator.js +75 -5
- package/dist/dashboard/generator.js.map +1 -1
- package/dist/dashboard/generator.test.js +213 -5
- package/dist/dashboard/generator.test.js.map +1 -1
- package/dist/dashboard/template.d.ts +1 -1
- package/dist/dashboard/template.d.ts.map +1 -1
- package/dist/dashboard/template.js +755 -114
- package/dist/dashboard/template.js.map +1 -1
- package/dist/e2e/knowledge.test.js +4 -3
- package/dist/e2e/knowledge.test.js.map +1 -1
- package/dist/e2e/pipeline.test.js +2 -0
- package/dist/e2e/pipeline.test.js.map +1 -1
- package/dist/e2e/rework.test.d.ts +6 -0
- package/dist/e2e/rework.test.d.ts.map +1 -0
- package/dist/e2e/rework.test.js +226 -0
- package/dist/e2e/rework.test.js.map +1 -0
- package/dist/index.js +0 -0
- package/dist/project/adopt.test.js +2 -0
- package/dist/project/adopt.test.js.map +1 -1
- package/dist/project/claude-md.js +2 -2
- package/dist/project/claude-md.js.map +1 -1
- package/dist/project/claude-md.test.js +4 -4
- package/dist/project/claude-md.test.js.map +1 -1
- package/dist/project/detector.d.ts.map +1 -1
- package/dist/project/detector.js +4 -1
- package/dist/project/detector.js.map +1 -1
- package/dist/project/frontmatter.d.ts.map +1 -1
- package/dist/project/frontmatter.js +54 -15
- package/dist/project/frontmatter.js.map +1 -1
- package/dist/project/frontmatter.test.js +2 -2
- package/dist/project/frontmatter.test.js.map +1 -1
- package/dist/state/rework-manager.d.ts +16 -0
- package/dist/state/rework-manager.d.ts.map +1 -0
- package/dist/state/rework-manager.js +126 -0
- package/dist/state/rework-manager.js.map +1 -0
- package/dist/state/rework-manager.test.d.ts +2 -0
- package/dist/state/rework-manager.test.d.ts.map +1 -0
- package/dist/state/rework-manager.test.js +191 -0
- package/dist/state/rework-manager.test.js.map +1 -0
- package/dist/state/state-manager.d.ts +13 -0
- package/dist/state/state-manager.d.ts.map +1 -1
- package/dist/state/state-manager.js +39 -2
- package/dist/state/state-manager.js.map +1 -1
- package/dist/state/state-manager.test.js +74 -1
- package/dist/state/state-manager.test.js.map +1 -1
- package/dist/state/state-migration.d.ts +23 -0
- package/dist/state/state-migration.d.ts.map +1 -0
- package/dist/state/state-migration.js +144 -0
- package/dist/state/state-migration.js.map +1 -0
- package/dist/state/state-migration.test.d.ts +2 -0
- package/dist/state/state-migration.test.d.ts.map +1 -0
- package/dist/state/state-migration.test.js +451 -0
- package/dist/state/state-migration.test.js.map +1 -0
- package/dist/types/assembly.d.ts +2 -0
- package/dist/types/assembly.d.ts.map +1 -1
- package/dist/types/dependency.d.ts +2 -2
- package/dist/types/dependency.d.ts.map +1 -1
- package/dist/types/frontmatter.d.ts +100 -7
- package/dist/types/frontmatter.d.ts.map +1 -1
- package/dist/types/frontmatter.js +89 -1
- package/dist/types/frontmatter.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/lock.d.ts +1 -1
- package/dist/types/lock.d.ts.map +1 -1
- package/dist/types/rework.d.ts +36 -0
- package/dist/types/rework.d.ts.map +1 -0
- package/dist/types/rework.js +2 -0
- package/dist/types/rework.js.map +1 -0
- package/dist/utils/errors.d.ts +1 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +8 -0
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/fs.d.ts +6 -0
- package/dist/utils/fs.d.ts.map +1 -1
- package/dist/utils/fs.js +13 -0
- package/dist/utils/fs.js.map +1 -1
- package/dist/validation/config-validator.test.d.ts +2 -0
- package/dist/validation/config-validator.test.d.ts.map +1 -0
- package/dist/validation/config-validator.test.js +210 -0
- package/dist/validation/config-validator.test.js.map +1 -0
- package/dist/validation/dependency-validator.test.d.ts +2 -0
- package/dist/validation/dependency-validator.test.d.ts.map +1 -0
- package/dist/validation/dependency-validator.test.js +215 -0
- package/dist/validation/dependency-validator.test.js.map +1 -0
- package/dist/validation/frontmatter-validator.test.d.ts +2 -0
- package/dist/validation/frontmatter-validator.test.d.ts.map +1 -0
- package/dist/validation/frontmatter-validator.test.js +371 -0
- package/dist/validation/frontmatter-validator.test.js.map +1 -0
- package/dist/validation/state-validator.test.d.ts +2 -0
- package/dist/validation/state-validator.test.d.ts.map +1 -0
- package/dist/validation/state-validator.test.js +325 -0
- package/dist/validation/state-validator.test.js.map +1 -0
- package/dist/wizard/suggestion.test.d.ts +2 -0
- package/dist/wizard/suggestion.test.d.ts.map +1 -0
- package/dist/wizard/suggestion.test.js +115 -0
- package/dist/wizard/suggestion.test.js.map +1 -0
- package/dist/wizard/wizard.d.ts.map +1 -1
- package/dist/wizard/wizard.js +34 -1
- package/dist/wizard/wizard.js.map +1 -1
- package/knowledge/core/adr-craft.md +57 -0
- package/knowledge/core/ai-memory-management.md +246 -0
- package/knowledge/core/api-design.md +8 -0
- package/knowledge/core/automated-review-tooling.md +203 -0
- package/knowledge/core/claude-md-patterns.md +254 -0
- package/knowledge/core/coding-conventions.md +246 -0
- package/knowledge/core/database-design.md +8 -0
- package/knowledge/core/design-system-tokens.md +469 -0
- package/knowledge/core/dev-environment.md +223 -0
- package/knowledge/core/domain-modeling.md +8 -0
- package/knowledge/core/eval-craft.md +1008 -0
- package/knowledge/core/git-workflow-patterns.md +200 -0
- package/knowledge/core/multi-model-review-dispatch.md +250 -0
- package/knowledge/core/operations-runbook.md +40 -225
- package/knowledge/core/project-structure-patterns.md +231 -0
- package/knowledge/core/review-step-template.md +247 -0
- package/knowledge/core/{security-review.md → security-best-practices.md} +9 -1
- package/knowledge/core/system-architecture.md +5 -1
- package/knowledge/core/task-decomposition.md +174 -36
- package/knowledge/core/task-tracking.md +225 -0
- package/knowledge/core/tech-stack-selection.md +214 -0
- package/knowledge/core/testing-strategy.md +63 -70
- package/knowledge/core/user-stories.md +69 -60
- package/knowledge/core/user-story-innovation.md +70 -0
- package/knowledge/core/ux-specification.md +18 -148
- package/knowledge/execution/enhancement-workflow.md +201 -0
- package/knowledge/execution/task-claiming-strategy.md +130 -0
- package/knowledge/execution/tdd-execution-loop.md +172 -0
- package/knowledge/execution/worktree-management.md +205 -0
- package/knowledge/finalization/apply-fixes-and-freeze.md +177 -14
- package/knowledge/finalization/developer-onboarding.md +4 -0
- package/knowledge/finalization/implementation-playbook.md +83 -5
- package/knowledge/product/gap-analysis.md +5 -1
- package/knowledge/product/prd-craft.md +55 -34
- package/knowledge/product/prd-innovation.md +12 -0
- package/knowledge/product/vision-craft.md +213 -0
- package/knowledge/review/review-adr.md +44 -0
- package/knowledge/review/{review-api-contracts.md → review-api-design.md} +47 -1
- package/knowledge/review/{review-database-schema.md → review-database-design.md} +40 -1
- package/knowledge/review/review-domain-modeling.md +38 -1
- package/knowledge/review/review-implementation-tasks.md +108 -1
- package/knowledge/review/review-methodology.md +11 -0
- package/knowledge/review/review-operations.md +67 -0
- package/knowledge/review/review-prd.md +46 -0
- package/knowledge/review/review-security.md +65 -0
- package/knowledge/review/review-system-architecture.md +32 -2
- package/knowledge/review/review-testing-strategy.md +62 -0
- package/knowledge/review/review-user-stories.md +65 -0
- package/knowledge/review/{review-ux-spec.md → review-ux-specification.md} +50 -2
- package/knowledge/review/review-vision.md +255 -0
- package/knowledge/tools/release-management.md +222 -0
- package/knowledge/tools/session-analysis.md +215 -0
- package/knowledge/tools/version-strategy.md +200 -0
- package/knowledge/validation/critical-path-analysis.md +1 -1
- package/knowledge/validation/cross-phase-consistency.md +12 -0
- package/knowledge/validation/decision-completeness.md +13 -1
- package/knowledge/validation/dependency-validation.md +12 -0
- package/knowledge/validation/scope-management.md +12 -0
- package/knowledge/validation/traceability.md +12 -0
- package/methodology/README.md +37 -0
- package/methodology/custom-defaults.yml +44 -4
- package/methodology/deep.yml +43 -3
- package/methodology/mvp.yml +43 -3
- package/package.json +4 -3
- package/pipeline/architecture/review-architecture.md +36 -13
- package/pipeline/architecture/system-architecture.md +24 -9
- package/pipeline/build/multi-agent-resume.md +245 -0
- package/pipeline/build/multi-agent-start.md +236 -0
- package/pipeline/build/new-enhancement.md +456 -0
- package/pipeline/build/quick-task.md +381 -0
- package/pipeline/build/single-agent-resume.md +210 -0
- package/pipeline/build/single-agent-start.md +207 -0
- package/pipeline/consolidation/claude-md-optimization.md +76 -0
- package/pipeline/consolidation/workflow-audit.md +77 -0
- package/pipeline/decisions/adrs.md +21 -7
- package/pipeline/decisions/review-adrs.md +32 -11
- package/pipeline/environment/ai-memory-setup.md +76 -0
- package/pipeline/environment/automated-pr-review.md +76 -0
- package/pipeline/environment/design-system.md +75 -0
- package/pipeline/environment/dev-env-setup.md +68 -0
- package/pipeline/environment/git-workflow.md +73 -0
- package/pipeline/finalization/apply-fixes-and-freeze.md +17 -6
- package/pipeline/finalization/developer-onboarding-guide.md +23 -9
- package/pipeline/finalization/implementation-playbook.md +43 -14
- package/pipeline/foundation/beads.md +71 -0
- package/pipeline/foundation/coding-standards.md +71 -0
- package/pipeline/foundation/project-structure.md +73 -0
- package/pipeline/foundation/tdd.md +64 -0
- package/pipeline/foundation/tech-stack.md +74 -0
- package/pipeline/integration/add-e2e-testing.md +80 -0
- package/pipeline/modeling/domain-modeling.md +23 -8
- package/pipeline/modeling/review-domain-modeling.md +35 -11
- package/pipeline/parity/platform-parity-review.md +90 -0
- package/pipeline/planning/implementation-plan-review.md +67 -0
- package/pipeline/planning/implementation-plan.md +110 -0
- package/pipeline/pre/create-prd.md +34 -10
- package/pipeline/pre/innovate-prd.md +46 -15
- package/pipeline/pre/innovate-user-stories.md +47 -14
- package/pipeline/pre/review-prd.md +29 -8
- package/pipeline/pre/review-user-stories.md +34 -8
- package/pipeline/pre/user-stories.md +23 -8
- package/pipeline/quality/create-evals.md +106 -0
- package/pipeline/quality/operations.md +46 -17
- package/pipeline/quality/review-operations.md +32 -11
- package/pipeline/quality/review-security.md +34 -12
- package/pipeline/quality/review-testing.md +37 -14
- package/pipeline/quality/security.md +36 -10
- package/pipeline/quality/story-tests.md +75 -0
- package/pipeline/specification/api-contracts.md +28 -8
- package/pipeline/specification/database-schema.md +29 -8
- package/pipeline/specification/review-api.md +32 -11
- package/pipeline/specification/review-database.md +32 -11
- package/pipeline/specification/review-ux.md +34 -12
- package/pipeline/specification/ux-spec.md +35 -13
- package/pipeline/validation/critical-path-walkthrough.md +45 -11
- package/pipeline/validation/cross-phase-consistency.md +45 -11
- package/pipeline/validation/decision-completeness.md +45 -11
- package/pipeline/validation/dependency-graph-validation.md +46 -11
- package/pipeline/validation/implementability-dry-run.md +46 -11
- package/pipeline/validation/scope-creep-check.md +46 -11
- package/pipeline/validation/traceability-matrix.md +51 -11
- package/pipeline/vision/create-vision.md +267 -0
- package/pipeline/vision/innovate-vision.md +157 -0
- package/pipeline/vision/review-vision.md +149 -0
- package/skills/multi-model-dispatch/SKILL.md +326 -0
- package/skills/scaffold-pipeline/SKILL.md +210 -0
- package/skills/scaffold-runner/SKILL.md +619 -0
- package/pipeline/planning/implementation-tasks.md +0 -57
- package/pipeline/planning/review-tasks.md +0 -38
- package/pipeline/quality/testing-strategy.md +0 -42
|
@@ -1,257 +1,72 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: operations-runbook
|
|
3
|
-
description:
|
|
4
|
-
topics: [operations,
|
|
3
|
+
description: Deployment pipeline, deployment strategies, monitoring, alerting, and incident response
|
|
4
|
+
topics: [operations, ci-cd, deployment, monitoring, incident-response, alerting, rollback]
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Summary
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Dev Environment Reference
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Local development setup (prerequisites, env vars, one-command setup, database, hot reload, common commands, troubleshooting) is defined in `docs/dev-setup.md`, created by the Dev Setup prompt. The operations runbook should reference it rather than redefine it.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
**Operations-specific additions** (not covered by dev-setup):
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|------------|---------|-----|
|
|
17
|
-
| Node.js | 20.x LTS | Runtime |
|
|
18
|
-
| Python | 3.12+ | Backend scripts |
|
|
19
|
-
| PostgreSQL | 16+ | Primary database |
|
|
20
|
-
| Redis | 7+ | Caching and sessions |
|
|
21
|
-
| Docker | 24+ | Database containers (optional) |
|
|
15
|
+
### Environment-Specific Configuration
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
- Node.js: `nvm`, `fnm`, or `.nvmrc` for automatic version switching
|
|
25
|
-
- Python: `pyenv` with `.python-version`
|
|
26
|
-
- Ruby: `rbenv` with `.ruby-version`
|
|
17
|
+
Document how environment variables differ across environments:
|
|
27
18
|
|
|
28
|
-
|
|
19
|
+
| Variable | Local | Staging | Production |
|
|
20
|
+
|----------|-------|---------|------------|
|
|
21
|
+
| `APP_ENV` | development | staging | production |
|
|
22
|
+
| `DATABASE_URL` | localhost | staging-db-host | prod-db-host |
|
|
23
|
+
| `LOG_LEVEL` | debug | info | warn |
|
|
29
24
|
|
|
30
|
-
###
|
|
25
|
+
### Secrets Management
|
|
31
26
|
|
|
32
|
-
|
|
27
|
+
Production secrets should never be in code or `.env` files:
|
|
28
|
+
- Use a secrets manager (AWS Secrets Manager, GCP Secret Manager, Vault, Doppler)
|
|
29
|
+
- Rotate secrets on a schedule (90 days for API keys, 365 days for service accounts)
|
|
30
|
+
- Audit access to secrets
|
|
31
|
+
- Document which secrets exist, where they're stored, and who can access them
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
## Deployment Pipeline
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
# Application
|
|
38
|
-
APP_PORT=3000 # Port for the dev server
|
|
39
|
-
APP_ENV=development # development | staging | production
|
|
40
|
-
APP_URL=http://localhost:3000 # Base URL for the app
|
|
41
|
-
|
|
42
|
-
# Database
|
|
43
|
-
DATABASE_URL=postgresql://localhost:5432/myapp_dev # Local PostgreSQL
|
|
44
|
-
DATABASE_POOL_SIZE=5 # Connection pool size
|
|
45
|
-
|
|
46
|
-
# Authentication
|
|
47
|
-
JWT_SECRET=local-dev-secret-change-in-production # JWT signing key
|
|
48
|
-
SESSION_SECRET=local-session-secret # Session cookie secret
|
|
49
|
-
|
|
50
|
-
# External Services (optional for local dev)
|
|
51
|
-
# STRIPE_SECRET_KEY=sk_test_... # Uncomment when testing payments
|
|
52
|
-
# SENDGRID_API_KEY=SG.... # Uncomment when testing emails
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
**`.env`** — Actual local configuration, gitignored. Created by copying `.env.example`.
|
|
56
|
-
|
|
57
|
-
**Required vs. optional:** Clearly mark which variables are required for the app to start and which are optional (features degrade gracefully without them).
|
|
58
|
-
|
|
59
|
-
### One-Command Setup
|
|
60
|
-
|
|
61
|
-
Provide a single command that installs all dependencies, creates the database, runs migrations, seeds data, and starts the dev server:
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
# First time setup
|
|
65
|
-
make setup # or: npm run setup
|
|
66
|
-
|
|
67
|
-
# Daily development
|
|
68
|
-
make dev # or: npm run dev
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
The setup command should be idempotent — safe to run twice without breaking anything.
|
|
72
|
-
|
|
73
|
-
### Database Setup for Local Development
|
|
74
|
-
|
|
75
|
-
**Option A: Local installation**
|
|
76
|
-
- Install database server natively
|
|
77
|
-
- Create dev database: `createdb myapp_dev` (PostgreSQL)
|
|
78
|
-
- Run migrations: `make db-migrate`
|
|
79
|
-
- Seed data: `make db-seed`
|
|
80
|
-
|
|
81
|
-
**Option B: Docker Compose**
|
|
82
|
-
```yaml
|
|
83
|
-
services:
|
|
84
|
-
db:
|
|
85
|
-
image: postgres:16
|
|
86
|
-
ports: ["5432:5432"]
|
|
87
|
-
environment:
|
|
88
|
-
POSTGRES_DB: myapp_dev
|
|
89
|
-
POSTGRES_USER: postgres
|
|
90
|
-
POSTGRES_PASSWORD: postgres
|
|
91
|
-
volumes:
|
|
92
|
-
- pgdata:/var/lib/postgresql/data
|
|
93
|
-
|
|
94
|
-
redis:
|
|
95
|
-
image: redis:7
|
|
96
|
-
ports: ["6379:6379"]
|
|
97
|
-
|
|
98
|
-
volumes:
|
|
99
|
-
pgdata:
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Docker Compose is convenient for managing service dependencies but adds startup time and complexity. For simple stacks (SQLite, single service), skip Docker entirely.
|
|
103
|
-
|
|
104
|
-
**Option C: SQLite for development**
|
|
105
|
-
- No setup required
|
|
106
|
-
- Create database file on first run
|
|
107
|
-
- Fast, zero-configuration
|
|
108
|
-
- Trade-off: behavior differences from production PostgreSQL (no JSONB, different SQL dialect)
|
|
109
|
-
|
|
110
|
-
### Hot Reloading Configuration
|
|
111
|
-
|
|
112
|
-
The dev server must reload automatically when code changes:
|
|
113
|
-
|
|
114
|
-
- **Frontend:** Vite HMR (React, Vue, Svelte), Next.js Fast Refresh, or webpack HMR
|
|
115
|
-
- **Backend (Node.js):** `tsx watch`, `nodemon`, or `ts-node-dev` for TypeScript; `node --watch` for plain Node
|
|
116
|
-
- **Backend (Python):** `uvicorn --reload` (FastAPI), `flask run --debug` (Flask), `manage.py runserver` (Django)
|
|
117
|
-
- **Full-stack:** Run frontend and backend concurrently with a process manager (`concurrently`, `honcho`, or Makefile with `&`)
|
|
118
|
-
|
|
119
|
-
### Common Dev Commands
|
|
120
|
-
|
|
121
|
-
Every project should have a consistent set of commands. Use whatever mechanism fits the stack:
|
|
122
|
-
|
|
123
|
-
| Command | Purpose | Implementation |
|
|
124
|
-
|---------|---------|---------------|
|
|
125
|
-
| `make dev` | Start dev server with hot reload | Frontend + backend concurrently |
|
|
126
|
-
| `make test` | Run all tests | Test runner with coverage |
|
|
127
|
-
| `make test-watch` | Run tests in watch mode | Test runner in watch mode |
|
|
128
|
-
| `make lint` | Check code style | Linter for each language |
|
|
129
|
-
| `make format` | Auto-fix formatting | Formatter for each language |
|
|
130
|
-
| `make db-migrate` | Run pending migrations | Migration tool |
|
|
131
|
-
| `make db-seed` | Seed database with sample data | Seed script |
|
|
132
|
-
| `make db-reset` | Drop, recreate, migrate, seed | Compose the above |
|
|
133
|
-
| `make check` | Run all quality gates | lint + type-check + test |
|
|
134
|
-
|
|
135
|
-
Commands should be:
|
|
136
|
-
- Short and memorable (not `npx jest --runInBand --coverage --passWithNoTests`)
|
|
137
|
-
- Documented with help text
|
|
138
|
-
- Idempotent where possible
|
|
139
|
-
- Fast enough to run frequently
|
|
140
|
-
|
|
141
|
-
### Troubleshooting Guide
|
|
142
|
-
|
|
143
|
-
Document solutions for common development issues:
|
|
144
|
-
|
|
145
|
-
**Port already in use:**
|
|
146
|
-
```bash
|
|
147
|
-
lsof -i :3000 # Find the process
|
|
148
|
-
kill -9 <PID> # Kill it
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
**Database connection refused:**
|
|
152
|
-
- Is the database running? `pg_isready` or `docker ps`
|
|
153
|
-
- Is the connection string correct? Check `.env`
|
|
154
|
-
- Is the port correct? Check for port conflicts
|
|
155
|
-
|
|
156
|
-
**Dependencies out of sync:**
|
|
157
|
-
```bash
|
|
158
|
-
rm -rf node_modules && npm install # Node.js
|
|
159
|
-
rm -rf .venv && python -m venv .venv && pip install -r requirements.txt # Python
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
**Migrations out of date:**
|
|
163
|
-
```bash
|
|
164
|
-
make db-migrate # Run pending migrations
|
|
165
|
-
make db-reset # Nuclear option: start fresh
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
## CI/CD Pipeline
|
|
35
|
+
The base CI pipeline (lint + test on PRs) is configured by the Git Workflow prompt in `.github/workflows/ci.yml`. The operations runbook extends this with production deployment stages — it does not redefine the base CI.
|
|
169
36
|
|
|
170
37
|
### Pipeline Architecture
|
|
171
38
|
|
|
172
|
-
A CI/CD pipeline automates the path from code commit to production deployment. Design it in stages:
|
|
173
|
-
|
|
174
39
|
```
|
|
175
|
-
|
|
176
|
-
-> Stage 1: Fast checks (30s)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
-> Stage 3: Build (1-2 min)
|
|
181
|
-
|
|
182
|
-
-> Stage
|
|
183
|
-
Deploy to staging/production
|
|
184
|
-
|
|
185
|
-
PR merge to main
|
|
186
|
-
-> All stages above
|
|
187
|
-
-> Stage 5: Post-deploy verification
|
|
188
|
-
Smoke tests against deployed environment
|
|
40
|
+
Existing CI (from git-workflow — already configured):
|
|
41
|
+
-> Stage 1: Fast checks (30s) — lint, format, type check
|
|
42
|
+
-> Stage 2: Tests (2-5 min) — unit + integration in parallel
|
|
43
|
+
|
|
44
|
+
Operations adds (main branch only):
|
|
45
|
+
-> Stage 3: Build (1-2 min) — compile, bundle, generate artifacts
|
|
46
|
+
-> Stage 4: Deploy (2-5 min) — deploy to staging/production
|
|
47
|
+
-> Stage 5: Post-deploy verification — smoke tests
|
|
189
48
|
```
|
|
190
49
|
|
|
191
|
-
### Stage
|
|
192
|
-
|
|
193
|
-
**Stage 1: Fast Checks**
|
|
194
|
-
- Run on every push and PR
|
|
195
|
-
- Fail fast: if linting fails, don't bother running tests
|
|
196
|
-
- Cache dependencies between runs
|
|
197
|
-
- Target: <30 seconds
|
|
198
|
-
|
|
199
|
-
```yaml
|
|
200
|
-
# GitHub Actions example
|
|
201
|
-
lint:
|
|
202
|
-
runs-on: ubuntu-latest
|
|
203
|
-
steps:
|
|
204
|
-
- uses: actions/checkout@v4
|
|
205
|
-
- uses: actions/setup-node@v4
|
|
206
|
-
with: { node-version-file: '.nvmrc' }
|
|
207
|
-
- run: npm ci --ignore-scripts
|
|
208
|
-
- run: npm run lint
|
|
209
|
-
- run: npm run type-check
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
**Stage 2: Tests**
|
|
213
|
-
- Run unit and integration tests in parallel
|
|
214
|
-
- Use a service container for the test database
|
|
215
|
-
- Upload coverage reports as artifacts
|
|
216
|
-
- Target: <5 minutes
|
|
217
|
-
|
|
218
|
-
```yaml
|
|
219
|
-
test:
|
|
220
|
-
runs-on: ubuntu-latest
|
|
221
|
-
services:
|
|
222
|
-
postgres:
|
|
223
|
-
image: postgres:16
|
|
224
|
-
env:
|
|
225
|
-
POSTGRES_DB: test
|
|
226
|
-
POSTGRES_PASSWORD: test
|
|
227
|
-
ports: ['5432:5432']
|
|
228
|
-
steps:
|
|
229
|
-
- uses: actions/checkout@v4
|
|
230
|
-
- uses: actions/setup-node@v4
|
|
231
|
-
- run: npm ci
|
|
232
|
-
- run: npm run test:ci
|
|
233
|
-
env:
|
|
234
|
-
DATABASE_URL: postgresql://postgres:test@localhost:5432/test
|
|
235
|
-
```
|
|
50
|
+
### Stage 3: Build
|
|
236
51
|
|
|
237
|
-
**Stage 3: Build**
|
|
238
52
|
- Compile TypeScript, bundle frontend assets, generate Docker image
|
|
239
53
|
- Verify the build artifact is valid (start the server and check health endpoint)
|
|
240
54
|
- Store the build artifact for deployment
|
|
55
|
+
- Only runs after Stages 1-2 pass
|
|
56
|
+
|
|
57
|
+
### Stage 4: Deploy
|
|
241
58
|
|
|
242
|
-
**Stage 4: Deploy**
|
|
243
59
|
- Only runs on main branch (after PR merge)
|
|
244
60
|
- Deploy the build artifact from Stage 3
|
|
245
61
|
- Run database migrations before starting new version
|
|
246
62
|
- Verify health check after deployment
|
|
247
63
|
|
|
248
|
-
###
|
|
249
|
-
|
|
250
|
-
**Parallel jobs:** Run lint, unit tests, and integration tests as separate parallel jobs. The total pipeline time equals the longest individual job, not the sum.
|
|
251
|
-
|
|
252
|
-
**Dependency caching:** Cache `node_modules/` (keyed by `package-lock.json` hash), Python virtual environments, Docker layer cache. This turns a 60-second install into a 5-second cache restore.
|
|
64
|
+
### Stage 5: Post-Deploy Verification
|
|
253
65
|
|
|
254
|
-
|
|
66
|
+
- Run smoke tests against the deployed environment
|
|
67
|
+
- Verify critical user flows work end-to-end
|
|
68
|
+
- Check external dependency connectivity
|
|
69
|
+
- If smoke tests fail: trigger automatic rollback
|
|
255
70
|
|
|
256
71
|
### Artifact Management
|
|
257
72
|
|
|
@@ -260,6 +75,8 @@ test:
|
|
|
260
75
|
- Tag artifacts with the git SHA for traceability
|
|
261
76
|
- Set retention policies (keep last 30 days, keep releases forever)
|
|
262
77
|
|
|
78
|
+
## Deep Guidance
|
|
79
|
+
|
|
263
80
|
## Deployment Strategies
|
|
264
81
|
|
|
265
82
|
### Blue-Green Deployment
|
|
@@ -502,8 +319,6 @@ Define service level targets for the application:
|
|
|
502
319
|
|
|
503
320
|
**Alert fatigue.** Too many alerts firing for non-critical issues. The on-call person starts ignoring alerts because most are noise. A real incident gets missed. Fix: every alert must have a clear response action. Remove alerts that routinely fire without requiring action.
|
|
504
321
|
|
|
505
|
-
**No local dev story.** "It works on the CI server" but developers can't run the application locally. Fix: document the local setup, make it one command, test it regularly by having new team members follow the instructions.
|
|
506
|
-
|
|
507
322
|
**Manual deployment steps.** Deployment requires an engineer to SSH into a server and run commands. This is error-prone, unreproducible, and blocks deployment on individual availability. Fix: fully automate deployment. A merge to main should trigger deployment automatically.
|
|
508
323
|
|
|
509
324
|
**No monitoring before launch.** Monitoring is added after the first incident, when it's most needed and least available. Fix: set up monitoring as part of the infrastructure phase, before any user traffic.
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: project-structure-patterns
|
|
3
|
+
description: Directory layout patterns by framework, module organization, and file placement rules
|
|
4
|
+
topics: [project-structure, directory-layout, module-organization, file-placement, monorepo, colocation]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Project Structure Patterns
|
|
8
|
+
|
|
9
|
+
Directory structure is the physical manifestation of architectural decisions. A well-organized project communicates its architecture through the file tree alone — a new developer should understand the system's boundaries by reading directory names. This knowledge covers core layout patterns, framework-specific conventions, and the rules that keep structures clean as projects grow.
|
|
10
|
+
|
|
11
|
+
## Summary
|
|
12
|
+
|
|
13
|
+
### Core Patterns
|
|
14
|
+
|
|
15
|
+
Three fundamental approaches to organizing source code:
|
|
16
|
+
|
|
17
|
+
1. **Feature-Based (Vertical Slices)** — Group by business domain. Each feature directory contains its own components, services, tests, and types. Best for: domain-rich applications, teams organized by feature.
|
|
18
|
+
2. **Layer-Based (Horizontal Layers)** — Group by technical concern. Separate directories for controllers, services, repositories, models. Best for: small projects, CRUD-heavy apps, teams organized by specialization.
|
|
19
|
+
3. **Hybrid** — Feature-based at the top level, layer-based within each feature. Most common in practice. Combines domain clarity with technical organization.
|
|
20
|
+
|
|
21
|
+
### The Co-Location Principle
|
|
22
|
+
|
|
23
|
+
Files that change together should live together. A feature's component, styles, tests, types, and utilities belong in the same directory — not scattered across `components/`, `styles/`, `tests/`, `types/`, and `utils/`. Co-location reduces the cognitive cost of changes.
|
|
24
|
+
|
|
25
|
+
### The Shared Code Rule
|
|
26
|
+
|
|
27
|
+
Code belongs in a shared directory (`shared/`, `common/`, `lib/`) only when it has 2 or more consumers. A "shared" utility used by one feature is misplaced — it belongs in that feature's directory. Premature extraction into shared code creates coupling without benefit.
|
|
28
|
+
|
|
29
|
+
### When to Restructure
|
|
30
|
+
|
|
31
|
+
Restructure when: navigation becomes difficult (too many files in one directory), features are tangled (changing one feature touches many directories), or onboarding developers consistently get lost. Do not restructure for aesthetic reasons or because a blog post recommended a different layout.
|
|
32
|
+
|
|
33
|
+
### Test Placement
|
|
34
|
+
|
|
35
|
+
Co-located tests (`service.test.ts` next to `service.ts`) for unit tests — easy to find, move with refactors. Mirror directory (`tests/` mirroring `src/`) for integration and E2E tests that span modules.
|
|
36
|
+
|
|
37
|
+
### Config vs. Application Code
|
|
38
|
+
|
|
39
|
+
Tooling config files (`tsconfig.json`, `eslint.config.js`, `Makefile`) live at project root by convention. Application config (`src/config/`) holds runtime settings (database URLs, feature flags). Never mix the two locations.
|
|
40
|
+
|
|
41
|
+
## Deep Guidance
|
|
42
|
+
|
|
43
|
+
### Feature-Based Structure
|
|
44
|
+
|
|
45
|
+
Feature-based organization maps directly to the product's domain model:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
src/
|
|
49
|
+
features/
|
|
50
|
+
auth/
|
|
51
|
+
components/LoginForm.tsx, LoginForm.test.tsx
|
|
52
|
+
hooks/useAuth.ts, useAuth.test.ts
|
|
53
|
+
services/auth-service.ts, auth-service.test.ts
|
|
54
|
+
types.ts
|
|
55
|
+
index.ts # public API barrel — other features import from here
|
|
56
|
+
billing/
|
|
57
|
+
components/, hooks/, services/, types.ts, index.ts
|
|
58
|
+
shared/
|
|
59
|
+
components/ # truly shared: Button, Modal, Input
|
|
60
|
+
hooks/ # truly shared: useDebounce, useLocalStorage
|
|
61
|
+
utils/ # truly shared: formatDate, validateEmail
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**The index.ts barrel** defines each feature's public API. Other features import from `@/features/auth`, never from internal paths. This creates explicit boundaries — internal refactoring cannot break consumers.
|
|
65
|
+
|
|
66
|
+
**When it breaks down**: Heavy cross-cutting concerns (every feature needs auth context, analytics, error boundaries). Solution: shared infrastructure lives in `shared/` or `infrastructure/`.
|
|
67
|
+
|
|
68
|
+
### Layer-Based Structure
|
|
69
|
+
|
|
70
|
+
Layer-based organization mirrors the technical architecture:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
src/
|
|
74
|
+
controllers/auth-controller.ts, billing-controller.ts
|
|
75
|
+
services/auth-service.ts, billing-service.ts
|
|
76
|
+
repositories/user-repository.ts, invoice-repository.ts
|
|
77
|
+
models/user.ts, invoice.ts
|
|
78
|
+
middleware/auth-middleware.ts, logging-middleware.ts
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Clear dependency direction: controllers depend on services, services on repositories, never reverse. Breaks down beyond ~20 files per directory — that signals the need for feature grouping.
|
|
82
|
+
|
|
83
|
+
### Framework-Specific Patterns
|
|
84
|
+
|
|
85
|
+
#### Next.js (App Router)
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
app/
|
|
89
|
+
layout.tsx, page.tsx
|
|
90
|
+
(auth)/login/page.tsx, signup/page.tsx # route group (no URL segment)
|
|
91
|
+
dashboard/layout.tsx, page.tsx, settings/page.tsx
|
|
92
|
+
api/users/route.ts
|
|
93
|
+
src/features/, src/shared/
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Conventions: `page.tsx` defines routes, `layout.tsx` for nested layouts, `loading.tsx` for suspense, `error.tsx` for error boundaries. Route groups `(name)` organize without URL impact. Server Components default — mark `'use client'` explicitly.
|
|
97
|
+
|
|
98
|
+
#### Express / Fastify
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
src/
|
|
102
|
+
routes/auth.routes.ts, index.ts # route definitions (thin)
|
|
103
|
+
handlers/auth.handler.ts # request/response logic
|
|
104
|
+
services/, repositories/, models/, middleware/
|
|
105
|
+
app.ts, server.ts
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Separate routes from handlers. Routes define paths and middleware chains. Handlers contain logic and are independently testable.
|
|
109
|
+
|
|
110
|
+
#### FastAPI
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
src/app/
|
|
114
|
+
routers/auth.py, billing.py
|
|
115
|
+
services/, repositories/
|
|
116
|
+
models/ # Pydantic schemas
|
|
117
|
+
db/ # SQLAlchemy models
|
|
118
|
+
core/config.py, security.py, dependencies.py
|
|
119
|
+
main.py
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Convention: `routers/` not `routes/`. Pydantic models for API schemas, separate ORM models for database. Dependency injection via `Depends()`.
|
|
123
|
+
|
|
124
|
+
#### Go
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
cmd/server/main.go, cli/main.go
|
|
128
|
+
internal/
|
|
129
|
+
auth/handler.go, service.go, repository.go, handler_test.go
|
|
130
|
+
billing/...
|
|
131
|
+
platform/postgres/, redis/, http/
|
|
132
|
+
pkg/validate/, money/
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Convention: `cmd/` for entry points, `internal/` for private code (compiler-enforced), `pkg/` for reusable libraries. Flat package structure preferred.
|
|
136
|
+
|
|
137
|
+
### Monorepo Patterns
|
|
138
|
+
|
|
139
|
+
Use a monorepo when packages share types/utilities, you need atomic cross-package changes, or packages are tightly coupled. Do not use when packages are independently deployable with no shared code.
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
packages/
|
|
143
|
+
web/src/, package.json
|
|
144
|
+
api/src/, package.json
|
|
145
|
+
shared/src/, package.json
|
|
146
|
+
config/eslint-base.js, tsconfig-base.json
|
|
147
|
+
package.json # workspace configuration
|
|
148
|
+
turbo.json # build orchestration
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Packages import from `@myorg/shared`, never from relative paths across package boundaries. Workspace resolution handles local development.
|
|
152
|
+
|
|
153
|
+
### The Hybrid Pattern — Detailed Example
|
|
154
|
+
|
|
155
|
+
The hybrid approach is the most practical for medium-to-large applications. Features at the top, layers within:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
src/
|
|
159
|
+
features/
|
|
160
|
+
auth/
|
|
161
|
+
controller.ts # HTTP handler / route handler
|
|
162
|
+
service.ts # Business logic
|
|
163
|
+
repository.ts # Data access
|
|
164
|
+
model.ts # Domain types
|
|
165
|
+
service.test.ts # Unit tests co-located
|
|
166
|
+
controller.test.ts
|
|
167
|
+
billing/
|
|
168
|
+
controller.ts
|
|
169
|
+
service.ts
|
|
170
|
+
repository.ts
|
|
171
|
+
model.ts
|
|
172
|
+
...
|
|
173
|
+
shared/
|
|
174
|
+
middleware/ # Cross-cutting: auth, logging, rate-limit
|
|
175
|
+
utils/ # Truly shared utilities (2+ consumers)
|
|
176
|
+
types/ # Shared type definitions
|
|
177
|
+
config/ # Application configuration
|
|
178
|
+
app.ts # Application bootstrap
|
|
179
|
+
server.ts # Server entry point
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Each feature is self-contained. Adding a new feature means creating a new directory — no changes to existing features. Deleting a feature means removing one directory (plus cleanup of any shared references).
|
|
183
|
+
|
|
184
|
+
### Config File Placement
|
|
185
|
+
|
|
186
|
+
Config files live in the project root by universal convention: `package.json`, `tsconfig.json`, `eslint.config.js`, `pyproject.toml`, `go.mod`, `Makefile`, `Dockerfile`. Do not move them into a `config/` directory — tooling expects them at root. Application configuration (database URLs, feature flags) belongs in `src/config/`.
|
|
187
|
+
|
|
188
|
+
### Generated File Handling
|
|
189
|
+
|
|
190
|
+
Generated files (API clients, GraphQL types, migrations) need special treatment:
|
|
191
|
+
- **Dedicated directory**: `src/generated/` or `__generated__/` — clearly non-hand-edited
|
|
192
|
+
- **Linter exclusion**: `**/generated/**` excluded from lint configs
|
|
193
|
+
- **Regeneration command**: `make generate` documented in CLAUDE.md
|
|
194
|
+
- **Git decision**: Generated-from-committed-specs can be gitignored; generated-from-external-sources should be committed
|
|
195
|
+
|
|
196
|
+
### Entry Points and Barrel Files
|
|
197
|
+
|
|
198
|
+
**Entry points** (`main.ts`, `server.ts`, `index.ts` at project root, route files) are imported by the framework, not by other source files. Structure evals must exclude them from orphan detection.
|
|
199
|
+
|
|
200
|
+
**Barrel files** (`index.ts` in feature directories) re-export the feature's public API. Rules:
|
|
201
|
+
- One barrel per feature directory
|
|
202
|
+
- Only re-export what other features need — internal utilities stay unexported
|
|
203
|
+
- Never create barrel files in leaf directories (they add indirection without value)
|
|
204
|
+
- Avoid circular dependencies by keeping barrel imports one-directional (features import from shared, never reverse)
|
|
205
|
+
|
|
206
|
+
### Common Anti-Patterns
|
|
207
|
+
|
|
208
|
+
**God Directories**: `src/utils/` has 47 files, `src/components/` has 93. Fix: move utilities into their consuming features. Only genuinely shared items (3+ consumers) stay in `shared/`.
|
|
209
|
+
|
|
210
|
+
**Premature Abstraction into Shared**: Creating `shared/formatCurrency.ts` "because someone might need it later." Fix: enforce the 2+ consumer rule. Code enters `shared/` only when a second consumer actually needs it.
|
|
211
|
+
|
|
212
|
+
**Inconsistent Depth**: 5-level nesting next to 2-level nesting. Fix: define maximum nesting depth (3-4 levels from `src/`). Deep nesting signals a feature should be split.
|
|
213
|
+
|
|
214
|
+
**Orphaned Files**: Files not imported by anything and not entry points, accumulated during refactors. Fix: structure evals detect orphans in CI.
|
|
215
|
+
|
|
216
|
+
### Migration Between Structures
|
|
217
|
+
|
|
218
|
+
Moving from layer-based to feature-based (the most common migration):
|
|
219
|
+
|
|
220
|
+
1. Create feature directories alongside existing layers
|
|
221
|
+
2. Move one feature at a time — start with the most self-contained (fewest cross-feature dependencies)
|
|
222
|
+
3. Update imports as you move — no redirect files
|
|
223
|
+
4. Verify tests pass after each feature migration
|
|
224
|
+
5. Delete empty layer directories once all features extracted
|
|
225
|
+
6. Update `docs/project-structure.md`
|
|
226
|
+
|
|
227
|
+
Move one feature per PR. Each PR leaves the project working with passing tests. Five small PRs over a week is safer than one massive PR touching every file.
|
|
228
|
+
|
|
229
|
+
## See Also
|
|
230
|
+
|
|
231
|
+
- [system-architecture](../core/system-architecture.md) — Architecture manifests in file structure
|