Feature Conductor — Prepare
Context artifacts preparation orchestrator — generates all context artifacts (module models,
HTML mockups, technical specifications, test specifications) needed before code implementation
can begin.
Ralph Loop Integration (AUTO-START — MANDATORY)
This skill AUTOMATICALLY starts a Ralph Loop to ensure complete artifact generation across all steps.
Without Ralph Loop, the preparation may stop prematurely due to context window limits, API
usage limits, or the agent incorrectly concluding work is "done enough". Ralph Loop ensures
the same prompt is re-fed after each session exit, and the agent picks up where it left off.
FIRST ACTION: Start Ralph Loop
BEFORE doing anything else (before Phase 0, before reading any files), you MUST invoke the
Ralph Loop skill using the Skill tool. This is a blocking requirement — do NOT proceed with
any work until Ralph Loop is active.
Invoke this immediately:
Skill(skill: "ralph-loop:ralph-loop", args: "/conductor-feature-prepare <application> [version:<version>] [module:<module>] --completion-promise \"ALL ARTIFACTS GENERATED\" --max-iterations 20")
Replace <application> and optional arguments with the actual arguments provided by the user.
Example: If the user invokes:
/conductor-feature-prepare mainapp
Then invoke:
Skill(skill: "ralph-loop:ralph-loop", args: "/conductor-feature-prepare mainapp --completion-promise \"ALL ARTIFACTS GENERATED\" --max-iterations 20")
If the user provides optional arguments:
/conductor-feature-prepare mainapp version:v2 module:user
Then invoke:
Skill(skill: "ralph-loop:ralph-loop", args: "/conductor-feature-prepare mainapp version:v2 module:user --completion-promise \"ALL ARTIFACTS GENERATED\" --max-iterations 20")
After Ralph Loop is active, proceed with Phase 0 (Resume Check) and continue normally.
How It Works
- This skill auto-starts a Ralph Loop with the orchestrator prompt as the loop body
- On each iteration, the agent checks which artifacts have already been generated
- The agent generates one or more artifacts until context runs out or all are done
- When the agent tries to exit, the Ralph Loop stop hook re-feeds the same prompt
- The next iteration resumes from where the last one left off
- When ALL artifacts are generated, the agent outputs the completion promise to exit the loop
Completion Promise
When ALL artifacts have been generated (or confirmed to already exist), output the following
promise tag to signal the Ralph Loop that preparation is finished:
<promise>ALL ARTIFACTS GENERATED</promise>
CRITICAL: Only output this promise when EVERY artifact step has completed:
- User story items tagged
- Module models generated
- HTML mockups generated
- Technical specifications generated
- Test specifications generated
Do NOT output the promise prematurely. Do NOT output it to escape the loop.
Iteration Awareness
At the START of every iteration (including the first), the agent MUST:
- Check if Ralph Loop is already active (if
.claude/ralph-loop.local.md exists, skip re-invoking)
- Read
<app_folder>/context/prepare/PREPARE_MASTER.md (the progress source of truth) if it
exists, to determine which steps and versions are already COMPLETED
- Verify against the
<app_folder>/context/ subfolders that the artifacts the tracker marks
COMPLETED actually exist (reconcile the tracker if an artifact was deleted)
- Skip steps already marked COMPLETED (unless version increment mode)
- Resume from the first incomplete step
- If the tracker's top-level status is COMPLETED (all steps for all versions done), output the
completion promise and stop
Inputs
The skill expects these arguments:
/conductor-feature-prepare <application> [version:<version>] [module:<module>]
| Argument |
Required |
Example |
Description |
<application> |
Yes |
mainapp |
Application name to locate the context folder |
version:<version> |
No |
version:v2 or version:v1,v2 or version:all |
Filter user stories and artifacts by version. Supports single version, comma-separated list, all, or omit for all versions. Multiple versions are processed sequentially in ascending semver order |
module:<module> |
No |
module:user |
If provided, process only this module. If omitted, process all modules |
Input Resolution
The application name is matched against root-level application folders:
- Strip any leading
<number>_ prefix from folder names (e.g., 1_hub_middleware → hub_middleware)
- Match case-insensitively against the provided application name
- Accept snake_case, kebab-case, or title-case input
- If no match found, list available applications and stop
Auto-Resolved Paths
| File |
Resolved Path |
| PRD.md |
<app_folder>/context/PRD.md |
| Module Models |
<app_folder>/context/model/ |
| HTML Mockups |
<app_folder>/context/mockup/ |
| Specifications |
<app_folder>/context/specification/ |
| Test Specs |
<app_folder>/context/test/ |
| References |
<app_folder>/context/reference/ |
| Preparation Tracking |
<app_folder>/context/prepare/PREPARE_MASTER.md |
Version Resolution
The version: argument supports four forms:
| Form |
Example |
Behavior |
| Single version |
version:v2 |
Process only v2 |
| Comma-separated list |
version:v1,v2,v3 |
Process each version sequentially in ascending semver order |
| Explicit all |
version:all |
Discover all versions from PRD.md, process sequentially in ascending semver order |
| Omitted |
(no version arg) |
Same as version:all |
Version Discovery
When version:all or omitted:
- Scan PRD.md for all
[vX.Y.Z] version tags across all module sections
- Collect unique versions
- Sort in ascending semantic version order (v1.0.0 < v1.0.1 < v1.1.0 < v2.0.0)
- This becomes the ordered version list for sequential processing
Sequential Version Processing Rule
Versions are ALWAYS processed one at a time, in ascending semver order. All artifacts for
version N must be fully generated (or confirmed to already exist) before version N+1 begins.
This ensures:
- Module models from earlier versions are in place before later version models are layered on
- Mockups, specifications, and test specs build incrementally on prior version artifacts
- Each version's artifacts reflect the cumulative state up to that version
Pre-Requisite: Project Information from CLAUDE.md (MANDATORY)
CLAUDE.md is automatically loaded into context at the start of every session. It contains
project details, infrastructure paths, credentials, and configuration. You do NOT need to read
it manually — the information is already available in your context.
Redo/Redevelop Guard
This guard prevents accidental re-execution of already-completed work while allowing
incremental processing of new versions. It uses a partition and filter approach, driven by
the PREPARE_MASTER.md tracker (the source of truth for what has been prepared).
Read <app_folder>/context/prepare/PREPARE_MASTER.md. If it does not exist, skip this check
(nothing has been prepared yet — every resolved version is new).
Resolve the version list (see Version Resolution).
Partition the resolved versions into two groups, using the tracker's Version Processing
Order table:
completed_versions — versions whose row is marked COMPLETED in PREPARE_MASTER.md
new_versions — versions with no row, or a row not yet COMPLETED
Decision:
new_versions |
completed_versions |
Artifacts exist? |
Action |
| Not empty |
Any (including empty) |
Yes (expected — prior versions built them) |
Proceed with new_versions only — filter out completed versions from the processing list. Existing artifacts are the base for version increment. |
| Not empty |
Any |
No |
Proceed with all resolved versions — no prior artifacts, start from scratch. |
| Empty |
Not empty |
Yes |
STOP. Print: "All requested versions ({list}) for {application} are already marked COMPLETED in <app_folder>/context/prepare/PREPARE_MASTER.md and their context artifacts still exist. To redo, first delete the existing context artifact folders (model/, mockup/, specification/, test/) and PREPARE_MASTER.md, then re-run this skill." |
| Empty |
Not empty |
No |
Proceed with all resolved versions — artifacts were cleaned up, this is a legitimate redo. |
Update the resolved version list to contain only the versions that will be processed
(either new_versions or all versions for redo). This filtered list is what the Sequential
Version Loop in Phase 1 will iterate over.
Workflow
Phase 0: Resume Check (Runs Every Ralph Loop Iteration)
This phase runs at the START of every iteration, including the first. In a Ralph Loop,
each iteration begins fresh with the same prompt, so the agent MUST check existing artifacts
to understand what has already been completed.
Auto-Start Ralph Loop — Check if .claude/ralph-loop.local.md exists. If it does NOT
exist, Ralph Loop is not yet active. Invoke it NOW using the Skill tool:
Skill(skill: "ralph-loop:ralph-loop", args: "<the full /conductor-feature-prepare invocation with args> --completion-promise \"ALL ARTIFACTS GENERATED\" --max-iterations 20")
If .claude/ralph-loop.local.md already exists, Ralph Loop is active — skip this step.
Use project information from CLAUDE.md (already in context) — extract database type,
design system, technology stack, and all infrastructure details.
Resolve the version list using the Version Resolution rules:
- Single version →
[v2]
- Comma-separated → parse and sort ascending by semver →
[v1, v2, v3]
all or omitted → scan PRD.md for ALL [vX.Y.Z] tags, deduplicate, sort ascending
Read the progress tracker <app_folder>/context/prepare/PREPARE_MASTER.md if it exists:
- It is the source of truth for which steps/versions are COMPLETED
- Reconcile it against the artifact folders below (if the tracker says COMPLETED but the
artifact is missing, reset that entry to PENDING)
- If it does NOT exist, this is a fresh start — Phase 1 Step 1.1.1 will create it
Then check which artifacts actually exist on disk:
- Check
<app_folder>/context/model/ for module model files
- Check
<app_folder>/context/mockup/ for HTML mockup files
- Check
<app_folder>/context/specification/ for spec files
- Check
<app_folder>/context/test/ for test spec files
If the tracker's top-level status is COMPLETED (all steps for all resolved versions done)
AND the artifacts still exist:
- Output
<promise>ALL ARTIFACTS GENERATED</promise> and stop
If multiple versions were resolved, proceed to Phase 1 — the version loop will determine
which versions still need processing (see Phase 1 Sequential Version Loop)
Otherwise, proceed to Phase 1, starting from the first step not marked COMPLETED in the tracker
Phase 1: Context Artifacts Generation
This phase generates all required context artifacts before code implementation begins. Each step
checks if the artifact already exists — if it does, the step is skipped. This ensures the phase
is idempotent and can be resumed safely.
IMPORTANT: If module argument was provided, pass it through to each sub-skill invocation
so that only the relevant subset of artifacts is generated.
Sequential Version Loop
Steps 1.1, 1.1.1 (tracker init) and 1.2 (tagging) are once-only setup — they run a single
time before the loop. When multiple versions are resolved (list, all, or omitted), Phase 1
wraps the per-version Steps 1.3–1.9 in a version loop:
# Once, before the loop: Step 1.1 (resolve folder), Step 1.1.1 (create PREPARE_MASTER.md),
# Step 1.2 (tag user stories)
resolved_versions = [v1.0.0, v1.0.1, v1.0.2] # ascending semver order
For each version in resolved_versions:
1. Mark this version IN PROGRESS in PREPARE_MASTER.md's Version Processing Order table
2. Run Steps 1.3–1.9 with this single version as the version argument
3. For the FIRST version: artifacts are generated from scratch (Steps 1.4–1.9)
4. For SUBSEQUENT versions: artifacts already exist from the prior version — operate in
Version Increment Mode (update, not skip)
5. All artifacts for this version must be COMPLETED (mark the version COMPLETED in the tracker)
before moving to the next version
When only a single version is resolved, the loop runs once — no behavioral difference from
the original single-version flow.
Version Increment Mode
When artifacts exist from a previous version but the current version in the loop has new/changed
user stories, Steps 1.4–1.9 operate in update mode:
- DO NOT skip steps just because artifacts already exist. The existing artifacts are from a
previous version and need to be updated with the current version's changes.
- Re-invoke ALL sub-skills (modelgen, mockgen, specgen, testgen) with BOTH the current
version
AND module arguments so they can update the existing artifacts incrementally.
- The sub-skills are responsible for reading the
[v<version>] sections in PRD.md and
updating their output files accordingly (appending new fields, modifying existing diagrams,
updating specs and test scenarios).
Bug Regression Awareness (Redo/Redevelop Scenario)
PRD.md modules may contain a ### Bug section listing previously fixed bugs (e.g.,
[BUG-024] Fixed Message ID link...). These entries represent validated fixes from prior
development cycles. When generating or updating artifacts, sub-skills MUST treat bug fix
entries as supplementary requirements:
- modelgen-*: If a bug fix involved model changes (new fields, changed relationships),
the model output must reflect the corrected structure.
- mockgen-tailwind: If a bug fix involved UI changes (layout, navigation, styling),
the mockup must reflect the corrected design.
- specgen-*: If a bug fix involved logic changes (event listeners, processing flow,
validation), the specification must include the corrected behavior.
- testgen-functional: Bug fix descriptions should inform test scenarios to ensure
regression coverage — each bug fix should have at least one corresponding test assertion.
This ensures that when an application is redeveloped from scratch, previously reported bugs
do not reappear in the new implementation.
PRD.md Extended Sections Awareness
PRD.md may contain three extended sections that influence how downstream skills are invoked
and what context they receive. Detect each section's presence at the start of Phase 1 and
record the result for use throughout the version loop:
# Design System — Already consumed by Step 1.5 (Infer Design System) for routing
decisions and resolved-file-path propagation to mockgen-* and specgen-*. No additional action
needed; Step 1.5 is the canonical handler.
# Architecture Principle — Already consumed by Step 1.3 (Infer Database Type) and
Step 1.7 (Infer Technology Stack) as the primary signal for routing decisions. Sub-skills
(modelgen-, specgen-) read it directly from PRD.md.
# High Level Process Flow — Detect presence here so all downstream skills are aware:
- Check PRD.md for a
# High Level Process Flow section. If present, record:
- The list of named flows (e.g., "Country submission flow", "Worker registration flow")
- Any external file references (e.g.,
[FLOW_DIAGRAM.md](reference/FLOW_DIAGRAM.md))
- Resolve any referenced file paths relative to PRD.md
- When invoking sub-skills in subsequent steps, pass this awareness as context so each skill
knows process flows are available and should be consulted:
- modelgen-* uses flows to identify entities/documents that participate in messaging
- specgen-* uses flows as the blueprint for service-layer methods, queue topology, and
message consumer/publisher design
- mockgen-* uses flows to determine screen-to-screen navigation and async UI states
- testgen-functional uses flows to design end-to-end test scenarios that exercise each
flow step in order
- If absent, sub-skills fall back to deriving messaging behavior from individual user stories
(existing behavior).
Record the detection result (Design System: yes/no, Architecture Principle: yes/no, Process
Flow: yes/no + flow names) in your working memory for the duration of the run. This awareness
does NOT replace each sub-skill's own reading of PRD.md — every sub-skill reads PRD.md directly,
but knowing which sections are present helps the orchestrator detect missing pre-requisites
early and surface them to the user.
Step 1.1: Resolve Application Folder
- Match the
<application> argument against root-level folders (same logic as Input Resolution)
- The resolved
<app_folder> is the root for all context artifacts
- Verify
<app_folder>/context/PRD.md exists — if not, stop with error
Step 1.1.1: Initialize Preparation Tracking (PREPARE_MASTER.md)
This step runs ONCE before the version loop starts (like tagging). It creates the progress
tracker that this skill — and any resumed Ralph Loop iteration — reads to know what is done.
- If
<app_folder>/context/prepare/PREPARE_MASTER.md already exists, read it and reconcile it
against the resolved version list (add rows for any newly-resolved versions as PENDING). Do
NOT overwrite existing COMPLETED rows.
- If it does not exist, create
<app_folder>/context/prepare/PREPARE_MASTER.md with the
structure below (pre-seed every row as PENDING; the version loop and steps below flip rows to
COMPLETED / SKIPPED as they run). Add one Artifact Generation Status table per resolved
version.
# Preparation Master - <Application Name>
**Started**: <date>
**Context**: <app_folder>/context
**Resolved Versions**: <comma-separated sorted version list, e.g., "v1.0.0, v1.0.1, v1.0.2">
**Status**: IN PROGRESS
---
## Inferred Configuration
| Aspect | Value | Source |
|--------|-------|--------|
| Database Type | TBD | - |
| Model Generator | TBD | - |
| Design System | TBD | - |
| Mockup Generator | TBD | - |
| Technology Stack | TBD | - |
| Spec Generator | TBD | - |
> Filled in by the inference steps (1.3, 1.5, 1.7) as the pipeline runs.
---
## User Story Tagging (runs ONCE, applies to all versions)
| Step | Skill | Status | Completed |
|------|-------|--------|-----------|
| 1.2 Tag items | util-ustagger | PENDING | - |
---
## Version Processing Order
| # | Version | Status | Started | Completed |
|---|---------|--------|---------|-----------|
| 1 | v1.0.0 | PENDING | - | - |
| 2 | v1.0.1 | PENDING | - | - |
> **Processing Rule**: All artifacts for version N must reach COMPLETED before version N+1 begins.
---
## Artifact Generation Status
One table per version. `SKIPPED` = artifact already existed and this is NOT a version increment.
### v1.0.0
| Step | Artifact | Skill | Status | Completed |
|------|----------|-------|--------|-----------|
| 1.4 | Module Model | modelgen-* | PENDING | - |
| 1.6 | HTML Mockups | mockgen-* | PENDING | - |
| 1.8 | Technical Spec | specgen-* | PENDING | - |
| 1.9 | Test Spec | testgen-functional | PENDING | - |
### v1.0.1
<one table per resolved version, same columns>
- Statuses used throughout:
PENDING, IN PROGRESS, COMPLETED, SKIPPED.
Tracking Updates (MANDATORY)
After each step below completes, update PREPARE_MASTER.md in place — never leave a finished step
marked PENDING. Use this mapping:
| After step |
Update in PREPARE_MASTER.md |
| 1.2 Tag User Stories |
User Story Tagging table → COMPLETED + date |
| 1.3 Infer Database Type |
Inferred Configuration → Database Type + Model Generator (with source) |
| 1.4 Generate Module Model |
current version's Artifact table → Module Model = COMPLETED (or SKIPPED) |
| 1.5 Infer Design System |
Inferred Configuration → Design System + Mockup Generator (with source) |
| 1.6 Generate HTML Mockups |
current version's Artifact table → HTML Mockups = COMPLETED (or SKIPPED) |
| 1.7 Infer Technology Stack |
Inferred Configuration → Technology Stack + Spec Generator (with source) |
| 1.8 Generate Technical Spec |
current version's Artifact table → Technical Spec = COMPLETED (or SKIPPED) |
| 1.9 Generate Test Spec |
current version's Artifact table → Test Spec = COMPLETED (or SKIPPED) |
| Version's 4 artifacts all done |
Version Processing Order → that version = COMPLETED + date; then start the next version (mark it IN PROGRESS) |
At the START of each version iteration, mark that version IN PROGRESS in the Version Processing
Order table. Mark an artifact SKIPPED (not COMPLETED) when the step is skipped because the
artifact already existed and this is not a version increment.
Step 1.2: Tag User Stories
Tag all untagged items in PRD.md with unique ID codes before any artifact generation begins.
This ensures all user stories, NFRs, constraints, and references have stable IDs that downstream
artifacts (module models, specs, tests) can reference for traceability.
This step runs ONCE before the version loop starts (not per-version), because tagging
applies to all items regardless of version.
- Determine the version label to pass:
- If processing a single version → use that version (e.g.,
v2)
- If processing multiple versions → use the HIGHEST version in the resolved list
- If no
version argument (all) → use v1 as the default
- Invoke the tagging skill:
Skill(skill: "co2-skills:util-ustagger", args: "<application> <version>")
- Example:
Skill(skill: "co2-skills:util-ustagger", args: "mainapp v1")
- Wait for the skill to complete. It will tag untagged items in-place in PRD.md.
- This step is idempotent — if all items are already tagged, the skill will report no changes.
Step 1.3: Infer Database Type
- Check PRD.md
# Architecture Principle section first (primary signal):
- If Architecture Principle explicitly mentions "document based database", "document-oriented", "NoSQL", "MongoDB", or similar → nosql
- If Architecture Principle explicitly mentions "relational database", "SQL", "PostgreSQL", "MySQL", or similar → relational
- Fallback to CLAUDE.md (if Architecture Principle is absent or does not mention database type):
- Read application details from CLAUDE.md (already in context)
- Identify the database from the application's dependency list:
- If the application depends on MySQL, PostgreSQL, or another relational database → relational
- If the application depends on MongoDB or another NoSQL database → nosql
- Record the inferred database type for the next step
Step 1.4: Generate Module Model
- Check if artifacts exist: List files in
<app_folder>/context/model/
- If
.md or .json files already exist AND this is NOT a version increment → SKIP this step
- If this IS a version increment, proceed to re-invoke the skill with version/module args
- Invoke the appropriate model generation skill:
- If database type is relational →
Skill(skill: "co2-skills:modelgen-relational", args: "<app_folder> [version:<version>] [module:<module>]")
- If database type is nosql →
Skill(skill: "co2-skills:modelgen-nosql", args: "<app_folder> [version:<version>] [module:<module>]")
- Wait for the skill to complete. The output will be module model files in
<app_folder>/context/model/
Step 1.5: Infer Design System
- Check PRD.md
# Design System section first (primary signal):
- If the section exists and references a
DESIGN_SYSTEM.md file (e.g., [DESIGN_SYSTEM.md](reference/DESIGN_SYSTEM.md)), resolve the file path relative to PRD.md
- Record the resolved design system file path for downstream skills (mockgen, specgen)
- The referenced file contains design tokens (colors, typography, components) that sub-skills will use
- Fallback to CLAUDE.md (if Design System section is absent or has no reference):
- Read application details from CLAUDE.md (already in context)
- Identify the design system / CSS framework:
- Look for mentions of Tailwind CSS, Bootstrap, Material UI, etc.
- If no design system is explicitly identified → default to Tailwind CSS
- Record the inferred design system for the next step
Step 1.6: Generate HTML Mockups
- Check if artifacts exist: List files in
<app_folder>/context/mockup/
- If
.html files already exist AND this is NOT a version increment → SKIP this step
- If this IS a version increment, proceed to re-invoke the skill with version/module args
- Determine the appropriate mockup generator:
- Check available skills matching
mockgen-* pattern
- For Tailwind CSS →
Skill(skill: "co2-skills:mockgen-tailwind", args: "<app_folder> [version:<version>] [module:<module>]")
- Default to
mockgen-tailwind if no specific generator matches the design system
- Wait for the skill to complete. The output will be HTML mockup files in
<app_folder>/context/mockup/
Step 1.7: Infer Technology Stack
- Check PRD.md
# Architecture Principle section first (primary signal):
- If Architecture Principle explicitly mentions a framework (e.g., "Spring Boot", "Laravel"), use it
- If it mentions a view engine (e.g., "JTE", "Blade"), use it
- If it mentions frontend tooling (e.g., "HTMX", "Alpine.js", "Vite"), use it
- If it mentions architectural style (e.g., "monolithic", "REST API"), use it to disambiguate specgen variant
- Fallback to CLAUDE.md (if Architecture Principle is absent or incomplete):
- Read application details from CLAUDE.md (already in context)
- Identify the technology stack:
- Framework (Laravel, Spring Boot, etc.)
- ORM (Eloquent, JPA/Hibernate, etc.)
- View engine (Blade, JTE, etc.)
- Frontend enhancement (HTMX, Alpine.js, etc.)
- Record the inferred technology stack for the next step
Step 1.8: Generate Technical Specification
- Check if artifacts exist: List files in
<app_folder>/context/specification/
- If
.md files already exist AND this is NOT a version increment → SKIP this step
- If this IS a version increment, proceed to re-invoke the skill with version/module args
- Determine the appropriate specification generator:
- Check available skills matching
specgen-* pattern
- For Laravel + Eloquent + Blade + HTMX →
Skill(skill: "co2-skills:specgen-laravel-eloquent-bladehtmx", args: "<app_folder> [version:<version>] [module:<module>]")
- For Spring Boot + JPA + JTE + HTMX →
Skill(skill: "co2-skills:specgen-spring-jpa-jtehtmx", args: "<app_folder> [version:<version>] [module:<module>]")
- 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>]")
- Match the skill name against the inferred technology stack components
- Wait for the skill to complete. The output will be specification files in
<app_folder>/context/specification/
Step 1.9: Generate Test Specification
- Check if artifacts exist: List files in
<app_folder>/context/test/
- If
.md files already exist AND this is NOT a version increment → SKIP this step
- If this IS a version increment, proceed to re-invoke the skill with version/module args
- Invoke the test specification generator:
Skill(skill: "co2-skills:testgen-functional", args: "<app_folder> [version:<version>] [module:<module>]")
- Wait for the skill to complete. The output will be test specification files in
<app_folder>/context/test/
Phase 1 Completion
After all artifacts for ALL versions in the resolved version list are generated (or confirmed
to already exist):
- Set the top-level
**Status**: in <app_folder>/context/prepare/PREPARE_MASTER.md to
COMPLETED, and verify every step and every version row is COMPLETED or SKIPPED (no
PENDING / IN PROGRESS rows remain)
- Output a summary of what was generated/skipped per version (sourced from PREPARE_MASTER.md)
- Output
<promise>ALL ARTIFACTS GENERATED</promise> to signal Ralph Loop completion
IMPORTANT — Version loop completion: The completion promise is ONLY output after the LAST
version in the resolved list has been fully processed. Do NOT output it after completing an
intermediate version — proceed to the next version immediately.
Critical Rules
CLAUDE.md is the source of truth — CLAUDE.md is automatically loaded into context. Use
it for all project details, database types, technology stacks, and infrastructure configuration.
Idempotent execution — Each step checks if artifacts already exist before generating.
This ensures the skill can be safely re-run or resumed without duplicating work.
Version increment awareness — When processing multiple versions sequentially, artifacts
from the prior version already exist when the next version begins. ALL sub-skills must be
re-invoked in update mode for each subsequent version.
Pass through filters — The current version from the version loop AND the module
argument (if provided) MUST be passed to every sub-skill invocation. Each sub-skill
receives a SINGLE version at a time, never a list.
Sequential version order — When multiple versions are resolved, they are processed
in ascending semver order. All artifacts for version N must complete before version N+1
begins. Never process versions in parallel or merge them into a single invocation.
Context window awareness (Ralph Loop handles recovery) — If approaching context limits,
the Ralph Loop will automatically re-feed the prompt, and the next iteration will resume
from the first step with missing artifacts.
Auto-start Ralph Loop — When this skill is triggered, the FIRST action (Phase 0, Step 0)
MUST be to check if Ralph Loop is active (.claude/ralph-loop.local.md exists). If not active,
invoke the Ralph Loop skill. Do NOT proceed with any work until Ralph Loop is confirmed active.
AUTONOMOUS CONTINUATION — NEVER STOP BETWEEN STEPS OR VERSIONS. This is an orchestrator
skill that runs a multi-step pipeline (Steps 1.1 through 1.9) across potentially multiple
versions. When a sub-skill (e.g., util-ustagger, modelgen-relational, mockgen-tailwind,
specgen-*, testgen-functional) completes and returns control, you MUST immediately proceed
to the NEXT step in the pipeline. When all steps for the current version are done, you MUST
immediately proceed to the NEXT version. Do NOT stop, do NOT wait for user input, do NOT
treat a sub-skill or version completion as the end of your task. The task is only complete
when ALL steps for ALL versions have been executed and the completion promise
<promise>ALL ARTIFACTS GENERATED</promise> has been output. Stopping after any
intermediate step or version is a bug in execution.
PREPARE_MASTER.md is the progress source of truth — Every step updates
<app_folder>/context/prepare/PREPARE_MASTER.md per the Tracking Updates table in Step 1.1.1.
On resume (any Ralph Loop iteration), read it FIRST to determine what is already done; do NOT
re-run steps it marks COMPLETED (unless in version increment mode). Reconcile it against the
artifact folders on disk if they disagree.
1---2name: conductor-feature-prepare3description: Context artifacts preparation orchestrator — generates all context artifacts (module models, HTML mockups, technical specifications, test specifications) by invoking the appropriate sub-skills, tracking progress in a PREPARE_MASTER.md file for cross-session resumption. Takes an application name (mandatory), with optional version and module filters. Version supports single version, comma-separated list, "all", or omit for all versions. When multiple versions are resolved, they are processed SEQUENTIALLY in ascending semver order — all artifacts for version N are fully generated before version N+1 begins. Use this skill when the user asks to "prepare artifacts", "generate context", "prepare for development", "generate models and specs", "create mockups and specs", or any request to systematically generate all context artifacts from user stories before implementation begins. Also trigger when user says "resume preparation" to continue from where a previous session left off.4---56# Feature Conductor — Prepare78Context artifacts preparation orchestrator — generates all context artifacts (module models,9HTML mockups, technical specifications, test specifications) needed before code implementation10can begin.1112## Ralph Loop Integration (AUTO-START — MANDATORY)1314This skill AUTOMATICALLY starts a Ralph Loop to ensure complete artifact generation across all steps.15Without Ralph Loop, the preparation may stop prematurely due to context window limits, API16usage limits, or the agent incorrectly concluding work is "done enough". Ralph Loop ensures17the same prompt is re-fed after each session exit, and the agent picks up where it left off.1819### FIRST ACTION: Start Ralph Loop2021**BEFORE doing anything else** (before Phase 0, before reading any files), you MUST invoke the22Ralph Loop skill using the Skill tool. This is a blocking requirement — do NOT proceed with23any work until Ralph Loop is active.2425**Invoke this immediately:**26```27Skill(skill: "ralph-loop:ralph-loop", args: "/conductor-feature-prepare <application> [version:<version>] [module:<module>] --completion-promise \"ALL ARTIFACTS GENERATED\" --max-iterations 20")28```2930Replace `<application>` and optional arguments with the actual arguments provided by the user.3132**Example:** If the user invokes:33```34/conductor-feature-prepare mainapp35```3637Then invoke:38```39Skill(skill: "ralph-loop:ralph-loop", args: "/conductor-feature-prepare mainapp --completion-promise \"ALL ARTIFACTS GENERATED\" --max-iterations 20")40```4142If the user provides optional arguments:43```44/conductor-feature-prepare mainapp version:v2 module:user45```4647Then invoke:48```49Skill(skill: "ralph-loop:ralph-loop", args: "/conductor-feature-prepare mainapp version:v2 module:user --completion-promise \"ALL ARTIFACTS GENERATED\" --max-iterations 20")50```5152After Ralph Loop is active, proceed with Phase 0 (Resume Check) and continue normally.5354### How It Works55561. This skill auto-starts a Ralph Loop with the orchestrator prompt as the loop body572. On each iteration, the agent checks which artifacts have already been generated583. The agent generates one or more artifacts until context runs out or all are done594. When the agent tries to exit, the Ralph Loop stop hook re-feeds the same prompt605. The next iteration resumes from where the last one left off616. When ALL artifacts are generated, the agent outputs the completion promise to exit the loop6263### Completion Promise6465When ALL artifacts have been generated (or confirmed to already exist), output the following66promise tag to signal the Ralph Loop that preparation is finished:6768```69<promise>ALL ARTIFACTS GENERATED</promise>70```7172**CRITICAL**: Only output this promise when EVERY artifact step has completed:73- User story items tagged74- Module models generated75- HTML mockups generated76- Technical specifications generated77- Test specifications generated7879Do NOT output the promise prematurely. Do NOT output it to escape the loop.8081### Iteration Awareness8283At the START of every iteration (including the first), the agent MUST:841. Check if Ralph Loop is already active (if `.claude/ralph-loop.local.md` exists, skip re-invoking)852. Read `<app_folder>/context/prepare/PREPARE_MASTER.md` (the progress source of truth) if it86 exists, to determine which steps and versions are already COMPLETED873. Verify against the `<app_folder>/context/` subfolders that the artifacts the tracker marks88 COMPLETED actually exist (reconcile the tracker if an artifact was deleted)894. Skip steps already marked COMPLETED (unless version increment mode)905. Resume from the first incomplete step916. If the tracker's top-level status is COMPLETED (all steps for all versions done), output the92 completion promise and stop9394## Inputs9596The skill expects these arguments:9798```99/conductor-feature-prepare <application> [version:<version>] [module:<module>]100```101102| Argument | Required | Example | Description |103|----------|----------|---------|-------------|104| `<application>` | Yes | `mainapp` | Application name to locate the context folder |105| `version:<version>` | No | `version:v2` or `version:v1,v2` or `version:all` | Filter user stories and artifacts by version. Supports single version, comma-separated list, `all`, or omit for all versions. Multiple versions are processed sequentially in ascending semver order |106| `module:<module>` | No | `module:user` | If provided, process only this module. If omitted, process all modules |107108### Input Resolution109110The application name is matched against root-level application folders:1111. Strip any leading `<number>_` prefix from folder names (e.g., `1_hub_middleware` → `hub_middleware`)1122. Match case-insensitively against the provided application name1133. Accept snake_case, kebab-case, or title-case input1144. If no match found, list available applications and stop115116### Auto-Resolved Paths117118| File | Resolved Path |119|------|---------------|120| PRD.md | `<app_folder>/context/PRD.md` |121| Module Models | `<app_folder>/context/model/` |122| HTML Mockups | `<app_folder>/context/mockup/` |123| Specifications | `<app_folder>/context/specification/` |124| Test Specs | `<app_folder>/context/test/` |125| References | `<app_folder>/context/reference/` |126| Preparation Tracking | `<app_folder>/context/prepare/PREPARE_MASTER.md` |127128### Version Resolution129130The `version:` argument supports four forms:131132| Form | Example | Behavior |133|------|---------|----------|134| Single version | `version:v2` | Process only v2 |135| Comma-separated list | `version:v1,v2,v3` | Process each version sequentially in ascending semver order |136| Explicit all | `version:all` | Discover all versions from PRD.md, process sequentially in ascending semver order |137| Omitted | _(no version arg)_ | Same as `version:all` |138139#### Version Discovery140141When `version:all` or omitted:1421. Scan PRD.md for all `[vX.Y.Z]` version tags across all module sections1432. Collect unique versions1443. Sort in ascending semantic version order (v1.0.0 < v1.0.1 < v1.1.0 < v2.0.0)1454. This becomes the ordered version list for sequential processing146147#### Sequential Version Processing Rule148149**Versions are ALWAYS processed one at a time, in ascending semver order.** All artifacts for150version N must be fully generated (or confirmed to already exist) before version N+1 begins.151This ensures:152- Module models from earlier versions are in place before later version models are layered on153- Mockups, specifications, and test specs build incrementally on prior version artifacts154- Each version's artifacts reflect the cumulative state up to that version155156## Pre-Requisite: Project Information from CLAUDE.md (MANDATORY)157158**CLAUDE.md is automatically loaded into context** at the start of every session. It contains159project details, infrastructure paths, credentials, and configuration. You do NOT need to read160it manually — the information is already available in your context.161162## Redo/Redevelop Guard163164This guard prevents accidental re-execution of already-completed work while allowing165incremental processing of new versions. It uses a **partition and filter** approach, driven by166the `PREPARE_MASTER.md` tracker (the source of truth for what has been prepared).1671681. Read `<app_folder>/context/prepare/PREPARE_MASTER.md`. If it does not exist, skip this check169 (nothing has been prepared yet — every resolved version is new).1702. Resolve the version list (see Version Resolution).1713. **Partition** the resolved versions into two groups, using the tracker's **Version Processing172 Order** table:173 - `completed_versions` — versions whose row is marked `COMPLETED` in PREPARE_MASTER.md174 - `new_versions` — versions with no row, or a row not yet `COMPLETED`1754. **Decision**:176177 | `new_versions` | `completed_versions` | Artifacts exist? | Action |178 |---------------|---------------------|-----------------|--------|179 | Not empty | Any (including empty) | Yes (expected — prior versions built them) | **Proceed with `new_versions` only** — filter out completed versions from the processing list. Existing artifacts are the base for version increment. |180 | Not empty | Any | No | **Proceed with all resolved versions** — no prior artifacts, start from scratch. |181 | Empty | Not empty | Yes | **STOP**. Print: `"All requested versions ({list}) for {application} are already marked COMPLETED in <app_folder>/context/prepare/PREPARE_MASTER.md and their context artifacts still exist. To redo, first delete the existing context artifact folders (model/, mockup/, specification/, test/) and PREPARE_MASTER.md, then re-run this skill."` |182 | Empty | Not empty | No | **Proceed with all resolved versions** — artifacts were cleaned up, this is a legitimate redo. |1831845. **Update the resolved version list** to contain only the versions that will be processed185 (either `new_versions` or all versions for redo). This filtered list is what the Sequential186 Version Loop in Phase 1 will iterate over.187188## Workflow189190### Phase 0: Resume Check (Runs Every Ralph Loop Iteration)191192This phase runs at the START of every iteration, including the first. In a Ralph Loop,193each iteration begins fresh with the same prompt, so the agent MUST check existing artifacts194to understand what has already been completed.1951960. **Auto-Start Ralph Loop** — Check if `.claude/ralph-loop.local.md` exists. If it does NOT197 exist, Ralph Loop is not yet active. Invoke it NOW using the Skill tool:198 ```199 Skill(skill: "ralph-loop:ralph-loop", args: "<the full /conductor-feature-prepare invocation with args> --completion-promise \"ALL ARTIFACTS GENERATED\" --max-iterations 20")200 ```201 If `.claude/ralph-loop.local.md` already exists, Ralph Loop is active — skip this step.2022031. **Use project information from CLAUDE.md (already in context)** — extract database type,204 design system, technology stack, and all infrastructure details.2052. **Resolve the version list** using the Version Resolution rules:206 - Single version → `[v2]`207 - Comma-separated → parse and sort ascending by semver → `[v1, v2, v3]`208 - `all` or omitted → scan PRD.md for ALL `[vX.Y.Z]` tags, deduplicate, sort ascending2093. Read the progress tracker `<app_folder>/context/prepare/PREPARE_MASTER.md` if it exists:210 - It is the source of truth for which steps/versions are COMPLETED211 - Reconcile it against the artifact folders below (if the tracker says COMPLETED but the212 artifact is missing, reset that entry to PENDING)213 - If it does NOT exist, this is a fresh start — Phase 1 Step 1.1.1 will create it214 Then check which artifacts actually exist on disk:215 - Check `<app_folder>/context/model/` for module model files216 - Check `<app_folder>/context/mockup/` for HTML mockup files217 - Check `<app_folder>/context/specification/` for spec files218 - Check `<app_folder>/context/test/` for test spec files2194. If the tracker's top-level status is COMPLETED (all steps for all resolved versions done)220 AND the artifacts still exist:221 - Output `<promise>ALL ARTIFACTS GENERATED</promise>` and stop2225. If multiple versions were resolved, proceed to Phase 1 — the version loop will determine223 which versions still need processing (see Phase 1 Sequential Version Loop)2246. Otherwise, proceed to Phase 1, starting from the first step not marked COMPLETED in the tracker225226### Phase 1: Context Artifacts Generation227228This phase generates all required context artifacts before code implementation begins. Each step229checks if the artifact already exists — if it does, the step is skipped. This ensures the phase230is idempotent and can be resumed safely.231232**IMPORTANT**: If `module` argument was provided, pass it through to each sub-skill invocation233so that only the relevant subset of artifacts is generated.234235#### Sequential Version Loop236237Steps 1.1, 1.1.1 (tracker init) and 1.2 (tagging) are **once-only setup** — they run a single238time before the loop. When multiple versions are resolved (list, `all`, or omitted), Phase 1239wraps the per-version Steps 1.3–1.9 in a **version loop**:240241```242# Once, before the loop: Step 1.1 (resolve folder), Step 1.1.1 (create PREPARE_MASTER.md),243# Step 1.2 (tag user stories)244245resolved_versions = [v1.0.0, v1.0.1, v1.0.2] # ascending semver order246247For each version in resolved_versions:248 1. Mark this version IN PROGRESS in PREPARE_MASTER.md's Version Processing Order table249 2. Run Steps 1.3–1.9 with this single version as the version argument250 3. For the FIRST version: artifacts are generated from scratch (Steps 1.4–1.9)251 4. For SUBSEQUENT versions: artifacts already exist from the prior version — operate in252 Version Increment Mode (update, not skip)253 5. All artifacts for this version must be COMPLETED (mark the version COMPLETED in the tracker)254 before moving to the next version255```256257When only a single version is resolved, the loop runs once — no behavioral difference from258the original single-version flow.259260#### Version Increment Mode261262When artifacts exist from a previous version but the current version in the loop has new/changed263user stories, Steps 1.4–1.9 operate in **update mode**:264265- **DO NOT skip steps just because artifacts already exist.** The existing artifacts are from a266 previous version and need to be updated with the current version's changes.267- Re-invoke ALL sub-skills (modelgen, mockgen, specgen, testgen) with BOTH the current `version`268 AND `module` arguments so they can update the existing artifacts incrementally.269- The sub-skills are responsible for reading the `[v<version>]` sections in PRD.md and270 updating their output files accordingly (appending new fields, modifying existing diagrams,271 updating specs and test scenarios).272273#### Bug Regression Awareness (Redo/Redevelop Scenario)274275PRD.md modules may contain a `### Bug` section listing previously fixed bugs (e.g.,276`[BUG-024] Fixed Message ID link...`). These entries represent validated fixes from prior277development cycles. When generating or updating artifacts, sub-skills MUST treat bug fix278entries as supplementary requirements:279280- **modelgen-***: If a bug fix involved model changes (new fields, changed relationships),281 the model output must reflect the corrected structure.282- **mockgen-tailwind**: If a bug fix involved UI changes (layout, navigation, styling),283 the mockup must reflect the corrected design.284- **specgen-***: If a bug fix involved logic changes (event listeners, processing flow,285 validation), the specification must include the corrected behavior.286- **testgen-functional**: Bug fix descriptions should inform test scenarios to ensure287 regression coverage — each bug fix should have at least one corresponding test assertion.288289This ensures that when an application is redeveloped from scratch, previously reported bugs290do not reappear in the new implementation.291292#### PRD.md Extended Sections Awareness293294PRD.md may contain three extended sections that influence how downstream skills are invoked295and what context they receive. Detect each section's presence at the **start of Phase 1** and296record the result for use throughout the version loop:297298- **`# Design System`** — Already consumed by Step 1.5 (Infer Design System) for routing299 decisions and resolved-file-path propagation to mockgen-* and specgen-*. No additional action300 needed; Step 1.5 is the canonical handler.301- **`# Architecture Principle`** — Already consumed by Step 1.3 (Infer Database Type) and302 Step 1.7 (Infer Technology Stack) as the **primary signal** for routing decisions. Sub-skills303 (modelgen-*, specgen-*) read it directly from PRD.md.304- **`# High Level Process Flow`** — **Detect presence here** so all downstream skills are aware:305 1. Check PRD.md for a `# High Level Process Flow` section. If present, record:306 - The list of named flows (e.g., "Country submission flow", "Worker registration flow")307 - Any external file references (e.g., `[FLOW_DIAGRAM.md](reference/FLOW_DIAGRAM.md)`)308 - Resolve any referenced file paths relative to PRD.md309 2. When invoking sub-skills in subsequent steps, pass this awareness as context so each skill310 knows process flows are available and should be consulted:311 - **modelgen-\*** uses flows to identify entities/documents that participate in messaging312 - **specgen-\*** uses flows as the blueprint for service-layer methods, queue topology, and313 message consumer/publisher design314 - **mockgen-\*** uses flows to determine screen-to-screen navigation and async UI states315 - **testgen-functional** uses flows to design end-to-end test scenarios that exercise each316 flow step in order317 3. If absent, sub-skills fall back to deriving messaging behavior from individual user stories318 (existing behavior).319320Record the detection result (Design System: yes/no, Architecture Principle: yes/no, Process321Flow: yes/no + flow names) in your working memory for the duration of the run. This awareness322does NOT replace each sub-skill's own reading of PRD.md — every sub-skill reads PRD.md directly,323but knowing which sections are present helps the orchestrator detect missing pre-requisites324early and surface them to the user.325326#### Step 1.1: Resolve Application Folder3273281. Match the `<application>` argument against root-level folders (same logic as Input Resolution)3292. The resolved `<app_folder>` is the root for all context artifacts3303. Verify `<app_folder>/context/PRD.md` exists — if not, stop with error331332#### Step 1.1.1: Initialize Preparation Tracking (PREPARE_MASTER.md)333334**This step runs ONCE before the version loop starts** (like tagging). It creates the progress335tracker that this skill — and any resumed Ralph Loop iteration — reads to know what is done.3363371. If `<app_folder>/context/prepare/PREPARE_MASTER.md` already exists, read it and reconcile it338 against the resolved version list (add rows for any newly-resolved versions as PENDING). Do339 NOT overwrite existing COMPLETED rows.3402. If it does not exist, create `<app_folder>/context/prepare/PREPARE_MASTER.md` with the341 structure below (pre-seed every row as PENDING; the version loop and steps below flip rows to342 COMPLETED / SKIPPED as they run). Add one **Artifact Generation Status** table per resolved343 version.344345```markdown346# Preparation Master - <Application Name>347348**Started**: <date>349**Context**: <app_folder>/context350**Resolved Versions**: <comma-separated sorted version list, e.g., "v1.0.0, v1.0.1, v1.0.2">351**Status**: IN PROGRESS352353---354355## Inferred Configuration356357| Aspect | Value | Source |358|--------|-------|--------|359| Database Type | TBD | - |360| Model Generator | TBD | - |361| Design System | TBD | - |362| Mockup Generator | TBD | - |363| Technology Stack | TBD | - |364| Spec Generator | TBD | - |365366> Filled in by the inference steps (1.3, 1.5, 1.7) as the pipeline runs.367368---369370## User Story Tagging (runs ONCE, applies to all versions)371372| Step | Skill | Status | Completed |373|------|-------|--------|-----------|374| 1.2 Tag items | util-ustagger | PENDING | - |375376---377378## Version Processing Order379380| # | Version | Status | Started | Completed |381|---|---------|--------|---------|-----------|382| 1 | v1.0.0 | PENDING | - | - |383| 2 | v1.0.1 | PENDING | - | - |384385> **Processing Rule**: All artifacts for version N must reach COMPLETED before version N+1 begins.386387---388389## Artifact Generation Status390391One table per version. `SKIPPED` = artifact already existed and this is NOT a version increment.392393### v1.0.0394395| Step | Artifact | Skill | Status | Completed |396|------|----------|-------|--------|-----------|397| 1.4 | Module Model | modelgen-* | PENDING | - |398| 1.6 | HTML Mockups | mockgen-* | PENDING | - |399| 1.8 | Technical Spec | specgen-* | PENDING | - |400| 1.9 | Test Spec | testgen-functional | PENDING | - |401402### v1.0.1403404<one table per resolved version, same columns>405```4064073. Statuses used throughout: `PENDING`, `IN PROGRESS`, `COMPLETED`, `SKIPPED`.408409##### Tracking Updates (MANDATORY)410411After each step below completes, update PREPARE_MASTER.md in place — never leave a finished step412marked PENDING. Use this mapping:413414| After step | Update in PREPARE_MASTER.md |415|-----------|------------------------------|416| 1.2 Tag User Stories | User Story Tagging table → `COMPLETED` + date |417| 1.3 Infer Database Type | Inferred Configuration → Database Type + Model Generator (with source) |418| 1.4 Generate Module Model | current version's Artifact table → Module Model = `COMPLETED` (or `SKIPPED`) |419| 1.5 Infer Design System | Inferred Configuration → Design System + Mockup Generator (with source) |420| 1.6 Generate HTML Mockups | current version's Artifact table → HTML Mockups = `COMPLETED` (or `SKIPPED`) |421| 1.7 Infer Technology Stack | Inferred Configuration → Technology Stack + Spec Generator (with source) |422| 1.8 Generate Technical Spec | current version's Artifact table → Technical Spec = `COMPLETED` (or `SKIPPED`) |423| 1.9 Generate Test Spec | current version's Artifact table → Test Spec = `COMPLETED` (or `SKIPPED`) |424| Version's 4 artifacts all done | Version Processing Order → that version = `COMPLETED` + date; then start the next version (mark it `IN PROGRESS`) |425426At the START of each version iteration, mark that version `IN PROGRESS` in the Version Processing427Order table. Mark an artifact `SKIPPED` (not `COMPLETED`) when the step is skipped because the428artifact already existed and this is not a version increment.429430#### Step 1.2: Tag User Stories431432Tag all untagged items in PRD.md with unique ID codes before any artifact generation begins.433This ensures all user stories, NFRs, constraints, and references have stable IDs that downstream434artifacts (module models, specs, tests) can reference for traceability.435436**This step runs ONCE before the version loop starts** (not per-version), because tagging437applies to all items regardless of version.4384391. Determine the version label to pass:440 - If processing a single version → use that version (e.g., `v2`)441 - If processing multiple versions → use the HIGHEST version in the resolved list442 - If no `version` argument (all) → use `v1` as the default4432. Invoke the tagging skill:444 - `Skill(skill: "co2-skills:util-ustagger", args: "<application> <version>")`445 - Example: `Skill(skill: "co2-skills:util-ustagger", args: "mainapp v1")`4463. Wait for the skill to complete. It will tag untagged items in-place in PRD.md.4474. This step is idempotent — if all items are already tagged, the skill will report no changes.448449#### Step 1.3: Infer Database Type4504511. **Check PRD.md `# Architecture Principle` section first** (primary signal):452 - If Architecture Principle explicitly mentions "document based database", "document-oriented", "NoSQL", "MongoDB", or similar → **nosql**453 - If Architecture Principle explicitly mentions "relational database", "SQL", "PostgreSQL", "MySQL", or similar → **relational**4542. **Fallback to CLAUDE.md** (if Architecture Principle is absent or does not mention database type):455 - Read application details from CLAUDE.md (already in context)456 - Identify the database from the application's dependency list:457 - If the application depends on MySQL, PostgreSQL, or another relational database → **relational**458 - If the application depends on MongoDB or another NoSQL database → **nosql**4593. Record the inferred database type for the next step460461#### Step 1.4: Generate Module Model4624631. **Check if artifacts exist**: List files in `<app_folder>/context/model/`464 - If `.md` or `.json` files already exist AND this is NOT a version increment → **SKIP** this step465 - If this IS a version increment, **proceed** to re-invoke the skill with version/module args4662. Invoke the appropriate model generation skill:467 - If database type is **relational** → `Skill(skill: "co2-skills:modelgen-relational", args: "<app_folder> [version:<version>] [module:<module>]")`468 - If database type is **nosql** → `Skill(skill: "co2-skills:modelgen-nosql", args: "<app_folder> [version:<version>] [module:<module>]")`4693. Wait for the skill to complete. The output will be module model files in `<app_folder>/context/model/`470471#### Step 1.5: Infer Design System4724731. **Check PRD.md `# Design System` section first** (primary signal):474 - If the section exists and references a `DESIGN_SYSTEM.md` file (e.g., `[DESIGN_SYSTEM.md](reference/DESIGN_SYSTEM.md)`), resolve the file path relative to PRD.md475 - Record the resolved design system file path for downstream skills (mockgen, specgen)476 - The referenced file contains design tokens (colors, typography, components) that sub-skills will use4772. **Fallback to CLAUDE.md** (if Design System section is absent or has no reference):478 - Read application details from CLAUDE.md (already in context)479 - Identify the design system / CSS framework:480 - Look for mentions of Tailwind CSS, Bootstrap, Material UI, etc.481 - If no design system is explicitly identified → default to **Tailwind CSS**4823. Record the inferred design system for the next step483484#### Step 1.6: Generate HTML Mockups4854861. **Check if artifacts exist**: List files in `<app_folder>/context/mockup/`487 - If `.html` files already exist AND this is NOT a version increment → **SKIP** this step488 - If this IS a version increment, **proceed** to re-invoke the skill with version/module args4892. Determine the appropriate mockup generator:490 - Check available skills matching `mockgen-*` pattern491 - For Tailwind CSS → `Skill(skill: "co2-skills:mockgen-tailwind", args: "<app_folder> [version:<version>] [module:<module>]")`492 - Default to `mockgen-tailwind` if no specific generator matches the design system4933. Wait for the skill to complete. The output will be HTML mockup files in `<app_folder>/context/mockup/`494495#### Step 1.7: Infer Technology Stack4964971. **Check PRD.md `# Architecture Principle` section first** (primary signal):498 - If Architecture Principle explicitly mentions a framework (e.g., "Spring Boot", "Laravel"), use it499 - If it mentions a view engine (e.g., "JTE", "Blade"), use it500 - If it mentions frontend tooling (e.g., "HTMX", "Alpine.js", "Vite"), use it501 - If it mentions architectural style (e.g., "monolithic", "REST API"), use it to disambiguate specgen variant5022. **Fallback to CLAUDE.md** (if Architecture Principle is absent or incomplete):503 - Read application details from CLAUDE.md (already in context)504 - Identify the technology stack:505 - Framework (Laravel, Spring Boot, etc.)506 - ORM (Eloquent, JPA/Hibernate, etc.)507 - View engine (Blade, JTE, etc.)508 - Frontend enhancement (HTMX, Alpine.js, etc.)5093. Record the inferred technology stack for the next step510511#### Step 1.8: Generate Technical Specification5125131. **Check if artifacts exist**: List files in `<app_folder>/context/specification/`514 - If `.md` files already exist AND this is NOT a version increment → **SKIP** this step515 - If this IS a version increment, **proceed** to re-invoke the skill with version/module args5162. Determine the appropriate specification generator:517 - Check available skills matching `specgen-*` pattern518 - For Laravel + Eloquent + Blade + HTMX → `Skill(skill: "co2-skills:specgen-laravel-eloquent-bladehtmx", args: "<app_folder> [version:<version>] [module:<module>]")`519 - For Spring Boot + JPA + JTE + HTMX → `Skill(skill: "co2-skills:specgen-spring-jpa-jtehtmx", args: "<app_folder> [version:<version>] [module:<module>]")`520 - 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>]")`521 - Match the skill name against the inferred technology stack components5223. Wait for the skill to complete. The output will be specification files in `<app_folder>/context/specification/`523524#### Step 1.9: Generate Test Specification5255261. **Check if artifacts exist**: List files in `<app_folder>/context/test/`527 - If `.md` files already exist AND this is NOT a version increment → **SKIP** this step528 - If this IS a version increment, **proceed** to re-invoke the skill with version/module args5292. Invoke the test specification generator:530 - `Skill(skill: "co2-skills:testgen-functional", args: "<app_folder> [version:<version>] [module:<module>]")`5313. Wait for the skill to complete. The output will be test specification files in `<app_folder>/context/test/`532533#### Phase 1 Completion534535After all artifacts for ALL versions in the resolved version list are generated (or confirmed536to already exist):5371. Set the top-level `**Status**:` in `<app_folder>/context/prepare/PREPARE_MASTER.md` to538 `COMPLETED`, and verify every step and every version row is `COMPLETED` or `SKIPPED` (no539 `PENDING` / `IN PROGRESS` rows remain)5402. Output a summary of what was generated/skipped per version (sourced from PREPARE_MASTER.md)5413. Output `<promise>ALL ARTIFACTS GENERATED</promise>` to signal Ralph Loop completion542543**IMPORTANT — Version loop completion**: The completion promise is ONLY output after the LAST544version in the resolved list has been fully processed. Do NOT output it after completing an545intermediate version — proceed to the next version immediately.546547## Critical Rules5485491. **CLAUDE.md is the source of truth** — CLAUDE.md is automatically loaded into context. Use550 it for all project details, database types, technology stacks, and infrastructure configuration.5515522. **Idempotent execution** — Each step checks if artifacts already exist before generating.553 This ensures the skill can be safely re-run or resumed without duplicating work.5545553. **Version increment awareness** — When processing multiple versions sequentially, artifacts556 from the prior version already exist when the next version begins. ALL sub-skills must be557 re-invoked in update mode for each subsequent version.5585594. **Pass through filters** — The current version from the version loop AND the `module`560 argument (if provided) MUST be passed to every sub-skill invocation. Each sub-skill561 receives a SINGLE version at a time, never a list.5625635. **Sequential version order** — When multiple versions are resolved, they are processed564 in ascending semver order. All artifacts for version N must complete before version N+1565 begins. Never process versions in parallel or merge them into a single invocation.5665676. **Context window awareness (Ralph Loop handles recovery)** — If approaching context limits,568 the Ralph Loop will automatically re-feed the prompt, and the next iteration will resume569 from the first step with missing artifacts.5705717. **Auto-start Ralph Loop** — When this skill is triggered, the FIRST action (Phase 0, Step 0)572 MUST be to check if Ralph Loop is active (`.claude/ralph-loop.local.md` exists). If not active,573 invoke the Ralph Loop skill. Do NOT proceed with any work until Ralph Loop is confirmed active.5745758. **AUTONOMOUS CONTINUATION — NEVER STOP BETWEEN STEPS OR VERSIONS.** This is an orchestrator576 skill that runs a multi-step pipeline (Steps 1.1 through 1.9) across potentially multiple577 versions. When a sub-skill (e.g., util-ustagger, modelgen-relational, mockgen-tailwind,578 specgen-*, testgen-functional) completes and returns control, you MUST immediately proceed579 to the NEXT step in the pipeline. When all steps for the current version are done, you MUST580 immediately proceed to the NEXT version. Do NOT stop, do NOT wait for user input, do NOT581 treat a sub-skill or version completion as the end of your task. The task is only complete582 when ALL steps for ALL versions have been executed and the completion promise583 `<promise>ALL ARTIFACTS GENERATED</promise>` has been output. **Stopping after any584 intermediate step or version is a bug in execution.**5855869. **PREPARE_MASTER.md is the progress source of truth** — Every step updates587 `<app_folder>/context/prepare/PREPARE_MASTER.md` per the Tracking Updates table in Step 1.1.1.588 On resume (any Ralph Loop iteration), read it FIRST to determine what is already done; do NOT589 re-run steps it marks COMPLETED (unless in version increment mode). Reconcile it against the590 artifact folders on disk if they disagree.