Cabbage Skill: Project Documentation Lifecycle & Workflow Gates
1. When to Use & Scenario Dispatch (Phase 0)
Use this Skill whenever performing any software engineering, architecture, documentation, or operational activity.
Before beginning, classify the incoming task against the 10 scenario archetypes:
| Scenario Archetype |
Cabbage Change Type |
Workflow Path |
Key Actions & Exit Criteria |
| New Feature / Capability |
feature |
Full Lifecycle |
PRD -> Tech Spec (Testing Decisions) -> Tasks (Vertical Slices) -> Implementation -> Dual-Axis Review -> Merge |
| Bug / Regression |
bugfix |
Lightweight Corrective |
Reproduce -> Failing Test (RED) -> Minimal Fix (GREEN) -> Regression Verify |
| Production Incident / Hotfix |
hotfix / incident |
Fast-Track Patch |
Patch from release tag -> Minimal Fix -> Release PR -> Rollback plan |
| Business Adjustment |
feature / bugfix |
Change Management |
Impact analysis -> Backward compatibility check -> Update spec -> Implement |
| Refactoring |
refactor |
Behavior-Preserving |
Test safety net -> Stepwise refactor -> Differential/snapshot parity check |
| Tech Debt Cleanup |
refactor |
Behavior-Preserving Removal |
Inventory unused assets -> Verify consumer references -> Delete -> Full regression |
| Infrastructure Change |
integration / refactor |
CI-as-Acceptance |
Small incremental steps -> Push to CI -> Verify build pipeline & regression |
| Documentation Update |
feature or direct docs |
Docs-as-Code |
Update canonical docs -> Terminology check -> Docs build verify (cabbage docs build) |
| Rollback & Recovery |
hotfix |
Controlled Rollback |
Revert PR -> Create root-cause corrective change -> Clean worktrees |
| Technical Research |
architecture |
Evidence-Driven |
Frame hypothesis -> Conduct research/POC -> Document findings & trade-offs |
- Reference:
references/decision-tree.md for full classification tree and impact mappings.
2. Core Principles & Anti-Rot Rules
- Single Source of Truth: Every architectural or product fact lives in exactly one canonical document; all other docs link to it.
- Current-State vs. Decision History:
- Current-state docs (
docs/01-product/, docs/03-architecture/system-design/, docs/05-api/, docs/13-operations/) describe the system as it exists now and are updated in-place.
- Decision-history docs (
ADR, RFC, postmortem) are immutable historical records. Never rewrite history; explicitly supersede older decisions with new ones.
- Content Signatures & Cascading Invalidation: Verifying an artifact computes a cryptographic SHA-256 signature of its content, workflow schema, and upstream dependencies. Modifying an upstream artifact automatically invalidates downstream stages to
stale.
- Zero Placeholder & Strict Link Integrity: Verification rejects any residual
TODO, TBD, FIXME, or default scaffold prompts, as well as broken local relative links.
- Atomic PR Delivery: Code changes and their associated documentation changes must be committed and delivered in the same Pull Request.
- Automated Specification Synchronization: Running
cabbage sync or cabbage archive automatically extracts verified specifications into the persistent docs/ hierarchy.
- No Final-v2-Copy Anti-Patterns: Avoid filenames like
spec-v2-final.md. Maintain stable paths and let Git manage version history.
3. Comprehensive Reference Index & Navigation
Before or during execution, consult the following dedicated reference guides in references/:
| Reference Document |
Scope & Key Topics |
When to Consult |
references/cli.md |
Complete CLI syntax, subcommands, flags, exit codes, and JSON outputs |
Executing or debugging any cabbage command |
references/decision-tree.md |
10 scenario archetypes, classification tree, impact matrix, conditional activations |
Classifying a new task or configuring impact flags |
references/lifecycle.md |
Change states (active / archived), stage state machine, SHA-256 signatures, stale triggers |
Understanding state transitions or resolving gate blocks |
references/directory-structure.md |
Standard 22-category docs/ tree layout and placement rules |
Locating, creating, or moving long-lived documentation |
references/document-types.md |
Specifications, Testing Decisions, DAG vertical task slices, and lifecycle rules for 12 artifact types |
Writing PRD, Tech Spec, ADR, RFC, API Design, Task DAGs, etc. |
references/adoption.md |
7-phase flow for scanning, classifying, and migrating existing repository docs |
Onboarding pre-existing project documentation |
references/validation.md |
Automated validation rules, TDD protocol, and Dual-Axis Review framework |
Troubleshooting verify/validate or reviewing PRs |
references/linking-rules.md |
Relative path resolution, stable heading anchors, cross-referencing rules |
Writing Markdown links between files |
references/naming-conventions.md |
Kebab-case naming, ADR/RFC numbering formats (ADR-0001-...), anti-patterns |
Naming change workspaces, ADRs, RFCs, and files |
references/diagrams.md |
Mermaid diagram syntax templates (Flowchart, Sequence, State, ER, Class, Git) |
Creating or reviewing architectural diagrams |
references/documentation-site.md |
VitePress 1.6+ configuration, Mermaid integration, local dev preview, static build |
Previewing or compiling the docs/ site |
references/enforcement.md |
CI gate configuration, branch protection, CODEOWNERS, agent security boundary |
Setting up CI/CD pipelines or permission policies |
references/ownership.md |
Code-to-documentation parity, frontmatter metadata, team ownership boundaries |
Assigning doc maintainers and PR reviewers |
4. Standard Operating Procedures (SOPs)
SOP 1: Feature & Capability Delivery Flow
Follow this end-to-end workflow when implementing a new feature or business capability.
flowchart TD
Pre["0. Grill-Me Alignment (Context & Boundaries)"] --> A["1. cabbage doctor & new feature <id>"]
A --> B["2. cabbage impact <id> --set ..."]
B --> C["3. Draft PRD, Tech Spec (Options) & Task DAG (SOP)"]
C --> D["4. cabbage verify <id> <stage>"]
D --> E{"5. cabbage gate <id> implementation"}
E -- Blocked --> C
E -- Allowed --> F["6. cabbage tasks --export-dag & Parallel Subagent TDD"]
F --> G["7. Mark Tasks Done [x] & Verify test-plan/release-plan"]
G --> H["8. cabbage validate <id> & cabbage sync <id>"]
H --> I{"9. Dual-Axis Review & cabbage gate <id> merge"}
I -- Blocked --> F
I -- Allowed --> J["10. Merge PR & cabbage archive <id>"]
Step 0: Pre-Flight Context Alignment & Grill-Me Protocol
Before touching workflow files or generating artifacts, AI and human must establish a crystal-clear boundary consensus:
- Context & Codebase Exploration:
- Inspect existing codebase, canonical docs (
docs/), and recent changes first.
- Never ask questions that can be answered by reading the codebase.
- Grill-Me Deep Alignment:
- Probe the intent iteratively: clarify the fundamental problem, business value, user personas, and hard constraints.
- Explicitly define In Scope vs. Explicit Non-Goals to eliminate scope creep before it starts.
- Formulate questions concisely (using structured options / questionnaires where applicable).
- Asymmetric Decision Framework (Frontal-Lobe Protection):
- AI Autonomous Decisions: Micro-level technical details, private helper structures, internal naming, local refactorings, and test mocks are decided directly by AI without cognitive overhead for the human.
- Human Gate Decisions: Strategic trade-offs, public API contracts, database schema migrations, billing/security policies, and breaking changes must be presented with options and decided by the human.
- Anchor in PRD:
- Record the validated assumptions, boundaries, and decision tiers into
.cabbage/changes/<change-id>/prd.md under ## Grill-Me Alignment Summary and ## Decision Boundaries.
Step 1: Initialize Workspace & Environment Check
Check environment prerequisites and initialize the change workspace:
cabbage doctor
cabbage new feature <change-id>
- Reference:
references/naming-conventions.md for <change-id> naming.
Step 2: Impact Analysis & Stage Activation
Evaluate affected technical domains and activate conditional stages:
cabbage impact <change-id>
cabbage impact <change-id> --set api=true --set database=true --set security=true
- Reference:
references/decision-tree.md for impact field mappings.
Step 3: Author Artifacts, DAG Task Decomposition & Stage Verification
Inspect next ready stages, fill in the generated templates in .cabbage/changes/<change-id>/, remove all placeholders, and verify each stage:
cabbage next <change-id>
# Edit .cabbage/changes/<change-id>/prd.md (contains Grill-Me outcomes and Decision Boundaries)
cabbage verify <change-id> prd
# Edit tech-spec.md (must evaluate Architecture Options and include Testing Decisions)
cabbage verify <change-id> tech-spec
# Edit tasks.md (must define Mermaid DAG, Parallel Groups, and Task SOP per slice)
cabbage verify <change-id> tasks
- Architecture Options Protocol:
- In
tech-spec.md, formulate 2 to 3 distinct architectural options (e.g. Minimal Low-Risk, Scalable Decoupled, Ideal Long-Term).
- Compare benefits, costs, and risks explicitly before committing to the design.
- Task DAG & Standard Operating Procedure (SOP):
- Model tasks as a Directed Acyclic Graph (DAG) with Mermaid
flowchart TD.
- Slice tasks vertically (end-to-end observable behavior), avoiding horizontal tech layers.
- Declare explicit
Blocked By dependencies (true blocking only; no circular dependencies).
- Every Task block must define its 4-step SOP:
- [RED] Test Seam: Define public test seam and write failing test.
- [GREEN] Implement: Minimal code to pass tests.
- [REFACTOR] Clean: Refactor, lint, type check, preserve behavior.
- [VERIFY] Validate: Run targeted verification command.
- Reference:
references/document-types.md for Testing Decisions, Architecture Options, and DAG Task SOP standards.
- Reference:
references/diagrams.md for Mermaid architectural and DAG diagram templates.
Step 4: Pre-Implementation Gate Guard
Before writing source code, confirm the implementation gate passes:
cabbage gate <change-id> implementation
If this command exits with non-zero or outputs BLOCKED, resolve missing or stale stages before touching code.
Step 5: TDD Implementation & Subagent Parallel Orchestration
Execute tasks according to the DAG topological order:
- DAG Inspection & Dispatch Export:
- Standard Operating Procedure (Task SOP):
- Each worker or subagent executes the 4-step SOP strictly against the designated test seam and verification command.
- Mark task items
- [ ] to - [x] as slices are verified.
- Topological Progression:
- Independent DAG branches run in parallel; convergence nodes run only after all prerequisites are marked green.
- Reference:
references/validation.md for TDD behavioral protocol and Dual-Axis Review.
Step 6: Post-Implementation Verification & Plans
Complete and verify test-plan.md and release-plan.md:
cabbage verify <change-id> tasks
cabbage verify <change-id> test-plan
cabbage verify <change-id> release-plan
Step 7: Full Validation & Specification Sync
Validate all change constraints and synchronize specifications into docs/:
cabbage validate <change-id>
cabbage sync <change-id>
cabbage docs build
- Reference:
references/directory-structure.md for synced target paths.
- Reference:
references/documentation-site.md for VitePress build details.
Step 8: Dual-Axis Review & Merge Gate
Execute Dual-Axis Review (Specification Axis + Convention Axis) and evaluate merge readiness:
cabbage gate <change-id> merge
cabbage ci --base origin/main
- Reference:
references/validation.md for Dual-Axis Review criteria.
Step 9: PR Merge & Archival
After merging the PR into the target branch:
cabbage archive <change-id>
- Reference:
references/lifecycle.md for archival mechanics.
SOP 2: Existing Project Documentation Adoption Flow
Follow this procedure when onboarding an existing repository with pre-existing documentation.
# 1. Scaffold Cabbage base without touching existing docs
cabbage init
# 2. Inventory all existing markdown documentation
cabbage adopt
# 3. Apply suggested migrations or manually resolve review rows
cabbage adopt --apply
# 4. Create adoption baseline change record
cabbage new feature adopt-existing-docs
# 5. Verify links and site build
cabbage validate adopt-existing-docs
cabbage docs build
# 6. Merge baseline PR and enable CI enforcement
- Reference:
references/adoption.md for the detailed 7-phase adoption guide.
- Reference:
references/enforcement.md for branch protection and CI setup.
SOP 3: Architecture Change & ADR/RFC Decision Flow
Follow this procedure when introducing systemic architectural changes, new design patterns, or major dependencies.
- Create Architecture Workspace:
cabbage new architecture <change-id>
- Draft Decision Records & Proposals:
- Write
adr.md following standard Context-Decision-Consequences format.
- If broad cross-team discussion is required, draft
rfc.md.
- Embed Mermaid topology and sequence diagrams directly in the text.
- Verify Decision Artifacts:
cabbage verify <change-id> adr
cabbage verify <change-id> tech-spec
cabbage gate <change-id> implementation
- Sync to Persistent Architecture Tree:
cabbage sync <change-id>
This automatically registers ADR-XXXX under docs/03-architecture/adr/.
- Reference:
references/document-types.md and references/naming-conventions.md.
SOP 4: Bugfix & Hotfix Flow
Follow this streamlined procedure for defect corrections.
- Create Bugfix / Hotfix Workspace:
cabbage new bugfix <change-id>
# or for urgent production defects:
cabbage new hotfix <change-id>
- Minimal Impact Assessment:
cabbage impact <change-id>
Only enable fields directly affected by the bugfix (e.g. testing=true).
- Reproduce & Fix with TDD:
- Write a failing reproduction test (RED).
- Apply minimal fix (GREEN).
- Document root cause analysis in
tasks.md and mark checklist items - [x].
- Verify & Merge:
cabbage verify <change-id> tasks
cabbage gate <change-id> merge
SOP 5: Database & Data Migration Flow
Follow this procedure when adding or modifying database schemas, tables, indexes, or running data backfills.
- Create Migration Workspace & Set Impact:
cabbage new migration <change-id>
cabbage impact <change-id> --set database=true --set deployment=true
- Author Database Design Artifact (
database-design.md):
- Define exact DDL / schema modifications.
- Document forward migration steps and rollback procedures.
- Include ER diagrams using Mermaid syntax.
- Evaluate locking, zero-downtime constraints, and data safety.
- Verify & Execute Gate:
cabbage verify <change-id> database-design
cabbage verify <change-id> tasks
cabbage gate <change-id> implementation
- Sync & Merge:
cabbage sync <change-id>
cabbage gate <change-id> merge
SOP 6: Production Incident & Postmortem Flow
Follow this procedure to document live service outages, root cause analysis, and preventative actions.
- Create Incident Workspace:
cabbage new incident <incident-id>
- Document Incident Timeline & Postmortem:
- Record exact UTC timeline in
incident.md.
- Conduct 5-Why root cause analysis in
postmortem.md.
- List actionable preventative tasks with assigned owners.
- Verify & Archive into Incident History:
cabbage verify <incident-id> incident
cabbage verify <incident-id> postmortem
cabbage sync <incident-id>
cabbage archive <incident-id>
Archived records permanently reside in docs/15-incidents/.
5. Long-Session Context Management & Handoff
During extended execution or when switching between major phases:
- Context Pressure Mitigation: When conversation history grows large or when pausing work:
- Produce a concise handoff record under
docs/dev/handoff-<YYYY-MM-DD>.md summarizing:
- Current change ID and phase.
- Completed stages and verified artifacts.
- Active tasks in progress and immediate next step.
- Key files created/modified.
- Session Resumption:
- Check existing changes:
cabbage status
- Inspect ready actions:
cabbage next <change-id>
- Resume directly from the next unblocked stage rather than re-scanning the entire project.
6. Command Quick Reference
# Environment & Diagnosis
cabbage doctor # Diagnostic check
cabbage init # Greenfield init
cabbage adopt [--apply] # Adopt existing docs
# Workspace & Stages
cabbage new <type> <change-id> # Create change workspace
cabbage status [change-id] # View stage progress
cabbage next <change-id> # View ready/blocked stages
cabbage impact <change-id> [--set k=v] # Inspect or update impact matrix
cabbage discard <change-id> # Remove active change
# Verification & Gates
cabbage verify <change-id> <stage> # Verify single artifact
cabbage validate [<change-id> | --all] # Validate markdown & links
cabbage gate <change-id> implementation|merge # Evaluate lifecycle gate
# Sync, Archive & CI
cabbage sync <change-id> # Extract specs into docs/
cabbage archive <change-id> # Archive completed change
cabbage ci --base <git-ref> # CI diff & gate runner
# Documentation Site
cabbage docs install|dev|build # VitePress lifecycle
- Reference:
references/cli.md for full parameter specifications and exit codes.
7. Troubleshooting & Common Failure Modes
| Error / Failure |
Root Cause |
Resolution |
verify: contains placeholder: ... |
File contains TODO, TBD, FIXME, or default template prompt text |
Replace placeholder text with real content. |
verify: unchecked tasks remain |
tasks.md contains - [ ] unchecked checklist items |
Mark completed items as - [x] after implementation. |
gate implementation: BLOCKED |
Required pre-implementation artifacts are unverified (pending) or stale |
Run cabbage next <id> and verify unready stages with cabbage verify. |
stage status: stale |
Upstream artifact, workflow definition, or impact flag was modified |
Review the artifact against updated upstream dependencies, then re-run cabbage verify <id> <stage>. |
validate: broken link ... |
A relative link in Markdown references a nonexistent file or anchor |
Check relative path depth or update heading anchor slug. See references/linking-rules.md. |
docs build: failed |
VitePress dead link check or unclosed code fence |
Run cabbage validate --all to pinpoint invalid paths. |
ci: code modified without change |
Strict mode detected source code modifications not covered by an active change |
Create or bind an active change via cabbage new <type> <id>. |
1---2name: project-docs-management3description: Enforce end-to-end project documentation lifecycle, change workflows, architecture decisions, validation, VitePress preview, Mermaid diagrams, and CI gates using cabbage.4---56# Cabbage Skill: Project Documentation Lifecycle & Workflow Gates78## 1. When to Use & Scenario Dispatch (Phase 0)910Use this Skill whenever performing any software engineering, architecture, documentation, or operational activity.1112Before beginning, classify the incoming task against the 10 scenario archetypes:1314| Scenario Archetype | Cabbage Change Type | Workflow Path | Key Actions & Exit Criteria |15|---|---|---|---|16| **New Feature / Capability** | `feature` | Full Lifecycle | PRD -> Tech Spec (Testing Decisions) -> Tasks (Vertical Slices) -> Implementation -> Dual-Axis Review -> Merge |17| **Bug / Regression** | `bugfix` | Lightweight Corrective | Reproduce -> Failing Test (RED) -> Minimal Fix (GREEN) -> Regression Verify |18| **Production Incident / Hotfix** | `hotfix` / `incident` | Fast-Track Patch | Patch from release tag -> Minimal Fix -> Release PR -> Rollback plan |19| **Business Adjustment** | `feature` / `bugfix` | Change Management | Impact analysis -> Backward compatibility check -> Update spec -> Implement |20| **Refactoring** | `refactor` | Behavior-Preserving | Test safety net -> Stepwise refactor -> Differential/snapshot parity check |21| **Tech Debt Cleanup** | `refactor` | Behavior-Preserving Removal | Inventory unused assets -> Verify consumer references -> Delete -> Full regression |22| **Infrastructure Change** | `integration` / `refactor` | CI-as-Acceptance | Small incremental steps -> Push to CI -> Verify build pipeline & regression |23| **Documentation Update** | `feature` or direct docs | Docs-as-Code | Update canonical docs -> Terminology check -> Docs build verify (`cabbage docs build`) |24| **Rollback & Recovery** | `hotfix` | Controlled Rollback | Revert PR -> Create root-cause corrective change -> Clean worktrees |25| **Technical Research** | `architecture` | Evidence-Driven | Frame hypothesis -> Conduct research/POC -> Document findings & trade-offs |2627- *Reference: [`references/decision-tree.md`](references/decision-tree.md) for full classification tree and impact mappings.*2829---3031## 2. Core Principles & Anti-Rot Rules32331. **Single Source of Truth**: Every architectural or product fact lives in exactly one canonical document; all other docs link to it.342. **Current-State vs. Decision History**:35 - Current-state docs (`docs/01-product/`, `docs/03-architecture/system-design/`, `docs/05-api/`, `docs/13-operations/`) describe the system as it exists now and are updated in-place.36 - Decision-history docs (`ADR`, `RFC`, `postmortem`) are immutable historical records. Never rewrite history; explicitly supersede older decisions with new ones.373. **Content Signatures & Cascading Invalidation**: Verifying an artifact computes a cryptographic SHA-256 signature of its content, workflow schema, and upstream dependencies. Modifying an upstream artifact automatically invalidates downstream stages to `stale`.384. **Zero Placeholder & Strict Link Integrity**: Verification rejects any residual `TODO`, `TBD`, `FIXME`, or default scaffold prompts, as well as broken local relative links.395. **Atomic PR Delivery**: Code changes and their associated documentation changes must be committed and delivered in the same Pull Request.406. **Automated Specification Synchronization**: Running `cabbage sync` or `cabbage archive` automatically extracts verified specifications into the persistent `docs/` hierarchy.417. **No Final-v2-Copy Anti-Patterns**: Avoid filenames like `spec-v2-final.md`. Maintain stable paths and let Git manage version history.4243---4445## 3. Comprehensive Reference Index & Navigation4647Before or during execution, consult the following dedicated reference guides in `references/`:4849| Reference Document | Scope & Key Topics | When to Consult |50|---|---|---|51| [`references/cli.md`](references/cli.md) | Complete CLI syntax, subcommands, flags, exit codes, and JSON outputs | Executing or debugging any `cabbage` command |52| [`references/decision-tree.md`](references/decision-tree.md) | 10 scenario archetypes, classification tree, impact matrix, conditional activations | Classifying a new task or configuring impact flags |53| [`references/lifecycle.md`](references/lifecycle.md) | Change states (`active` / `archived`), stage state machine, SHA-256 signatures, stale triggers | Understanding state transitions or resolving gate blocks |54| [`references/directory-structure.md`](references/directory-structure.md) | Standard 22-category `docs/` tree layout and placement rules | Locating, creating, or moving long-lived documentation |55| [`references/document-types.md`](references/document-types.md) | Specifications, Testing Decisions, DAG vertical task slices, and lifecycle rules for 12 artifact types | Writing PRD, Tech Spec, ADR, RFC, API Design, Task DAGs, etc. |56| [`references/adoption.md`](references/adoption.md) | 7-phase flow for scanning, classifying, and migrating existing repository docs | Onboarding pre-existing project documentation |57| [`references/validation.md`](references/validation.md) | Automated validation rules, TDD protocol, and Dual-Axis Review framework | Troubleshooting `verify`/`validate` or reviewing PRs |58| [`references/linking-rules.md`](references/linking-rules.md) | Relative path resolution, stable heading anchors, cross-referencing rules | Writing Markdown links between files |59| [`references/naming-conventions.md`](references/naming-conventions.md) | Kebab-case naming, ADR/RFC numbering formats (`ADR-0001-...`), anti-patterns | Naming change workspaces, ADRs, RFCs, and files |60| [`references/diagrams.md`](references/diagrams.md) | Mermaid diagram syntax templates (Flowchart, Sequence, State, ER, Class, Git) | Creating or reviewing architectural diagrams |61| [`references/documentation-site.md`](references/documentation-site.md) | VitePress 1.6+ configuration, Mermaid integration, local dev preview, static build | Previewing or compiling the `docs/` site |62| [`references/enforcement.md`](references/enforcement.md) | CI gate configuration, branch protection, CODEOWNERS, agent security boundary | Setting up CI/CD pipelines or permission policies |63| [`references/ownership.md`](references/ownership.md) | Code-to-documentation parity, frontmatter metadata, team ownership boundaries | Assigning doc maintainers and PR reviewers |6465---6667## 4. Standard Operating Procedures (SOPs)6869### SOP 1: Feature & Capability Delivery Flow7071Follow this end-to-end workflow when implementing a new feature or business capability.7273```mermaid74flowchart TD75 Pre["0. Grill-Me Alignment (Context & Boundaries)"] --> A["1. cabbage doctor & new feature <id>"]76 A --> B["2. cabbage impact <id> --set ..."]77 B --> C["3. Draft PRD, Tech Spec (Options) & Task DAG (SOP)"]78 C --> D["4. cabbage verify <id> <stage>"]79 D --> E{"5. cabbage gate <id> implementation"}80 E -- Blocked --> C81 E -- Allowed --> F["6. cabbage tasks --export-dag & Parallel Subagent TDD"]82 F --> G["7. Mark Tasks Done [x] & Verify test-plan/release-plan"]83 G --> H["8. cabbage validate <id> & cabbage sync <id>"]84 H --> I{"9. Dual-Axis Review & cabbage gate <id> merge"}85 I -- Blocked --> F86 I -- Allowed --> J["10. Merge PR & cabbage archive <id>"]87```8889#### Step 0: Pre-Flight Context Alignment & Grill-Me Protocol90Before touching workflow files or generating artifacts, AI and human must establish a crystal-clear boundary consensus:91921. **Context & Codebase Exploration**:93 - Inspect existing codebase, canonical docs (`docs/`), and recent changes first.94 - Never ask questions that can be answered by reading the codebase.952. **Grill-Me Deep Alignment**:96 - Probe the intent iteratively: clarify the fundamental problem, business value, user personas, and hard constraints.97 - Explicitly define **In Scope** vs. **Explicit Non-Goals** to eliminate scope creep before it starts.98 - Formulate questions concisely (using structured options / questionnaires where applicable).993. **Asymmetric Decision Framework (Frontal-Lobe Protection)**:100 - **AI Autonomous Decisions**: Micro-level technical details, private helper structures, internal naming, local refactorings, and test mocks are decided directly by AI without cognitive overhead for the human.101 - **Human Gate Decisions**: Strategic trade-offs, public API contracts, database schema migrations, billing/security policies, and breaking changes must be presented with options and decided by the human.1024. **Anchor in PRD**:103 - Record the validated assumptions, boundaries, and decision tiers into `.cabbage/changes/<change-id>/prd.md` under `## Grill-Me Alignment Summary` and `## Decision Boundaries`.104105#### Step 1: Initialize Workspace & Environment Check106Check environment prerequisites and initialize the change workspace:107108```bash109cabbage doctor110cabbage new feature <change-id>111```112- *Reference: [`references/naming-conventions.md`](references/naming-conventions.md) for `<change-id>` naming.*113114#### Step 2: Impact Analysis & Stage Activation115Evaluate affected technical domains and activate conditional stages:116117```bash118cabbage impact <change-id>119cabbage impact <change-id> --set api=true --set database=true --set security=true120```121- *Reference: [`references/decision-tree.md`](references/decision-tree.md) for impact field mappings.*122123#### Step 3: Author Artifacts, DAG Task Decomposition & Stage Verification124Inspect next ready stages, fill in the generated templates in `.cabbage/changes/<change-id>/`, remove all placeholders, and verify each stage:125126```bash127cabbage next <change-id>128# Edit .cabbage/changes/<change-id>/prd.md (contains Grill-Me outcomes and Decision Boundaries)129cabbage verify <change-id> prd130131# Edit tech-spec.md (must evaluate Architecture Options and include Testing Decisions)132cabbage verify <change-id> tech-spec133134# Edit tasks.md (must define Mermaid DAG, Parallel Groups, and Task SOP per slice)135cabbage verify <change-id> tasks136```137- **Architecture Options Protocol**:138 - In `tech-spec.md`, formulate 2 to 3 distinct architectural options (e.g. Minimal Low-Risk, Scalable Decoupled, Ideal Long-Term).139 - Compare benefits, costs, and risks explicitly before committing to the design.140- **Task DAG & Standard Operating Procedure (SOP)**:141 - Model tasks as a Directed Acyclic Graph (DAG) with Mermaid `flowchart TD`.142 - Slice tasks vertically (end-to-end observable behavior), avoiding horizontal tech layers.143 - Declare explicit `Blocked By` dependencies (true blocking only; no circular dependencies).144 - Every Task block must define its 4-step SOP:145 1. *[RED]* Test Seam: Define public test seam and write failing test.146 2. *[GREEN]* Implement: Minimal code to pass tests.147 3. *[REFACTOR]* Clean: Refactor, lint, type check, preserve behavior.148 4. *[VERIFY]* Validate: Run targeted verification command.149- *Reference: [`references/document-types.md`](references/document-types.md) for Testing Decisions, Architecture Options, and DAG Task SOP standards.* 150- *Reference: [`references/diagrams.md`](references/diagrams.md) for Mermaid architectural and DAG diagram templates.*151152#### Step 4: Pre-Implementation Gate Guard153Before writing source code, confirm the implementation gate passes:154155```bash156cabbage gate <change-id> implementation157```158*If this command exits with non-zero or outputs `BLOCKED`, resolve missing or stale stages before touching code.*159160#### Step 5: TDD Implementation & Subagent Parallel Orchestration161Execute tasks according to the DAG topological order:1621631. **DAG Inspection & Dispatch Export**:164 - Inspect DAG readiness and parallel groups:165 ```bash166 cabbage tasks <change-id>167 cabbage tasks <change-id> --export-dag168 ```169 - Exported plans can be dispatched directly to isolated worker subagents (e.g. parallel `subagent` calls) without cross-contamination.1702. **Standard Operating Procedure (Task SOP)**:171 - Each worker or subagent executes the 4-step SOP strictly against the designated test seam and verification command.172 - Mark task items `- [ ]` to `- [x]` as slices are verified.1733. **Topological Progression**:174 - Independent DAG branches run in parallel; convergence nodes run only after all prerequisites are marked green.175- *Reference: [`references/validation.md`](references/validation.md) for TDD behavioral protocol and Dual-Axis Review.*176177#### Step 6: Post-Implementation Verification & Plans178Complete and verify `test-plan.md` and `release-plan.md`:179180```bash181cabbage verify <change-id> tasks182cabbage verify <change-id> test-plan183cabbage verify <change-id> release-plan184```185186#### Step 7: Full Validation & Specification Sync187Validate all change constraints and synchronize specifications into `docs/`:188189```bash190cabbage validate <change-id>191cabbage sync <change-id>192cabbage docs build193```194- *Reference: [`references/directory-structure.md`](references/directory-structure.md) for synced target paths.* 195- *Reference: [`references/documentation-site.md`](references/documentation-site.md) for VitePress build details.*196197#### Step 8: Dual-Axis Review & Merge Gate198Execute Dual-Axis Review (Specification Axis + Convention Axis) and evaluate merge readiness:199200```bash201cabbage gate <change-id> merge202cabbage ci --base origin/main203```204- *Reference: [`references/validation.md`](references/validation.md) for Dual-Axis Review criteria.*205206#### Step 9: PR Merge & Archival207After merging the PR into the target branch:208209```bash210cabbage archive <change-id>211```212- *Reference: [`references/lifecycle.md`](references/lifecycle.md) for archival mechanics.*213214---215216### SOP 2: Existing Project Documentation Adoption Flow217218Follow this procedure when onboarding an existing repository with pre-existing documentation.219220```bash221# 1. Scaffold Cabbage base without touching existing docs222cabbage init223224# 2. Inventory all existing markdown documentation225cabbage adopt226227# 3. Apply suggested migrations or manually resolve review rows228cabbage adopt --apply229230# 4. Create adoption baseline change record231cabbage new feature adopt-existing-docs232233# 5. Verify links and site build234cabbage validate adopt-existing-docs235cabbage docs build236237# 6. Merge baseline PR and enable CI enforcement238```239- *Reference: [`references/adoption.md`](references/adoption.md) for the detailed 7-phase adoption guide.* 240- *Reference: [`references/enforcement.md`](references/enforcement.md) for branch protection and CI setup.*241242---243244### SOP 3: Architecture Change & ADR/RFC Decision Flow245246Follow this procedure when introducing systemic architectural changes, new design patterns, or major dependencies.2472481. **Create Architecture Workspace**:249 ```bash250 cabbage new architecture <change-id>251 ```2522. **Draft Decision Records & Proposals**:253 - Write `adr.md` following standard Context-Decision-Consequences format.254 - If broad cross-team discussion is required, draft `rfc.md`.255 - Embed Mermaid topology and sequence diagrams directly in the text.2563. **Verify Decision Artifacts**:257 ```bash258 cabbage verify <change-id> adr259 cabbage verify <change-id> tech-spec260 cabbage gate <change-id> implementation261 ```2624. **Sync to Persistent Architecture Tree**:263 ```bash264 cabbage sync <change-id>265 ```266 *This automatically registers `ADR-XXXX` under `docs/03-architecture/adr/`.*267- *Reference: [`references/document-types.md`](references/document-types.md) and [`references/naming-conventions.md`](references/naming-conventions.md).*268269---270271### SOP 4: Bugfix & Hotfix Flow272273Follow this streamlined procedure for defect corrections.2742751. **Create Bugfix / Hotfix Workspace**:276 ```bash277 cabbage new bugfix <change-id>278 # or for urgent production defects:279 cabbage new hotfix <change-id>280 ```2812. **Minimal Impact Assessment**:282 ```bash283 cabbage impact <change-id>284 ```285 *Only enable fields directly affected by the bugfix (e.g. `testing=true`).*2863. **Reproduce & Fix with TDD**:287 - Write a failing reproduction test (RED).288 - Apply minimal fix (GREEN).289 - Document root cause analysis in `tasks.md` and mark checklist items `- [x]`.2904. **Verify & Merge**:291 ```bash292 cabbage verify <change-id> tasks293 cabbage gate <change-id> merge294 ```295296---297298### SOP 5: Database & Data Migration Flow299300Follow this procedure when adding or modifying database schemas, tables, indexes, or running data backfills.3013021. **Create Migration Workspace & Set Impact**:303 ```bash304 cabbage new migration <change-id>305 cabbage impact <change-id> --set database=true --set deployment=true306 ```3072. **Author Database Design Artifact (`database-design.md`)**:308 - Define exact DDL / schema modifications.309 - Document forward migration steps and rollback procedures.310 - Include ER diagrams using Mermaid syntax.311 - Evaluate locking, zero-downtime constraints, and data safety.3123. **Verify & Execute Gate**:313 ```bash314 cabbage verify <change-id> database-design315 cabbage verify <change-id> tasks316 cabbage gate <change-id> implementation317 ```3184. **Sync & Merge**:319 ```bash320 cabbage sync <change-id>321 cabbage gate <change-id> merge322 ```323324---325326### SOP 6: Production Incident & Postmortem Flow327328Follow this procedure to document live service outages, root cause analysis, and preventative actions.3293301. **Create Incident Workspace**:331 ```bash332 cabbage new incident <incident-id>333 ```3342. **Document Incident Timeline & Postmortem**:335 - Record exact UTC timeline in `incident.md`.336 - Conduct 5-Why root cause analysis in `postmortem.md`.337 - List actionable preventative tasks with assigned owners.3383. **Verify & Archive into Incident History**:339 ```bash340 cabbage verify <incident-id> incident341 cabbage verify <incident-id> postmortem342 cabbage sync <incident-id>343 cabbage archive <incident-id>344 ```345 *Archived records permanently reside in `docs/15-incidents/`.*346347---348349## 5. Long-Session Context Management & Handoff350351During extended execution or when switching between major phases:3523531. **Context Pressure Mitigation**: When conversation history grows large or when pausing work:354 - Produce a concise handoff record under `docs/dev/handoff-<YYYY-MM-DD>.md` summarizing:355 - Current change ID and phase.356 - Completed stages and verified artifacts.357 - Active tasks in progress and immediate next step.358 - Key files created/modified.3592. **Session Resumption**:360 - Check existing changes: `cabbage status`361 - Inspect ready actions: `cabbage next <change-id>`362 - Resume directly from the next unblocked stage rather than re-scanning the entire project.363364---365366## 6. Command Quick Reference367368```bash369# Environment & Diagnosis370cabbage doctor # Diagnostic check371cabbage init # Greenfield init372cabbage adopt [--apply] # Adopt existing docs373374# Workspace & Stages375cabbage new <type> <change-id> # Create change workspace376cabbage status [change-id] # View stage progress377cabbage next <change-id> # View ready/blocked stages378cabbage impact <change-id> [--set k=v] # Inspect or update impact matrix379cabbage discard <change-id> # Remove active change380381# Verification & Gates382cabbage verify <change-id> <stage> # Verify single artifact383cabbage validate [<change-id> | --all] # Validate markdown & links384cabbage gate <change-id> implementation|merge # Evaluate lifecycle gate385386# Sync, Archive & CI387cabbage sync <change-id> # Extract specs into docs/388cabbage archive <change-id> # Archive completed change389cabbage ci --base <git-ref> # CI diff & gate runner390391# Documentation Site392cabbage docs install|dev|build # VitePress lifecycle393```394- *Reference: [`references/cli.md`](references/cli.md) for full parameter specifications and exit codes.*395396---397398## 7. Troubleshooting & Common Failure Modes399400| Error / Failure | Root Cause | Resolution |401|---|---|---|402| `verify: contains placeholder: ...` | File contains `TODO`, `TBD`, `FIXME`, or default template prompt text | Replace placeholder text with real content. |403| `verify: unchecked tasks remain` | `tasks.md` contains `- [ ]` unchecked checklist items | Mark completed items as `- [x]` after implementation. |404| `gate implementation: BLOCKED` | Required pre-implementation artifacts are unverified (`pending`) or `stale` | Run `cabbage next <id>` and verify unready stages with `cabbage verify`. |405| `stage status: stale` | Upstream artifact, workflow definition, or impact flag was modified | Review the artifact against updated upstream dependencies, then re-run `cabbage verify <id> <stage>`. |406| `validate: broken link ...` | A relative link in Markdown references a nonexistent file or anchor | Check relative path depth or update heading anchor slug. See [`references/linking-rules.md`](references/linking-rules.md). |407| `docs build: failed` | VitePress dead link check or unclosed code fence | Run `cabbage validate --all` to pinpoint invalid paths. |408| `ci: code modified without change` | Strict mode detected source code modifications not covered by an active change | Create or bind an active change via `cabbage new <type> <id>`. |