@rashidee/co2 1.3.12 → 1.3.13

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.
Binary file
Binary file
Binary file
package/dist/index.js CHANGED
@@ -6809,7 +6809,7 @@ var {
6809
6809
  // package.json
6810
6810
  var package_default = {
6811
6811
  name: "@rashidee/co2",
6812
- version: "1.3.12",
6812
+ version: "1.3.13",
6813
6813
  description: "Compound Context Studio \u2014 self-hosted team context authoring for CO2 projects",
6814
6814
  type: "module",
6815
6815
  license: "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rashidee/co2",
3
- "version": "1.3.12",
3
+ "version": "1.3.13",
4
4
  "description": "Compound Context Studio — self-hosted team context authoring for CO2 projects",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -12,7 +12,7 @@
12
12
  "name": "co2-skills",
13
13
  "source": "./",
14
14
  "description": "Compound Context Skills — generates data models, HTML mockups, technical specifications, test specifications, and orchestrates full-stack development from Agile user stories.",
15
- "version": "1.6.0",
15
+ "version": "1.7.0",
16
16
  "author": {
17
17
  "name": "Rashidee M.Rashid"
18
18
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "co2-skills",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Compound Context Skills — an opinionated context engineering methodology for AI-driven software development. Generates data models, HTML mockups, technical specifications, test specifications, and orchestrates full-stack development from Agile user stories.",
5
5
  "author": {
6
6
  "name": "Rashidee M.Rashid"
package/plugin/README.md CHANGED
@@ -229,6 +229,7 @@ Example skill invocation for technical specification generation:
229
229
  /specgen-flutter-riverpod <app_name> ## For generating Flutter 3 mobile application technical specification with Riverpod, Hive, Dio, go_router and Firebase Messaging.
230
230
  /specgen-ts-cli <app_name> ## For generating Node.js CLI application technical specification with TypeScript, Commander.js and tsup.
231
231
  /specgen-node-cli-web <app_name> ## For generating self-hosted Node.js web application technical specification distributed as a global npm CLI — Hono, embedded React SPA, Drizzle + SQLite, hand-rolled sessions and tsup.
232
+ /specgen-custom <app_name> ## For generating a technical specification for an arbitrary user-defined stack from a custom stack spec markdown (also the automatic fallback when no specgen matches).
232
233
  ~~~
233
234
 
234
235
  - Input:
@@ -556,7 +557,7 @@ We welcome contributions from the community! Here are some ways you can contribu
556
557
 
557
558
  ## Specification Generator Skills (`specgen-*`)
558
559
 
559
- This is the **highest impact area** for contribution. The CO2 workflow is designed to be technology-agnostic, but each `specgen-*` skill targets a specific technology stack. We currently support:
560
+ This is the **highest impact area** for contribution. The CO2 workflow is designed to be technology-agnostic, but each `specgen-*` skill targets a specific technology stack. Stacks not covered by a dedicated variant are served by `specgen-custom` (driven by a user-authored stack spec markdown), but a contributed stack-specific specgen always produces a deeper specification and remains preferred. We currently support:
560
561
 
561
562
  | Skill | Technology Stack |
562
563
  |-------|-----------------|
@@ -570,6 +571,7 @@ This is the **highest impact area** for contribution. The CO2 workflow is design
570
571
  | `specgen-ts-cli` | Node.js CLI + TypeScript + Commander.js + tsup + pkg |
571
572
  | `specgen-node-cli-web` | Self-hosted Node.js web app as a global npm CLI — Node 22 + commander 12 + Hono 4 + embedded React 19/Vite 6 SPA + Tailwind CSS v4 + shadcn/ui + Drizzle ORM + SQLite + hand-rolled scrypt sessions + tsup + Biome + Vitest + Playwright |
572
573
  | `specgen-sdk-java` | Java SDK library — Maven Multi-Release fat JAR (JDK 8 baseline + JDK 11+ overlay) + OkHttp |
574
+ | `specgen-custom` | Any stack described by a user-authored custom stack spec markdown (authoring template: `skills/specgen-custom/references/stack-doc-template.md`) — an explicit declaration overrides the built-in variants; also the automatic fallback when no variant matches |
573
575
 
574
576
  We are looking for contributors to create new `specgen-*` skills for other technology stacks, such as:
575
577
 
package/plugin/SKILLS.md CHANGED
@@ -237,7 +237,9 @@ All specgens share the same contract: **Invoke** `/specgen-<variant> <applicatio
237
237
  UI-bearing stacks); **Output** `context/specification/` — root `SPECIFICATION.md` + one
238
238
  self-contained `SPEC.md` per module (or per command for CLI stacks), with complete code
239
239
  samples and traceability tables. **Pick exactly ONE variant, matching the application's
240
- technology stack** (declared in `CLAUDE.md` / PRD Architecture Principle):
240
+ technology stack** (declared in `CLAUDE.md` / PRD Architecture Principle). A custom stack
241
+ spec declared as ``Stack per custom stack spec at `<path>` `` always wins over the built-in
242
+ variants, and `specgen-custom` is the fallback when nothing matches:
241
243
 
242
244
  | Skill | Pick when the application is… |
243
245
  |-------|-------------------------------|
@@ -250,6 +252,7 @@ technology stack** (declared in `CLAUDE.md` / PRD Architecture Principle):
250
252
  | `specgen-ts-cli` | Distributable Node.js CLI **tool** (TypeScript 5, Commander 12, tsup, Zod, chalk/ora; optional prompts, conf/cosmiconfig, SQLite, execa, got, @yao-pkg/pkg binaries) — terminal-only, no web UI |
251
253
  | `specgen-node-cli-web` | Self-hosted **web application distributed as a global npm CLI** — installed `npm i -g`, started `<app> start`, opened at `http://IP:PORT`. Single Node 22 process: Hono 4 API + embedded pre-built React 19/Vite 6 SPA (Tailwind v4, shadcn/ui), Drizzle + SQLite, hand-rolled scrypt sessions with first-run admin + forced password change, tsup, Biome, Vitest + Playwright with built-binary smoke test |
252
254
  | `specgen-sdk-java` | Java SDK **library** wrapping a remote REST API — Maven Multi-Release fat JAR, JDK 8 baseline + JDK 11+ overlay, OkHttp as sole runtime dependency |
255
+ | `specgen-custom` | ANY other stack — driven by a user-authored custom stack spec markdown (declared in PRD.md/CLAUDE.md as ``Stack per custom stack spec at `<path>` ``, authoring template in `references/stack-doc-template.md`). An explicit declaration OVERRIDES the built-in variants; also the automatic fallback (with `[TODO]`-annotated defaults) when no variant matches |
253
256
 
254
257
  > **`specgen-ts-cli` vs `specgen-node-cli-web`:** if the deliverable is a terminal tool with
255
258
  > commands and flags → `specgen-ts-cli`. If the deliverable is a browser-accessed web app that
@@ -406,7 +409,7 @@ implemented** (empty stub — no SKILL.md). Do not invoke; fall back to `specgen
406
409
  | "prepare everything for development" | `conductor-feature-prepare` |
407
410
  | "design the data model / ERD" | `modelgen-relational` or `modelgen-nosql` (by datastore) |
408
411
  | "generate mockups / UI screens" | `mockgen-tailwind` or `mockgen-shadcn` (by stack) |
409
- | "write the technical spec" | the ONE `specgen-*` matching the stack (see table) |
412
+ | "write the technical spec" | the ONE `specgen-*` matching the stack (see table); a declared custom stack spec → `specgen-custom`, which is also the fallback when nothing matches |
410
413
  | "generate the test plan" | `testgen-functional` |
411
414
  | "set up databases/queues in k8s" | `util-preparek8senv` |
412
415
  | "plan deployment / plan cicd" | `util-plancicd` |
@@ -389,6 +389,11 @@ files to understand what has already been completed.
389
389
  version (e.g., `${APP_VERSION:1.0.4}`)
390
390
  - **config/app.php** (Laravel): Update the default in `env('APP_VERSION', '1.0.0')`
391
391
  to the new version
392
+ - **Custom / other stacks** (SPECIFICATION.md generated by `specgen-custom`): Update
393
+ the manifest file/field and environment variable named in SPECIFICATION.md's
394
+ **Application Version Configuration** subsection. If the spec names none, update
395
+ the project's primary manifest and add a `[TODO]` in IMPLEMENTATION_MASTER.md
396
+ noting the gap.
392
397
  The version displayed in the application footer (or API info endpoint) MUST reflect
393
398
  the new version after this update.
394
399
  3. Proceed to Phase 3 (Implementation) for the affected modules.
@@ -496,6 +501,8 @@ subdirectory. Instead:
496
501
  then move ALL files (including dotfiles) from that temp directory up to `<source-code-path>/`,
497
502
  then remove the empty temp directory. This avoids overwriting the existing `context/` folder.
498
503
  - For Spring Boot: Same approach — scaffold into a temp dir, then move files up.
504
+ - For any other stack whose scaffolding tool creates a nested project directory: same
505
+ temp-dir-then-move approach.
499
506
  - NEVER use the project slug/name as the target directory if it would create a nested folder.
500
507
 
501
508
  **Scaffolding Checklist** (adapt to the technology stack from SPECIFICATION.md):
@@ -511,6 +518,9 @@ subdirectory. Instead:
511
518
  - **Laravel**: Set `version` in `composer.json` and `APP_VERSION` in `.env`
512
519
  - **React / Node.js**: Set `version` in `package.json` and `VITE_APP_VERSION` in
513
520
  `.env.development` (or `APP_VERSION` in `.env` for Node.js backends)
521
+ - **Custom / other stacks**: Use the manifest file/field and environment variable named in
522
+ SPECIFICATION.md's **Application Version Configuration** subsection (a spec generated by
523
+ `specgen-custom` always names them)
514
524
  - The version in the manifest MUST match the version in the environment variable
515
525
  - For multi-version processing, this version will be updated during each version increment
516
526
  in the Phase 0 resume check
@@ -1057,6 +1067,9 @@ Extracted from IMPLEMENTATION_MASTER.md execution order and module details.>
1057
1067
  - For **Spring Boot** apps: use Maven/Gradle commands, `src/main/java` paths, `application.yml` config
1058
1068
  - For **Laravel** apps: use Composer/Artisan commands, `app/` paths, `.env` config
1059
1069
  - For **REST API** apps: omit view/template sections, focus on API endpoints and Swagger/OpenAPI docs
1070
+ - For **custom stacks** (SPECIFICATION.md generated by `specgen-custom`): every command, path
1071
+ and config reference comes from SPECIFICATION.md's Build, Run & Packaging and Project
1072
+ Structure sections — never from stack assumptions
1060
1073
  - Include only sections that are relevant to the actual specification — do NOT add sections for
1061
1074
  features that are not part of the spec (e.g., skip messaging section if no messaging is configured)
1062
1075
 
@@ -319,8 +319,10 @@ record the result for use throughout the version loop:
319
319
  decisions and resolved-file-path propagation to mockgen-* and specgen-*. No additional action
320
320
  needed; Step 1.5 is the canonical handler.
321
321
  - **`# Architecture Principle`** — Already consumed by Step 1.3 (Infer Database Type) and
322
- Step 1.7 (Infer Technology Stack) as the **primary signal** for routing decisions. Sub-skills
323
- (modelgen-*, specgen-*) read it directly from PRD.md.
322
+ Step 1.7 (Infer Technology Stack) as the **primary signal** for routing decisions. It may
323
+ also declare a custom stack spec file (``Stack per custom stack spec at `<path>` `` or a
324
+ markdown link to the stack file), which Step 1.7 treats as the **overriding** signal and
325
+ routes to `specgen-custom`. Sub-skills (modelgen-*, specgen-*) read it directly from PRD.md.
324
326
  - **`# High Level Process Flow`** — **Detect presence here** so all downstream skills are aware:
325
327
  1. Check PRD.md for a `# High Level Process Flow` section. If present, record:
326
328
  - The list of named flows (e.g., "Country submission flow", "Worker registration flow")
@@ -384,6 +386,10 @@ tracker that this skill — and any resumed Ralph Loop iteration — reads to kn
384
386
  | Spec Generator | TBD | - |
385
387
 
386
388
  > Filled in by the inference steps (1.3, 1.5, 1.7) as the pipeline runs.
389
+ > When a custom stack spec is used, record Technology Stack = "Custom (per `<path>`)" and
390
+ > Spec Generator = "specgen-custom (explicit)" or "specgen-custom (fallback)"; the Source
391
+ > column names the declaration (`PRD.md # Architecture Principle (custom stack spec)`,
392
+ > `CLAUDE.md entry (custom stack spec)`) or `fallback (no specgen matched)`.
387
393
 
388
394
  ---
389
395
 
@@ -514,31 +520,53 @@ applies to all items regardless of version.
514
520
 
515
521
  #### Step 1.7: Infer Technology Stack
516
522
 
517
- 1. **Check PRD.md `# Architecture Principle` section first** (primary signal):
523
+ 1. **Check for an explicit custom stack spec declaration first** (overrides all other signals):
524
+ - In PRD.md `# Architecture Principle`: a statement matching ``Stack per custom stack spec at `<path>` ``
525
+ or a markdown link to a custom stack spec markdown file (e.g., `[STACK.md](reference/STACK.md)`)
526
+ - Else in the application's CLAUDE.md entry (under `# Custom Applications`): the same
527
+ ``Stack per custom stack spec at `<path>` `` convention
528
+ - If found: resolve the path (relative to PRD.md first, then to the project root) and verify
529
+ the file exists — if it does NOT exist, **STOP** and report the dangling declaration to the
530
+ user. If it exists, record **Technology Stack = Custom (per `<path>`)** with the resolved
531
+ path and **skip items 2–3** — the stack doc is authoritative.
532
+ 2. **Check PRD.md `# Architecture Principle` section** (primary signal):
518
533
  - If Architecture Principle explicitly mentions a framework (e.g., "Spring Boot", "Laravel"), use it
519
534
  - If it mentions a view engine (e.g., "JTE", "Blade"), use it
520
535
  - If it mentions frontend tooling (e.g., "HTMX", "Alpine.js", "Vite"), use it
521
536
  - If it mentions architectural style (e.g., "monolithic", "REST API"), use it to disambiguate specgen variant
522
- 2. **Fallback to CLAUDE.md** (if Architecture Principle is absent or incomplete):
537
+ 3. **Fallback to CLAUDE.md** (if Architecture Principle is absent or incomplete):
523
538
  - Read application details from CLAUDE.md (already in context)
524
539
  - Identify the technology stack:
525
540
  - Framework (Laravel, Spring Boot, etc.)
526
541
  - ORM (Eloquent, JPA/Hibernate, etc.)
527
542
  - View engine (Blade, JTE, etc.)
528
543
  - Frontend enhancement (HTMX, Alpine.js, etc.)
529
- 3. Record the inferred technology stack for the next step
544
+ 4. Record the inferred technology stack (or the resolved custom stack doc path) for the next step
530
545
 
531
546
  #### Step 1.8: Generate Technical Specification
532
547
 
533
548
  1. **Check if artifacts exist**: List files in `<app_folder>/context/specification/`
534
549
  - If `.md` files already exist AND this is NOT a version increment → **SKIP** this step
535
550
  - If this IS a version increment, **proceed** to re-invoke the skill with version/module args
536
- 2. Determine the appropriate specification generator:
537
- - Check available skills matching `specgen-*` pattern
538
- - For Laravel + Eloquent + Blade + HTMX `Skill(skill: "co2-skills:specgen-laravel-eloquent-bladehtmx", args: "<app_folder> [version:<version>] [module:<module>]")`
539
- - For Spring Boot + JPA + JTE + HTMX → `Skill(skill: "co2-skills:specgen-spring-jpa-jtehtmx", args: "<app_folder> [version:<version>] [module:<module>]")`
540
- - For a self-hosted Node.js web app distributed as a global npm CLI (Hono + embedded React SPA + SQLite) → `Skill(skill: "co2-skills:specgen-node-cli-web", args: "<app_folder> [version:<version>] [module:<module>]")`
541
- - Match the skill name against the inferred technology stack components
551
+ 2. Determine the appropriate specification generator, **in this priority order**:
552
+ - **a. Explicit custom stack spec (from Step 1.7)** — if Step 1.7 resolved a custom stack doc,
553
+ use `specgen-custom` regardless of whether a built-in specgen would also match the stack:
554
+ `Skill(skill: "co2-skills:specgen-custom", args: "<app_folder> [version:<version>] [module:<module>] stack:<resolved-stack-doc-path>")`
555
+ - **b. Built-in specgen match** otherwise, check available skills matching the `specgen-*`
556
+ pattern (excluding `specgen-custom`) and match against the inferred technology stack.
557
+ Only route to a variant that actually exists as an invokable skill (has a SKILL.md):
558
+ - For Laravel + Eloquent + Blade + HTMX → `Skill(skill: "co2-skills:specgen-laravel-eloquent-bladehtmx", args: "<app_folder> [version:<version>] [module:<module>]")`
559
+ - For Spring Boot + JPA + JTE + HTMX → `Skill(skill: "co2-skills:specgen-spring-jpa-jtehtmx", args: "<app_folder> [version:<version>] [module:<module>]")`
560
+ - For a self-hosted Node.js web app distributed as a global npm CLI (Hono + embedded React SPA + SQLite) → `Skill(skill: "co2-skills:specgen-node-cli-web", args: "<app_folder> [version:<version>] [module:<module>]")`
561
+ - Match the skill name against the inferred technology stack components
562
+ - **c. No match — fallback to specgen-custom** — if NO built-in specgen matches the inferred
563
+ stack, do NOT stop and do NOT force-fit the closest variant. Invoke:
564
+ `Skill(skill: "co2-skills:specgen-custom", args: "<app_folder> [version:<version>] [module:<module>] stack-desc:\"<inferred stack summary from Step 1.7>\"")`
565
+ specgen-custom will first attempt to auto-discover a stack doc at its well-known paths
566
+ (`<app_folder>/context/reference/STACK.md`, `<app_folder>/context/STACK.md`,
567
+ `<root>/shared_context/STACK.md`); if none exists it generates from the inferred stack
568
+ description, annotating every assumption with `[TODO]`. Surface the applied defaults to
569
+ the user in the run summary.
542
570
  3. Wait for the skill to complete. The output will be specification files in `<app_folder>/context/specification/`
543
571
 
544
572
  #### Step 1.9: Generate Test Specification
@@ -0,0 +1,442 @@
1
+ ---
2
+ name: specgen-custom
3
+ model: claude-opus-4-8
4
+ effort: high
5
+ description: >
6
+ Generate a detailed technical specification for an application whose technology stack
7
+ is described by a USER-AUTHORED custom stack spec markdown file — instead of one of the
8
+ built-in stack-specific specgen-* variants. Reads the stack doc (declared in PRD.md
9
+ `# Architecture Principle` or the application's CLAUDE.md entry as "Stack per custom
10
+ stack spec at `<path>`", passed via stack:<path>, or found at well-known paths) and
11
+ produces the SAME artifact shape as every other specgen: context/specification/
12
+ SPECIFICATION.md plus one self-contained per-module SPEC.md, with complete code samples
13
+ in the stack doc's declared languages/frameworks and full traceability tables. Also
14
+ serves as the FALLBACK generator when no built-in specgen-* matches the inferred
15
+ technology stack (invoked with stack-desc:"<inferred stack>"), synthesizing a stack
16
+ definition and annotating every assumption with [TODO]. Standardized input: application
17
+ name (mandatory), version (mandatory), module (optional), stack:<path> (optional),
18
+ stack-desc:"<text>" (optional).
19
+ Use this skill whenever the user asks to create a spec for a custom, bespoke,
20
+ unsupported or "bring your own" technology stack, says "spec from my stack doc",
21
+ "use my custom stack spec", "no specgen matches my stack", or when a custom stack spec
22
+ file is declared in PRD.md/CLAUDE.md. Do NOT use this skill when a built-in specgen-*
23
+ variant matches the application's stack AND no custom stack spec is declared — the
24
+ stack-specific variant always produces a deeper specification.
25
+ ---
26
+
27
+ # Custom Stack Application Specification Generator
28
+
29
+ This skill generates a comprehensive specification document (Markdown) for an application
30
+ whose technology stack is **defined by the user**, not by a built-in `specgen-*` variant.
31
+ The spec is intended to be followed by a developer or coding agent (normally
32
+ `conductor-feature-develop`) to produce a fully functional application — without the
33
+ develop phase ever having to re-infer or guess the stack.
34
+
35
+ The specification does NOT generate code. It produces a detailed technical document
36
+ describing every layer of the application — project layout, build pipeline, data layer,
37
+ service composition, testing — so that implementation becomes a mechanical exercise.
38
+
39
+ ## Operating Modes
40
+
41
+ The skill runs in one of two modes, resolved during Stack Doc Resolution below:
42
+
43
+ - **Mode 1 — Stack-doc-driven (primary).** A custom stack spec markdown authored by the
44
+ user is resolved. That document is the **authoritative stack definition**: where the
45
+ coding agent's general stack habits or preferences conflict with the stack doc, **the
46
+ stack doc wins**. Technologies listed in the stack doc's `# Exclusions` section must
47
+ never appear in the spec.
48
+ - **Mode 2 — Inferred-stack fallback.** No stack doc exists; the invoker (normally
49
+ `conductor-feature-prepare` Step 1.8, after no built-in `specgen-*` matched) passes the
50
+ inferred stack as `stack-desc:"<free text>"`. The skill synthesizes a stack definition
51
+ from that description plus CLAUDE.md, records every assumption in the Determination
52
+ Summary, and annotates each assumption inline in the generated spec with
53
+ `[TODO: confirm — defaulted by specgen-custom]`.
54
+
55
+ ## Stack Definition Source
56
+
57
+ Unlike the stack-specific `specgen-*` variants, this skill has **no fixed technology
58
+ table and no opinionated version pins**. The Technology Stack table in the generated
59
+ `SPECIFICATION.md` is rendered from the stack doc (Mode 1) or the synthesized definition
60
+ (Mode 2) — never from this skill's own preferences.
61
+
62
+ - A library named in the stack doc without a version gets "latest stable as of the
63
+ generation date" plus a `[TODO: pin version]` marker in the spec.
64
+ - Never silently substitute a technology the stack doc names or excludes. If a stack doc
65
+ choice is unworkable (e.g., two mutually incompatible libraries), flag the conflict to
66
+ the user instead of quietly resolving it.
67
+
68
+ ## When the Skill Triggers
69
+
70
+ Generate the spec when the user (or the prepare conductor) provides an **application
71
+ name** and **version** that corresponds to one of the custom applications defined in
72
+ `CLAUDE.md`, and the application's stack is custom (declared stack doc) or unmatched by
73
+ any built-in `specgen-*` variant.
74
+
75
+ Example invocations:
76
+ - `/specgen-custom my_app v1.0.0`
77
+ - `/specgen-custom my_app v1.0.0 stack:shared_context/STACK.md`
78
+ - `/specgen-custom my_app v1.0.0 module:Inventory`
79
+ - `/specgen-custom my_app v1.0.0 stack-desc:"Go 1.23 + Gin + PostgreSQL server-rendered app"`
80
+
81
+ ## Version Gate
82
+
83
+ Before starting any work, resolve the application folder first (see Input Resolution below), then check `CHANGELOG.md` in the application folder (`<app_folder>/CHANGELOG.md`):
84
+
85
+ 1. If `<app_folder>/CHANGELOG.md` does not exist, skip this check (first-ever execution for this application).
86
+ 2. If `<app_folder>/CHANGELOG.md` exists, scan all `## vX.Y.Z` headings and determine the **highest version** using semantic versioning comparison.
87
+ 3. Compare the requested version against the highest version:
88
+ - If requested version **>=** highest version: proceed normally.
89
+ - If requested version **<** highest version: **STOP immediately**. Print: `"Version {requested} is lower than the current application version {highest} recorded in <app_folder>/CHANGELOG.md. Execution rejected."` Do NOT proceed with any work.
90
+
91
+ ## Input Resolution
92
+
93
+ This skill uses standardized input resolution. Provide:
94
+
95
+ | Argument | Required | Example | Description |
96
+ |----------|----------|---------|-------------|
97
+ | `<application>` | Yes | `my_app` | Application name to locate the context folder |
98
+ | `<version>` | Yes | `v1.0.0` | Version to scope processing |
99
+ | `module:<name>` | No | `module:Inventory` | Limit generation to a single module |
100
+ | `stack:<path>` | No | `stack:shared_context/STACK.md` | Explicit path to the custom stack spec doc |
101
+ | `stack-desc:<text>` | No | `stack-desc:"Go + Gin + PostgreSQL"` | Inferred-stack fallback description (Mode 2); used only when no stack doc resolves |
102
+
103
+ ### Application Folder Resolution
104
+
105
+ The application name is matched against root-level application folders:
106
+ 1. Strip any leading `<number>_` prefix from folder names (e.g., `1_my_app` → `my_app`)
107
+ 2. Match case-insensitively against the provided application name
108
+ 3. Accept snake_case, kebab-case, or title-case input (all match the same folder)
109
+ 4. If no match found, list available applications and stop
110
+
111
+ ### Auto-Resolved Paths
112
+
113
+ | File | Resolved Path |
114
+ |------|---------------|
115
+ | PRD.md | `<app_folder>/context/PRD.md` |
116
+ | Module Models | `<app_folder>/context/model/` |
117
+ | HTML Mockups | `<app_folder>/context/mockup/` |
118
+ | Output (specification) | `<app_folder>/context/specification/` |
119
+
120
+ ### Version Filtering
121
+
122
+ When a version is provided, only include user stories, NFRs, and constraints from versions
123
+ <= the provided version. For example, if `v1.0.4` is specified:
124
+ - Include items tagged `[v1.0.0]` through `[v1.0.4]`
125
+ - Exclude items tagged `[v1.0.5]` or later
126
+ - Version comparison uses semantic versioning order
127
+
128
+ ### Module Filtering
129
+
130
+ When `module:<name>` is provided:
131
+ - Only generate the `SPEC.md` for that specific module
132
+ - Other existing module spec files remain untouched
133
+ - `SPECIFICATION.md` (root) gets a partial update — only that module's entry in the TOC
134
+ is added or updated; all other TOC entries are preserved as-is
135
+
136
+ ## Stack Doc Resolution
137
+
138
+ Resolve the custom stack spec document in this priority order (first hit wins):
139
+
140
+ 1. **`stack:<path>` argument** — resolve relative to the project root first, then
141
+ relative to `<app_folder>`. If the argument is given but the file does not exist,
142
+ **STOP** and report the dangling path.
143
+ 2. **PRD.md `# Architecture Principle` section** — a statement matching
144
+ ``Stack per custom stack spec at `<path>` `` or any markdown link to a stack spec
145
+ markdown file (e.g., `[STACK.md](reference/STACK.md)`). Resolve the path relative to
146
+ PRD.md, then relative to the project root.
147
+ 3. **CLAUDE.md application entry** — the same ``Stack per custom stack spec at `<path>` ``
148
+ convention in the application's description under `# Custom Applications` (this
149
+ mirrors the existing "Stack per the `specgen-<variant>` CO2 specgen variant" comment
150
+ convention used for built-in variants).
151
+ 4. **Well-known paths**, checked in order:
152
+ - `<app_folder>/context/reference/STACK.md`
153
+ - `<app_folder>/context/STACK.md`
154
+ - `<project_root>/shared_context/STACK.md`
155
+ 5. **Nothing found**:
156
+ - If `stack-desc:` was provided → enter **Mode 2** (inferred-stack fallback).
157
+ - Otherwise → **STOP** and print: `"No custom stack spec found for <application>.
158
+ Copy the template at co2-skills/skills/specgen-custom/references/stack-doc-template.md
159
+ into your project (e.g., <app_folder>/context/reference/STACK.md), fill every
160
+ REQUIRED section, and declare it in PRD.md under '# Architecture Principle' as:
161
+ Stack per custom stack spec at '<path>'."`
162
+
163
+ Record the resolved mode and stack doc path — they are printed in the Determination
164
+ Summary and written into the changelog row.
165
+
166
+ ## Stack Doc Validation (Mode 1)
167
+
168
+ Validate the resolved stack doc against the template sections before generating anything.
169
+
170
+ **Required sections — STOP if missing (never guess fundamentals):**
171
+
172
+ | Section | Why it cannot be defaulted |
173
+ |---------|---------------------------|
174
+ | `# Languages & Frameworks` (with the primary framework named) | Defines the languages every code sample is written in |
175
+ | `# Architecture Style` | Defines module boundaries and layering of the whole spec |
176
+ | `# Project Layout` | Defines where every generated blueprint file lives |
177
+ | `# Build, Run & Test Commands` | conductor-feature-develop executes these verbatim |
178
+
179
+ If any required section is missing or empty, **STOP** and print a checklist of exactly
180
+ which sections must be added to the stack doc. Guessing fundamentals defeats the purpose
181
+ of a user-authored stack definition.
182
+
183
+ **Recommended sections — apply a sensible default + inline `[TODO]` when missing:**
184
+
185
+ | Section | Default when absent |
186
+ |---------|--------------------|
187
+ | Versions on individual libraries | Latest stable + `[TODO: pin version]` |
188
+ | `# Testing Stack` | The stack's dominant unit-test framework + Playwright E2E (the CO2 `testgen-functional` / develop-phase convention) |
189
+ | `# Packaging & Deployment` | Run from source + `[TODO: confirm packaging]`; primary manifest carries the app version |
190
+ | `# Coding Conventions` | The language's community standard + `[TODO: confirm conventions]` |
191
+ | `# Key Libraries` | Chosen per capability need, each choice marked `[TODO: confirm library]` |
192
+ | `# Authentication & Security` | Derived from PRD.md auth stories; if PRD has none, no auth layer |
193
+ | `# Data & Persistence` | Derived from the module model files + CLAUDE.md dependency list |
194
+
195
+ Every applied default MUST appear in **both** places:
196
+ 1. The pre-generation **Determination Summary** (so the user can override), and
197
+ 2. An inline `[TODO: confirm — defaulted by specgen-custom]` annotation at the point of
198
+ use in the generated spec.
199
+
200
+ In **Mode 2** the entire stack definition is synthesized (from `stack-desc:`, CLAUDE.md
201
+ and the model/mockup artifacts), so every table row of the Technology Stack and every
202
+ defaulted section carries the `[TODO]` convention above.
203
+
204
+ ## Gathering Input
205
+
206
+ The specification is driven by **six input sources** read from the project's context
207
+ files, plus the stack doc:
208
+
209
+ ### Input 1: Application Name (from CLAUDE.md)
210
+
211
+ From CLAUDE.md (already loaded in context), locate the target application under the
212
+ **Custom Applications** section. Extract:
213
+
214
+ - **Application name**: The section heading
215
+ - **Application description**: The description paragraph below the heading
216
+ - **Dependencies**: The "Depends on" list — external services become integration points
217
+ in the spec, wired through the mechanisms the stack doc declares (HTTP client, queue
218
+ driver, etc.)
219
+
220
+ ### Input 2: User Stories (from PRD.md)
221
+
222
+ Read `<app_folder>/context/PRD.md`. This file contains all user stories organized by
223
+ module. Extract:
224
+
225
+ - **System modules**: Modules under `# System Module` (e.g., Authentication, User
226
+ Management) — each becomes a module blueprint using the stack doc's auth approach.
227
+ - **Business modules**: Modules under `# Business Module`. Each becomes a feature area in
228
+ the stack doc's project layout and a `<module>/SPEC.md`.
229
+ - **Command/terminal-facing stories** (if the stack doc declares a CLI surface) map to
230
+ commands.
231
+
232
+ **Important:** Items with strikethrough (`~~text~~`) are deprecated — do NOT include them
233
+ as active requirements. List them in the "Removed / Replaced" subsection of the
234
+ traceability table. Track the `[v1.0.x]` version tag for each item and carry it through
235
+ to the generated specification's traceability section.
236
+
237
+ ### Input 3: Non-Functional Requirements (from PRD.md)
238
+
239
+ Each module's `### Non Functional Requirement` section informs:
240
+
241
+ - Pagination, filtering, and list-size decisions
242
+ - Validation rules (character limits, formats) → the stack doc's validation mechanism
243
+ - Performance constraints (response budgets, concurrency expectations)
244
+ - Security posture layered onto the stack doc's `# Authentication & Security` section
245
+
246
+ ### Input 4: Constraints (from PRD.md)
247
+
248
+ Each module's `### Constraint` section defines hard boundaries:
249
+
250
+ - Status enum values → schema-level enums in the stack doc's persistence layer
251
+ - Business rules → service-layer invariants with tests
252
+ - Access control (e.g., "only ADMIN can ...") → guard configuration in the stack doc's
253
+ auth mechanism
254
+
255
+ ### Input 5: Module Model (from model/ folder)
256
+
257
+ Read `<app_folder>/context/model/MODEL.md` first as the index, then the individual module
258
+ model files (e.g., `model/inventory/model.md` + `schemas.json`). The module model maps to
259
+ the **persistence layer defined in the stack doc** — ORM entities, schema definitions,
260
+ migration files, or document models, whichever the stack doc names — field-for-field, not
261
+ placeholder. If the model family (relational vs NoSQL) mismatches the stack doc's
262
+ datastore, map the structures across and note every mapping decision in the spec.
263
+
264
+ ### Input 6: HTML Mockup Screens (from mockup/ folder)
265
+
266
+ Read `<app_folder>/context/mockup/MOCKUP.html` first as the index, then the HTML files
267
+ organized by role in subfolders. The mockups map to the **UI layer defined in the stack
268
+ doc** — pages, templates, components, or views, whichever the stack doc names:
269
+
270
+ - One UI blueprint per screen, using the stack doc's UI technology
271
+ - Navigation structure and per-role menu items
272
+ - Design tokens (colors, font, radius) extracted from mockup CSS
273
+
274
+ **Role folders inform access control, NOT URL paths.** `mockup/admin/users.html` means
275
+ the route requires the `admin` role — the URL is `/users`, never `/admin/users`.
276
+
277
+ If the stack doc declares a **headless stack** (API-only, CLI, batch, library), skip this
278
+ input with an explicit note in the Determination Summary — do not invent a UI layer.
279
+
280
+ ## PRD.md Extended Sections
281
+
282
+ Before determining capabilities, check PRD.md for the following extended sections:
283
+
284
+ ### Architecture Principle Extraction
285
+
286
+ If PRD.md contains an `# Architecture Principle` section, its statements are **constraints
287
+ to honor** — unlike the stack-specific variants, this skill has no fixed architecture
288
+ model to defend. Precedence rules:
289
+
290
+ - **Technology choices**: the stack doc wins. If PRD.md names a technology the stack doc
291
+ excludes or contradicts, flag the contradiction to the user — do not silently pick one.
292
+ - **Requirements and principles** (offline-first, audit logging, deployment posture):
293
+ PRD.md wins; the spec must realize them with the stack doc's technologies.
294
+
295
+ ### Design System Extraction
296
+
297
+ If PRD.md contains a `# Design System` section with a file reference, resolve and read
298
+ it, then map design tokens into the styling mechanism the stack doc declares. If absent,
299
+ derive tokens from the mockup CSS.
300
+
301
+ ### High Level Process Flow Extraction
302
+
303
+ If PRD.md contains a `# High Level Process Flow` section, flows inform service-method
304
+ sequencing, status enums surfaced in list filters, and the E2E test scenario order.
305
+ If absent, derive flow from user stories only.
306
+
307
+ ## Determination Summary
308
+
309
+ After resolving the stack and analyzing all inputs, produce a determination summary
310
+ before generating the spec. Present it to the user for confirmation:
311
+
312
+ ```
313
+ Mode: Stack-doc-driven (Mode 1)
314
+ Stack Doc: <app_folder>/context/reference/STACK.md
315
+ Technology Stack:
316
+ <the rendered Layer | Technology | Version table>
317
+ Applied Defaults:
318
+ - Testing Stack: <framework> + Playwright E2E [TODO — stack doc section missing]
319
+ - <library> version: latest stable [TODO — unpinned in stack doc]
320
+ Capability Determination (from NFRs/stories, mapped to the stack doc's Key Libraries):
321
+ - DataGrid: yes → <library from stack doc, or [TODO: choose library]>
322
+ - Charts: no
323
+ - FileUpload: yes → <mechanism>
324
+ - Jobs: no
325
+ Modules: <list of modules to generate>
326
+ UI Layer: <UI technology, or "headless — mockup input skipped">
327
+ ```
328
+
329
+ If the user disagrees with any determination, allow them to override before proceeding.
330
+ When invoked non-interactively by `conductor-feature-prepare`, print the summary into the
331
+ run output and proceed — the `[TODO]` markers in the spec remain the review surface.
332
+
333
+ ## Generating the Specification
334
+
335
+ Once inputs are gathered and the stack is determined, generate the specification as a
336
+ **multi-file output split by module**. Read the generic spec template at
337
+ `references/spec-template.md` for the exact structure and content of each section — it is
338
+ the authoritative guide.
339
+
340
+ This skill ships **no stack pattern reference files**. Where a stack-specific variant
341
+ would read `auth-patterns.md` or `server-patterns.md`, this skill derives patterns from:
342
+
343
+ 1. The stack doc's `# Coding Conventions`, `# Key Libraries` and
344
+ `# Authentication & Security` sections, and
345
+ 2. The framework's idiomatic community patterns for anything the stack doc leaves open
346
+ (each such derivation marked `[TODO: confirm — defaulted by specgen-custom]`).
347
+
348
+ The specification is split into two categories:
349
+
350
+ 1. **Root `SPECIFICATION.md`** — TOC, project overview with the stack-doc-rendered
351
+ Technology Stack table, project structure & build configuration (including the
352
+ mandatory **Application Version Configuration** subsection), data & persistence,
353
+ application composition, authentication (if applicable), UI shell (UI stacks only),
354
+ testing strategy, and build/run/packaging.
355
+ 2. **Per-module `<module-name>/SPEC.md`** — Each module gets its own folder with a
356
+ self-contained blueprint spanning its data model, schemas/validation, service logic,
357
+ API/routes/commands, UI feature (if applicable), and tests.
358
+
359
+ An auth/user-management module SPEC.md is generated **only when** PRD.md defines
360
+ authentication/user stories or the stack doc declares an `# Authentication & Security`
361
+ section — a custom stack may legitimately be a headless API or batch application with no
362
+ auth surface. When generated, PRD story IDs merge into its traceability tables.
363
+
364
+ **Important:** The generated spec must use **real application data** from the context
365
+ files, not generic placeholders:
366
+
367
+ - **Modules** use actual module names from PRD.md and MODEL.md
368
+ - **Entities/schemas and types** match the model files field-for-field
369
+ - **Routes/commands and services** map to actual user stories
370
+ - **UI blueprints** map to actual mockup screens; URL paths are module-based, not
371
+ role-prefixed
372
+ - **Validation** enforces the actual PRD constraints
373
+ - **Version tags** on every user story ID, NFR ID, constraint ID, and mockup screen in
374
+ traceability tables (e.g., `USMA00003 [v1.0.2]`); **ALL traceability sub-tables MUST
375
+ include the `| Version |` column**
376
+ - **Removed / Replaced** subsection lists deprecated items with the removing version,
377
+ replacement ID (if any), and reason
378
+
379
+ ### Output Structure
380
+
381
+ ```
382
+ <app_folder>/context/specification/
383
+ ├── SPECIFICATION.md ← Root: TOC + shared infrastructure per the stack doc
384
+ ├── <module-1>/
385
+ │ └── SPEC.md ← Module blueprint (data + service + API/UI per the stack doc)
386
+ ├── <module-2>/
387
+ │ └── SPEC.md
388
+ └── ... ← One folder per module from PRD.md
389
+ ```
390
+
391
+ **Sample code is mandatory.** Every component described in any spec file must include a
392
+ complete, self-explanatory code sample **written in the stack doc's declared languages
393
+ and frameworks**. The code must be continuous (no `// ...` gaps) and usable as a direct
394
+ reference by a coding agent.
395
+
396
+ ## Changelog Append
397
+
398
+ After all specification files are successfully generated, append an entry to `CHANGELOG.md` in the application folder (`<app_folder>/CHANGELOG.md`):
399
+
400
+ 1. Read `<app_folder>/CHANGELOG.md`. If it does not exist, create it with:
401
+ ```markdown
402
+ # Changelog
403
+
404
+ - This file tracks all skill executions by version for this application.
405
+ - The highest version recorded here is the current application version.
406
+ - Skills MUST NOT execute for a version lower than the highest version in this file.
407
+
408
+ ---
409
+ ```
410
+ 2. Search for a `## {version}` heading matching the current version.
411
+ 3. If the section **exists**: append a new row to its table.
412
+ 4. If the section **does not exist**: insert a new section after the `---` below the context header and before any existing `## vX.Y.Z` section (newest-first ordering), with a new table header and the first row.
413
+ 5. Row format: `| {YYYY-MM-DD} | {application_name} | specgen-custom | {module or "All"} | Generated technical specification from custom stack spec ({stack doc path, or "inferred stack (Mode 2)"}) |`
414
+ 6. **Never modify or delete existing rows.**
415
+
416
+ ## Constraints (Non-Negotiable)
417
+
418
+ These constraints apply to the generated spec regardless of the stack. Where the coding
419
+ agent's habits conflict with them, these constraints win.
420
+
421
+ **The spec must be self-sufficient for `conductor-feature-develop`.** The develop
422
+ conductor extracts exactly these from `SPECIFICATION.md` and must find them without
423
+ consulting the stack doc:
424
+
425
+ - The **Technology Stack table** with versions (from the stack doc)
426
+ - The **Project Layout tree** with actual module names substituted
427
+ - The **Build, Run & Test Commands** verbatim from the stack doc
428
+ - An **Application Version Configuration** subsection naming the manifest file/field and
429
+ environment variable that carry the application version (from the stack doc's
430
+ `# Packaging & Deployment` section; if the stack doc names none, pick the stack's
431
+ primary manifest and mark it `[TODO: confirm version carrier]`), and how the running
432
+ application surfaces it (footer, `--version` flag, or info endpoint)
433
+
434
+ **Stack doc supremacy.** Never substitute a technology the stack doc names, never
435
+ introduce one it excludes. Conflicts are flagged to the user, not silently resolved.
436
+
437
+ **`[TODO]` greppability.** Every assumption or default must be annotated with a marker
438
+ that literally contains `[TODO` so a single grep surfaces the full review list.
439
+
440
+ **Traceability completeness.** Every user story, NFR and constraint in scope for the
441
+ requested version appears in exactly one module's traceability tables, with the
442
+ `| Version |` column present in every sub-table.
@@ -0,0 +1,271 @@
1
+ # Specification Template — Custom Stack Application
2
+
3
+ This is the authoritative template for the generated specification. It is
4
+ **stack-agnostic**: every technology-specific value is rendered from the resolved custom
5
+ stack spec doc (Mode 1) or the synthesized stack definition (Mode 2) — see SKILL.md. The
6
+ specification is split into **two types of files**:
7
+
8
+ 1. **`SPECIFICATION.md`** (root) — Table of Contents, project overview, project structure
9
+ & build configuration, data & persistence, application composition, authentication
10
+ (if applicable), UI shell (UI stacks only), testing, build/run/packaging. Generated
11
+ once per application.
12
+ 2. **`<module-name>/SPEC.md`** (per-module) — Self-contained module blueprint spanning
13
+ every layer the stack doc declares. Generated once per module from PRD.md.
14
+
15
+ ```
16
+ specification/
17
+ ├── SPECIFICATION.md
18
+ ├── <module-1>/
19
+ │ └── SPEC.md
20
+ ├── <module-2>/
21
+ │ └── SPEC.md
22
+ └── ...
23
+ ```
24
+
25
+ Placeholders use `{{VARIABLE}}` syntax and must be replaced with actual values. Sections
26
+ marked *[UI stacks only]* are omitted for headless stacks (API/CLI/batch/library);
27
+ sections marked *[if applicable]* are included only when their capability exists.
28
+
29
+ ---
30
+
31
+ # Part A: Root SPECIFICATION.md
32
+
33
+ ---
34
+
35
+ ## Table of Contents
36
+
37
+ Generate a TOC with anchor links. Include a **Modules** section linking to each module's
38
+ `SPEC.md`:
39
+
40
+ ```markdown
41
+ ## Table of Contents
42
+
43
+ ### Shared Infrastructure
44
+ - [1. Project Overview](#1-project-overview)
45
+ - [2. Project Structure & Build Configuration](#2-project-structure--build-configuration)
46
+ - ...
47
+
48
+ ### Modules
49
+ - [{{Module 1}}]({{module-1}}/SPEC.md)
50
+ - ...
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Section 1: Project Overview
56
+
57
+ ```
58
+ # {{APPLICATION_NAME}} — Technical Specification
59
+
60
+ ## 1. Project Overview
61
+
62
+ **Application Name**: {{APPLICATION_NAME}}
63
+ **Application Type**: {{web | api | cli | mobile | batch | library — from the stack doc}}
64
+ **Description**: {{APP_DESCRIPTION}}
65
+ **Versions Covered**: v1.0.0 — v{{LATEST_VERSION}}
66
+ **Stack Definition**: {{path to the custom stack spec doc, or "inferred (Mode 2) — see [TODO] markers"}}
67
+
68
+ ### Architecture Model
69
+ {{The Architecture Style from the stack doc, expanded into 1–2 paragraphs: process
70
+ model, layering, module boundary rules, communication style. Cite compatible PRD.md
71
+ Architecture Principle statements here.}}
72
+
73
+ ### Technology Stack
74
+ {{Render the full Layer | Technology | Version table from the stack doc, plus any
75
+ capability-driven additions from Key Libraries. Unpinned versions carry
76
+ [TODO: pin version]; Mode 2 rows carry [TODO: confirm — defaulted by specgen-custom].}}
77
+
78
+ ### Capability Determination (Auto-Determined from PRD)
79
+ {{The capability list from the Determination Summary — grids, charts, file upload,
80
+ background jobs, integrations — each mapped to the stack doc's Key Libraries entry or
81
+ marked [TODO: choose library].}}
82
+
83
+ ### User Roles [if applicable]
84
+ | Role | Source (mockup folder) | Capabilities summary |
85
+ |------|------------------------|----------------------|
86
+ | {{role}} | mockup/{{role}}/ | {{...}} |
87
+
88
+ ### Module Index
89
+ | Module | Spec File | {{Persistence Units}} | {{Routes / Commands / Screens}} |
90
+ |--------|-----------|----------------------|--------------------------------|
91
+ | {{Module}} | [{{module}}/SPEC.md]({{module}}/SPEC.md) | {{tables/collections/files}} | {{...}} |
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Section 2: Project Structure & Build Configuration
97
+
98
+ - Render the **Project Layout tree from the stack doc** with actual module names from
99
+ PRD.md substituted into the module slots.
100
+ - Complete, copy-pasteable **manifest and build configuration files** (whatever the stack
101
+ uses: `go.mod` + `Makefile`, `pyproject.toml`, `pom.xml`, `package.json`, ...), with
102
+ every dependency from the Technology Stack table at its pinned version.
103
+ - State the **structural rules** from the stack doc's Coding Conventions (naming,
104
+ file-size limits, error handling, forbidden patterns). Defaulted conventions carry
105
+ `[TODO: confirm conventions]`.
106
+
107
+ ### Section 2a: Application Version Configuration (MANDATORY)
108
+
109
+ This subsection is never omitted — `conductor-feature-develop` reads it on every version
110
+ increment:
111
+
112
+ - **Version carrier**: the manifest file + field ({{from the stack doc's Packaging &
113
+ Deployment section, e.g., "`version` in `pyproject.toml`"}}) MUST be set to the version
114
+ from skill invocation (highest, if multiple).
115
+ - **Environment variable**: {{e.g., APP_VERSION}} mirrors the manifest value.
116
+ - **Surfacing**: how the running application exposes the version — {{UI footer / CLI
117
+ `--version` flag / info endpoint, per application type}} — with a complete code sample.
118
+ - If the stack doc named no version carrier, name the stack's primary manifest here and
119
+ mark the choice `[TODO: confirm version carrier]`.
120
+
121
+ ---
122
+
123
+ ## Section 3: Data & Persistence
124
+
125
+ From the stack doc's Data & Persistence section and the module model files:
126
+
127
+ - Datastore, access layer (ORM / query builder / driver) and connection management —
128
+ complete configuration sample
129
+ - Migration tool and workflow (file location, generation command, when migrations run)
130
+ - The **complete schema/entity definitions** for shared/system tables; per-module tables
131
+ live in each module's SPEC.md
132
+ - If the model family (relational vs NoSQL) mismatches the stack doc's datastore, the
133
+ mapping decisions are documented here
134
+
135
+ ---
136
+
137
+ ## Section 4: Application Composition
138
+
139
+ The application's entry point and composition root, in the stack doc's framework:
140
+
141
+ - Entry point sample (main function / bootstrap / CLI program) — complete
142
+ - Middleware/interceptor order or command wiring (request ID, logging, auth resolution,
143
+ guards, routes/commands)
144
+ - Configuration loading (env vars / config file per the stack doc), validated at startup —
145
+ complete sample
146
+ - Logging setup per the stack doc's logging library
147
+ - Health/status surface ({{endpoint / command}}) used by tests and operations
148
+
149
+ ---
150
+
151
+ ## Section 5: Authentication & Security [if applicable]
152
+
153
+ Only when PRD.md defines auth stories or the stack doc declares Authentication & Security:
154
+
155
+ - The auth mechanism from the stack doc (sessions / OIDC / API keys / ...) with complete
156
+ samples: credential verification, session/token issue + resolve + revoke, guards
157
+ - Password/credential policy as validation schemas shared by UI and API
158
+ - Role model and route/command guard configuration
159
+ - Security invariants as explicit, testable statements (e.g., "cannot delete the last
160
+ admin"), each mapped to a PRD constraint ID where one exists
161
+
162
+ ---
163
+
164
+ ## Section 6: UI Shell [UI stacks only]
165
+
166
+ - The UI technology setup from the stack doc (SPA build config / template engine layout /
167
+ mobile navigation shell) — complete samples
168
+ - Design tokens from the PRD Design System file or mockup CSS, mapped into the stack
169
+ doc's styling mechanism
170
+ - Shared layout (navigation, topbar/sidebar, footer rendering `v{{VERSION}}` from the
171
+ version surface defined in Section 2a)
172
+ - Route/screen registration pattern and role-guarded navigation derived from mockup role
173
+ folders
174
+
175
+ ---
176
+
177
+ ## Section 7: Testing Strategy
178
+
179
+ From the stack doc's Testing Stack section (or the CO2 default: dominant unit framework +
180
+ Playwright E2E, marked `[TODO]` when defaulted):
181
+
182
+ - Unit/integration test setup — real persistence layer in tests where the stack allows
183
+ (in-memory / testcontainers), never a fully mocked data layer
184
+ - The mandatory coverage list: every PRD constraint invariant, auth invariants (if
185
+ applicable), and one regression assertion per `### Bug` entry in PRD.md
186
+ - E2E setup and the scenario ordering (from High Level Process Flow when present)
187
+
188
+ ---
189
+
190
+ ## Section 8: Build, Run & Packaging
191
+
192
+ - The **verbatim command table** from the stack doc (install / build / run-dev /
193
+ run-prod / test / lint) — `conductor-feature-develop` executes these as-is
194
+ - Packaging: artifact type and production run model from the stack doc's Packaging &
195
+ Deployment section
196
+ - Configuration reference: every env var / config key, type, and default
197
+
198
+ ---
199
+
200
+ # Part B: Per-Module `<module-name>/SPEC.md`
201
+
202
+ Every module file is **self-contained** — a coding agent implements it independently
203
+ after the shared infrastructure exists. Layer sections use the stack doc's layer names;
204
+ the generic names below are placeholders to be renamed accordingly (e.g., "Routes" →
205
+ "Handlers" for Gin, "Commands" for a CLI, "Screens" for mobile).
206
+
207
+ ## Template
208
+
209
+ ```
210
+ # {{MODULE_NAME}} — Module Specification
211
+
212
+ > Part of [{{APPLICATION_NAME}} Technical Specification](../SPECIFICATION.md).
213
+ > Implement after the shared infrastructure (root spec sections 2–{{N}}) is in place.
214
+
215
+ ## 1. Traceability
216
+
217
+ ### User Stories
218
+ | ID | Version | Summary | Implemented By |
219
+ |----|---------|---------|----------------|
220
+ | {{USXX00001}} | [v1.0.0] | {{summary}} | {{handler / service / screen file}} |
221
+
222
+ ### Non-Functional Requirements
223
+ | ID | Version | Requirement | Technical Decision |
224
+ |----|---------|-------------|--------------------|
225
+
226
+ ### Constraints
227
+ | ID | Version | Constraint | Enforcement Point |
228
+ |----|---------|------------|-------------------|
229
+
230
+ ### Mockup Screens [UI stacks only]
231
+ | Screen | Role | Route/Screen | Component/Template |
232
+ |--------|------|--------------|--------------------|
233
+
234
+ ### Removed / Replaced
235
+ | Removed ID | Removed In | Replaced By | Reason |
236
+ |-----------|------------|-------------|--------|
237
+
238
+ ## 2. Data Model
239
+ The module's persistence definitions (tables / collections / entities) in the stack
240
+ doc's access layer — field-for-field from the model files, with relations and the
241
+ migration file name. Complete sample.
242
+
243
+ ## 3. Schemas & Validation
244
+ The module's input/output schemas in the stack doc's validation mechanism — entity,
245
+ create/update inputs, query params — with derived types where the language supports it.
246
+ Complete sample.
247
+
248
+ ## 4. Service / Business Logic
249
+ The module's service layer — pure business logic taking the data access handle;
250
+ business rules from PRD constraints as explicit invariants. No transport concerns.
251
+ Complete sample.
252
+
253
+ ## 5. API / Routes / Commands
254
+ The module's transport surface in the stack doc's framework — every route/command with
255
+ validation, guards, and typed responses; wired into the composition root (Section 4 of
256
+ the root spec). Complete sample. Surface table: {{method+path or command}}, guard,
257
+ request schema, response, story IDs.
258
+
259
+ ## 6. UI Feature [UI stacks only]
260
+ - One UI blueprint per mockup screen in the stack doc's UI technology, matching the
261
+ mockup layout
262
+ - Forms bound to the Section 3 schemas
263
+ - Data access via the pattern defined in the root spec
264
+ - Route/screen registration + role-guarded navigation entries
265
+ Complete samples for every component.
266
+
267
+ ## 7. Tests
268
+ - Unit/integration: service + transport tests per the root Testing Strategy; every
269
+ constraint invariant has a test; every `### Bug` entry has a regression assertion
270
+ - E2E: the module's user-visible flows appended to the E2E suite [UI stacks only]
271
+ ```
@@ -0,0 +1,154 @@
1
+ <!--
2
+ CUSTOM STACK SPEC TEMPLATE (CO2 / specgen-custom)
3
+
4
+ Copy this file into your project — recommended location:
5
+ <app_folder>/context/reference/STACK.md
6
+ (also discovered at <app_folder>/context/STACK.md and <root>/shared_context/STACK.md)
7
+
8
+ Fill every REQUIRED section, then declare it in the application's PRD.md under
9
+ `# Architecture Principle` as:
10
+
11
+ Stack per custom stack spec at `context/reference/STACK.md`
12
+
13
+ (or equivalently in the application's CLAUDE.md entry under # Custom Applications).
14
+
15
+ RECOMMENDED sections may be omitted — specgen-custom will apply a sensible default and
16
+ mark it inline with [TODO: confirm — defaulted by specgen-custom] for your review.
17
+ Replace every {{placeholder}}. Delete these comment blocks when done.
18
+ -->
19
+
20
+ # Stack Overview
21
+
22
+ <!-- REQUIRED context paragraph. State the application type explicitly:
23
+ web app / REST API / CLI / mobile app / batch job / library. -->
24
+
25
+ {{One paragraph: what kind of application this stack builds, its runtime model
26
+ (single process? client + server? serverless?), and how end users run or consume it.}}
27
+
28
+ **Application type**: {{web | api | cli | mobile | batch | library}}
29
+
30
+ # Languages & Frameworks
31
+
32
+ <!-- REQUIRED. The primary framework MUST be named. Versions are strongly recommended —
33
+ unpinned entries get "latest stable" + [TODO: pin version] in the generated spec. -->
34
+
35
+ | Layer | Technology | Version |
36
+ |-------|------------|---------|
37
+ | Language | {{e.g., Go}} | {{e.g., 1.23}} |
38
+ | Framework | {{e.g., Gin}} | {{e.g., 1.10}} |
39
+ | {{Frontend / Templates}} | {{e.g., templ + HTMX}} | {{...}} |
40
+ | {{...}} | {{...}} | {{...}} |
41
+
42
+ # Architecture Style
43
+
44
+ <!-- REQUIRED. Defines the layering and module boundaries of the whole specification. -->
45
+
46
+ - {{Monolith / modular monolith / microservices / hexagonal / layered MVC ...}}
47
+ - {{Module boundary rule — e.g., "one package per business module, no cross-module
48
+ imports except through the service interfaces"}}
49
+ - {{Communication style — e.g., "server-rendered pages + HTMX partials", "JSON REST",
50
+ "gRPC between services"}}
51
+
52
+ # Project Layout
53
+
54
+ <!-- REQUIRED. Annotated directory tree. specgen-custom substitutes actual module names
55
+ from PRD.md into this layout. -->
56
+
57
+ ```
58
+ {{project-root/
59
+ ├── cmd/server/main.go # entry point
60
+ ├── internal/
61
+ │ ├── <module>/ # one package per business module
62
+ │ │ ├── handler.go
63
+ │ │ ├── service.go
64
+ │ │ └── repo.go
65
+ │ └── platform/ # shared: db, config, auth, logging
66
+ ├── migrations/ # SQL migrations
67
+ ├── web/ # templates + static assets
68
+ └── Makefile}}
69
+ ```
70
+
71
+ # Build, Run & Test Commands
72
+
73
+ <!-- REQUIRED. conductor-feature-develop runs these verbatim — they must be exact. -->
74
+
75
+ | Purpose | Command |
76
+ |---------|---------|
77
+ | Install dependencies | {{e.g., go mod download}} |
78
+ | Build | {{e.g., go build -o bin/app ./cmd/server}} |
79
+ | Run (dev) | {{e.g., go run ./cmd/server}} |
80
+ | Run (prod) | {{e.g., ./bin/app}} |
81
+ | Unit/integration tests | {{e.g., go test ./...}} |
82
+ | E2E tests | {{e.g., npx playwright test}} |
83
+ | Lint/format | {{e.g., golangci-lint run}} |
84
+
85
+ # Data & Persistence
86
+
87
+ <!-- RECOMMENDED. Default when absent: derived from the module model files and the
88
+ CLAUDE.md dependency list, marked [TODO]. -->
89
+
90
+ - **Datastore**: {{e.g., PostgreSQL 16}}
91
+ - **Access layer**: {{ORM / query builder / driver — e.g., sqlc, GORM, raw pgx}}
92
+ - **Migrations**: {{tool + workflow — e.g., "golang-migrate; files in migrations/,
93
+ applied on deploy via make migrate"}}
94
+
95
+ # Authentication & Security
96
+
97
+ <!-- RECOMMENDED. Default when absent: derived from PRD.md auth stories; omitted
98
+ entirely for headless stacks with no auth stories. -->
99
+
100
+ - **Mechanism**: {{e.g., session cookies / OIDC via Keycloak / API keys / none}}
101
+ - **Session/token handling**: {{storage, expiry, revocation}}
102
+ - **Role model**: {{roles and how routes/commands are guarded}}
103
+
104
+ # Testing Stack
105
+
106
+ <!-- RECOMMENDED. Default when absent: the stack's dominant unit-test framework +
107
+ Playwright E2E. NOTE: the CO2 pipeline (testgen-functional and the develop phase)
108
+ assumes Playwright E2E for UI-bearing applications — if your stack cannot run
109
+ Playwright (embedded, desktop-native, ...), declare the substitute here explicitly. -->
110
+
111
+ - **Unit/integration**: {{framework + conventions}}
112
+ - **E2E**: {{Playwright (CO2 default) or declared substitute}}
113
+ - **Test data**: {{fixtures / in-memory DB / testcontainers ...}}
114
+
115
+ # Key Libraries
116
+
117
+ <!-- RECOMMENDED. Capabilities not covered here get a [TODO: choose library] in the spec
118
+ when PRD NFRs demand them (grids, charts, file upload, background jobs, HTTP...). -->
119
+
120
+ | Purpose | Library | Version |
121
+ |---------|---------|---------|
122
+ | Validation | {{...}} | {{...}} |
123
+ | Logging | {{...}} | {{...}} |
124
+ | HTTP client | {{...}} | {{...}} |
125
+ | {{...}} | {{...}} | {{...}} |
126
+
127
+ # Coding Conventions
128
+
129
+ <!-- RECOMMENDED. Default when absent: the language's community standard, marked [TODO]. -->
130
+
131
+ - {{Naming conventions, file-size limits, error-handling style, typing strictness,
132
+ lint configuration, forbidden patterns}}
133
+
134
+ # Packaging & Deployment
135
+
136
+ <!-- RECOMMENDED but IMPORTANT: name the manifest file/field and environment variable
137
+ that carry the application version — conductor-feature-develop updates these on
138
+ every version increment and surfaces the version in the app footer/--version/info
139
+ endpoint. Default when absent: the stack's primary manifest + [TODO]. -->
140
+
141
+ - **Artifact**: {{e.g., single static binary / jar / npm package / container image}}
142
+ - **Version carrier**: {{manifest file + field, e.g., "version constant in
143
+ internal/platform/version.go" or "version field in pyproject.toml"}} and
144
+ {{env var, e.g., APP_VERSION}}
145
+ - **Configuration**: {{how config is supplied — env vars / config file + naming
146
+ conventions}}
147
+
148
+ # Exclusions
149
+
150
+ <!-- OPTIONAL. Technologies that must NOT appear in the generated spec, even where the
151
+ coding agent would habitually reach for them. -->
152
+
153
+ - {{e.g., No ORM — raw SQL via sqlc only}}
154
+ - {{e.g., No Docker}}