cleargate 0.1.0-alpha.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +41 -2
  2. package/dist/MANIFEST.json +160 -0
  3. package/dist/cli.cjs +4383 -16
  4. package/dist/cli.cjs.map +1 -1
  5. package/dist/cli.js +4367 -4
  6. package/dist/cli.js.map +1 -1
  7. package/dist/templates/cleargate-planning/.claude/agents/architect.md +57 -0
  8. package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-ingest.md +145 -0
  9. package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-lint.md +256 -0
  10. package/dist/templates/cleargate-planning/.claude/agents/cleargate-wiki-query.md +143 -0
  11. package/dist/templates/cleargate-planning/.claude/agents/developer.md +58 -0
  12. package/dist/templates/cleargate-planning/.claude/agents/qa.md +57 -0
  13. package/dist/templates/cleargate-planning/.claude/agents/reporter.md +129 -0
  14. package/dist/templates/cleargate-planning/.claude/hooks/session-start.sh +4 -0
  15. package/dist/templates/cleargate-planning/.claude/hooks/stamp-and-gate.sh +18 -0
  16. package/dist/templates/cleargate-planning/.claude/hooks/token-ledger.sh +174 -0
  17. package/dist/templates/cleargate-planning/.claude/settings.json +35 -0
  18. package/dist/templates/cleargate-planning/.claude/skills/flashcard/SKILL.md +92 -0
  19. package/dist/templates/cleargate-planning/.cleargate/FLASHCARD.md +7 -0
  20. package/dist/templates/cleargate-planning/.cleargate/delivery/archive/.gitkeep +0 -0
  21. package/dist/templates/cleargate-planning/.cleargate/delivery/pending-sync/.gitkeep +0 -0
  22. package/dist/templates/cleargate-planning/.cleargate/knowledge/cleargate-protocol.md +508 -0
  23. package/dist/templates/cleargate-planning/.cleargate/knowledge/readiness-gates.md +133 -0
  24. package/dist/templates/cleargate-planning/.cleargate/templates/Bug.md +82 -0
  25. package/dist/templates/cleargate-planning/.cleargate/templates/CR.md +77 -0
  26. package/dist/templates/cleargate-planning/.cleargate/templates/Sprint Plan Template.md +63 -0
  27. package/dist/templates/cleargate-planning/.cleargate/templates/epic.md +120 -0
  28. package/dist/templates/cleargate-planning/.cleargate/templates/initiative.md +53 -0
  29. package/dist/templates/cleargate-planning/.cleargate/templates/proposal.md +52 -0
  30. package/dist/templates/cleargate-planning/.cleargate/templates/story.md +135 -0
  31. package/dist/templates/cleargate-planning/CLAUDE.md +42 -0
  32. package/dist/templates/cleargate-planning/MANIFEST.json +160 -0
  33. package/dist/templates/synthesis/active-sprint.md +30 -0
  34. package/dist/templates/synthesis/open-gates.md +38 -0
  35. package/dist/templates/synthesis/product-state.md +32 -0
  36. package/dist/templates/synthesis/roadmap.md +63 -0
  37. package/package.json +9 -2
  38. package/templates/cleargate-planning/.claude/agents/architect.md +57 -0
  39. package/templates/cleargate-planning/.claude/agents/cleargate-wiki-ingest.md +145 -0
  40. package/templates/cleargate-planning/.claude/agents/cleargate-wiki-lint.md +256 -0
  41. package/templates/cleargate-planning/.claude/agents/cleargate-wiki-query.md +143 -0
  42. package/templates/cleargate-planning/.claude/agents/developer.md +58 -0
  43. package/templates/cleargate-planning/.claude/agents/qa.md +57 -0
  44. package/templates/cleargate-planning/.claude/agents/reporter.md +129 -0
  45. package/templates/cleargate-planning/.claude/hooks/session-start.sh +4 -0
  46. package/templates/cleargate-planning/.claude/hooks/stamp-and-gate.sh +18 -0
  47. package/templates/cleargate-planning/.claude/hooks/token-ledger.sh +174 -0
  48. package/templates/cleargate-planning/.claude/settings.json +35 -0
  49. package/templates/cleargate-planning/.claude/skills/flashcard/SKILL.md +92 -0
  50. package/templates/cleargate-planning/.cleargate/FLASHCARD.md +7 -0
  51. package/templates/cleargate-planning/.cleargate/delivery/archive/.gitkeep +0 -0
  52. package/templates/cleargate-planning/.cleargate/delivery/pending-sync/.gitkeep +0 -0
  53. package/templates/cleargate-planning/.cleargate/knowledge/cleargate-protocol.md +508 -0
  54. package/templates/cleargate-planning/.cleargate/knowledge/readiness-gates.md +133 -0
  55. package/templates/cleargate-planning/.cleargate/templates/Bug.md +82 -0
  56. package/templates/cleargate-planning/.cleargate/templates/CR.md +77 -0
  57. package/templates/cleargate-planning/.cleargate/templates/Sprint Plan Template.md +63 -0
  58. package/templates/cleargate-planning/.cleargate/templates/epic.md +120 -0
  59. package/templates/cleargate-planning/.cleargate/templates/initiative.md +53 -0
  60. package/templates/cleargate-planning/.cleargate/templates/proposal.md +52 -0
  61. package/templates/cleargate-planning/.cleargate/templates/story.md +135 -0
  62. package/templates/cleargate-planning/CLAUDE.md +42 -0
  63. package/templates/cleargate-planning/MANIFEST.json +160 -0
  64. package/templates/synthesis/active-sprint.md +30 -0
  65. package/templates/synthesis/open-gates.md +38 -0
  66. package/templates/synthesis/product-state.md +32 -0
  67. package/templates/synthesis/roadmap.md +63 -0
@@ -0,0 +1,82 @@
1
+ <instructions>
2
+ FOLLOW THIS EXACT STRUCTURE. Output sections in order 1-5.
3
+ YAML Frontmatter: Bug ID, Parent Ref, Status, Severity, Reporter, Approved gate.
4
+ §1 The Anomaly: Expected vs. Actual behavior.
5
+ §2 Reproduction Protocol: Deterministic steps to recreate.
6
+ §3 Evidence & Context: Raw logs, stack traces, payloads — no paraphrasing.
7
+ §4 Execution Sandbox: Exact file paths to investigate. Restrict scope to prevent unrelated refactoring.
8
+ §5 Verification Protocol: The failing test that proves the bug exists and proves the fix resolves it.
9
+ Output location: .cleargate/delivery/pending-sync/BUG-{ID}.md
10
+
11
+ CRITICAL PHASE GATE: Do NOT invoke cleargate_push_item until reproduction steps are 100% deterministic and a failing test is attached.
12
+ Do NOT output these instructions.
13
+ </instructions>
14
+
15
+ ---
16
+ bug_id: "BUG-{ID}"
17
+ parent_ref: "EPIC-{ID} | STORY-{ID}"
18
+ status: "Draft | Triaged | In Fix | Verified"
19
+ severity: "P0-Critical | P1-High | P2-Medium | P3-Low"
20
+ reporter: "{name}"
21
+ approved: false
22
+ created_at: "2026-04-17T00:00:00Z"
23
+ updated_at: "2026-04-17T00:00:00Z"
24
+ created_at_version: "strategy-phase-pre-init"
25
+ updated_at_version: "strategy-phase-pre-init"
26
+ server_pushed_at_version: null
27
+ draft_tokens:
28
+ input: null
29
+ output: null
30
+ cache_read: null
31
+ cache_creation: null
32
+ model: null
33
+ sessions: []
34
+ cached_gate_result:
35
+ pass: null
36
+ failing_criteria: []
37
+ last_gate_check: null
38
+ ---
39
+
40
+ # BUG-{ID}: {Bug Name}
41
+
42
+ ## 1. The Anomaly (Expected vs. Actual)
43
+ **Expected Behavior:** {What the system should do under normal conditions.}
44
+
45
+ **Actual Behavior:** {What it is doing right now.}
46
+
47
+ ## 2. Reproduction Protocol
48
+ *(AI agents need strict, deterministic steps. "If it can't be reproduced reliably, it can't be fixed safely.")*
49
+
50
+ 1. Go to...
51
+ 2. Click...
52
+ 3. Observe...
53
+
54
+ ## 3. Evidence & Context
55
+ *(Provide the raw truth: stack traces, terminal errors, network payloads. Do not paraphrase.)*
56
+
57
+ ```
58
+ [Paste exact logs or error messages here]
59
+ ```
60
+
61
+ ## 4. Execution Sandbox (Suspected Blast Radius)
62
+ *(Restrict the agent's focus to prevent unrelated refactoring.)*
63
+
64
+ **Investigate / Modify:**
65
+ - `src/...`
66
+
67
+ ## 5. Verification Protocol (The Failing Test)
68
+ *(The agent must write or run a specific test that proves the bug exists, then prove the fix resolves it.)*
69
+
70
+ **Command:** `npm test ...`
71
+
72
+ ---
73
+
74
+ ## ClearGate Ambiguity Gate (🟢 / 🟡 / 🔴)
75
+ **Current Status: 🔴 High Ambiguity**
76
+
77
+ Requirements to pass to Green (Ready for Fix):
78
+ - [ ] Reproduction steps are 100% deterministic.
79
+ - [ ] Actual vs. Expected behavior is explicitly defined.
80
+ - [ ] Raw error logs/evidence are attached.
81
+ - [ ] Verification command (failing test) is provided.
82
+ - [ ] `approved: true` is set in the YAML frontmatter.
@@ -0,0 +1,77 @@
1
+ <instructions>
2
+ FOLLOW THIS EXACT STRUCTURE. Output sections in order 1-4.
3
+ YAML Frontmatter: CR ID, Parent Ref (Epic or Story being changed), Status, Approved gate.
4
+ Use this template when CHANGING an existing feature. For net-new functionality, use story.md instead.
5
+ §1 The Context Override: What to remove/forget + the new truth. AI agents hallucinate when old context conflicts with new requests.
6
+ §2 Blast Radius & Invalidation: Which downstream items does this CR break? A CR acts as a "Gate Reset" on affected items.
7
+ §3 Execution Sandbox: Exact file paths to modify.
8
+ §4 Verification Protocol: How to confirm new logic works and old logic is fully evicted.
9
+ Output location: .cleargate/delivery/pending-sync/CR-{ID}.md
10
+
11
+ CRITICAL PHASE GATE: Do NOT invoke cleargate_push_item until all impacted downstream Epics/Stories are identified and reverted to 🔴 High Ambiguity.
12
+ Do NOT output these instructions.
13
+ </instructions>
14
+
15
+ ---
16
+ cr_id: "CR-{ID}"
17
+ parent_ref: "EPIC-{ID} | STORY-{ID}"
18
+ status: "Draft | In Review | Approved"
19
+ approved: false
20
+ created_at: "2026-04-17T00:00:00Z"
21
+ updated_at: "2026-04-17T00:00:00Z"
22
+ created_at_version: "strategy-phase-pre-init"
23
+ updated_at_version: "strategy-phase-pre-init"
24
+ server_pushed_at_version: null
25
+ draft_tokens:
26
+ input: null
27
+ output: null
28
+ cache_read: null
29
+ cache_creation: null
30
+ model: null
31
+ sessions: []
32
+ cached_gate_result:
33
+ pass: null
34
+ failing_criteria: []
35
+ last_gate_check: null
36
+ ---
37
+
38
+ # CR-{ID}: {Change Request Name}
39
+
40
+ ## 1. The Context Override (Old vs. New)
41
+ *(AI agents hallucinate when old context conflicts with new requests. Explicitly declare what to evict.)*
42
+
43
+ **Obsolete Logic (What to Remove / Forget):**
44
+ - {e.g., We no longer use Stripe for this flow.}
45
+
46
+ **New Logic (The New Truth):**
47
+ - {e.g., Route all payments through PayPal.}
48
+
49
+ ## 2. Blast Radius & Invalidation
50
+ *(A CR acts as a "Gate Reset" — all affected downstream items revert to 🔴 High Ambiguity.)*
51
+
52
+ - [ ] Invalidate/Update Story: [Link]
53
+ - [ ] Invalidate/Update Epic: [Link]
54
+ - [ ] Database schema impacts? {Yes/No — describe}
55
+
56
+ ## 3. Execution Sandbox
57
+ *(Restrict the agent's scope to prevent unrelated refactoring.)*
58
+
59
+ **Modify:**
60
+ - `src/...`
61
+
62
+ ## 4. Verification Protocol
63
+ *(How do we confirm new logic works and old logic is completely removed?)*
64
+
65
+ **Command/Test:** `npm test ...`
66
+
67
+ ---
68
+
69
+ ## ClearGate Ambiguity Gate (🟢 / 🟡 / 🔴)
70
+ **Current Status: 🔴 High Ambiguity**
71
+
72
+ Requirements to pass to Green (Ready for Execution):
73
+ - [ ] "Obsolete Logic" to be evicted is explicitly declared.
74
+ - [ ] All impacted downstream Epics/Stories are identified and reverted to 🔴 High Ambiguity.
75
+ - [ ] Execution Sandbox contains exact file paths.
76
+ - [ ] Verification command is provided.
77
+ - [ ] `approved: true` is set in the YAML frontmatter.
@@ -0,0 +1,63 @@
1
+ <instructions>
2
+ This is a READ artifact. It is written by cleargate_pull_initiative when syncing a Sprint from the remote PM tool.
3
+ Do NOT draft this file manually. Do NOT invoke cleargate_push_item on this file.
4
+ The Vibe Coder may annotate the "Execution Guidelines" section locally — this section is never pushed.
5
+ Output location: .cleargate/plans/SPRINT-{ID}.md
6
+ Do NOT output these instructions.
7
+ </instructions>
8
+
9
+ ---
10
+ sprint_id: "SPRINT-{ID}"
11
+ remote_id: "{PM_TOOL_SPRINT_ID}"
12
+ source_tool: "linear | jira"
13
+ status: "Draft | Active | Completed"
14
+ start_date: "{YYYY-MM-DD}"
15
+ end_date: "{YYYY-MM-DD}"
16
+ synced_at: "{ISO-8601 timestamp}"
17
+ created_at: "2026-04-17T00:00:00Z"
18
+ updated_at: "2026-04-17T00:00:00Z"
19
+ created_at_version: "strategy-phase-pre-init"
20
+ updated_at_version: "strategy-phase-pre-init"
21
+ draft_tokens:
22
+ input: null
23
+ output: null
24
+ cache_read: null
25
+ cache_creation: null
26
+ model: null
27
+ sessions: []
28
+ cached_gate_result:
29
+ pass: null
30
+ failing_criteria: []
31
+ last_gate_check: null
32
+ ---
33
+
34
+ # SPRINT-{ID}: {Sprint Number / Name}
35
+
36
+ ## Sprint Goal
37
+ {One clear sentence describing the primary objective of this sprint, as defined in the PM tool.}
38
+
39
+ ## Consolidated Deliverables
40
+ *(Pulled from PM tool. IDs are the remote PM entity IDs.)*
41
+
42
+ - `{TASK-ID}`: {Title} — {Brief Description}
43
+ - `{TASK-ID}`: {Title} — {Brief Description}
44
+
45
+ ## Risks & Dependencies
46
+ *(As defined in the PM tool.)*
47
+
48
+ | Risk | Mitigation |
49
+ |---|---|
50
+ | {Description} | {Action} |
51
+
52
+ ## Metrics & Metadata
53
+ - **Expected Impact:** {e.g., performance improvement %, specific user outcome}
54
+ - **Priority Alignment:** {Notes on prioritization from the PM tool}
55
+
56
+ ---
57
+
58
+ ## Execution Guidelines (Local Annotation — Not Pushed)
59
+ *(Vibe Coder: Fill this in locally to direct Claude Code during the Execution Phase. This section never syncs to the PM tool.)*
60
+
61
+ - **Starting Point:** {Which deliverable to tackle first and why}
62
+ - **Relevant Context:** {Key documentation or codebase areas to reference}
63
+ - **Constraints:** {Specific technical boundaries or "out of scope" rules for this sprint}
@@ -0,0 +1,120 @@
1
+ <instructions>
2
+ FOLLOW THIS EXACT STRUCTURE. Output sections in order.
3
+ YAML Frontmatter: Epic ID, Status, Ambiguity, Context Source (MUST link to approved proposal.md), Owner, Target Date.
4
+ §0 Agent Handoff: XML block specifically formulated for AI coding agents to ingest.
5
+ §1 Problem & Value: Why (problem), What (solution), Success Metrics.
6
+ §2 Scope Boundaries: IN-SCOPE checkboxes, OUT-OF-SCOPE list.
7
+ §3 The Reality Check (Context): Constraints table.
8
+ §4 Technical Grounding: Verified files and data changes. Copied strictly from approved proposal.md.
9
+ §5 Acceptance Criteria: Gherkin scenarios (happy path + error cases).
10
+ §6 AI Interrogation Loop: Explicit questions the Planning AI needs the Human to answer.
11
+ Output location: .cleargate/delivery/pending-sync/EPIC-{NNN}_{epic_name}.md
12
+
13
+ Codebase research is mandatory. Do NOT guess at affected files.
14
+ You MUST base this strictly on an approved: true proposal document.
15
+ Do NOT output these instructions.
16
+ </instructions>
17
+
18
+ ---
19
+ epic_id: "EPIC-{ID}"
20
+ status: "Draft"
21
+ ambiguity: "🔴 High"
22
+ context_source: "PROPOSAL-{ID}.md"
23
+ owner: "{PM/PO name}"
24
+ target_date: "{YYYY-MM-DD}"
25
+ created_at: "2026-04-17T00:00:00Z"
26
+ updated_at: "2026-04-17T00:00:00Z"
27
+ created_at_version: "strategy-phase-pre-init"
28
+ updated_at_version: "strategy-phase-pre-init"
29
+ server_pushed_at_version: null
30
+ draft_tokens:
31
+ input: null
32
+ output: null
33
+ cache_read: null
34
+ cache_creation: null
35
+ model: null
36
+ sessions: []
37
+ cached_gate_result:
38
+ pass: null
39
+ failing_criteria: []
40
+ last_gate_check: null
41
+ ---
42
+
43
+ # EPIC-{ID}: {Epic Name}
44
+
45
+ ## 0. AI Coding Agent Handoff
46
+ *(This section is strictly for downstream AI execution agents. It contains zero business fluff.)*
47
+
48
+ ```xml
49
+ <agent_context>
50
+ <objective>{1 sentence strict technical objective}</objective>
51
+ <architecture_rules>
52
+ <rule>Must use existing {Component/Pattern}</rule>
53
+ <rule>No changes to {Protected Area}</rule>
54
+ </architecture_rules>
55
+ <target_files>
56
+ <file path="src/..." action="modify|create" />
57
+ </target_files>
58
+ </agent_context>
59
+ ```
60
+
61
+ ## 1. Problem & Value
62
+
63
+ **Why are we doing this?**
64
+ {1-2 sentences explaining the user pain or business value.}
65
+
66
+ **Success Metrics (North Star):**
67
+ - Metric 1: {Quantifiable outcome}
68
+
69
+ ## 2. Scope Boundaries
70
+
71
+ **✅ IN-SCOPE (Build This)**
72
+ - [ ] {Technical capability 1}
73
+ - [ ] {Technical capability 2}
74
+
75
+ **❌ OUT-OF-SCOPE (Do NOT Build This)**
76
+ - {Explicitly excluded capability to prevent scope creep / AI hallucination}
77
+
78
+ ## 3. The Reality Check (Context)
79
+
80
+ | Constraint Type | Limit / Rule |
81
+ |---|---|
82
+ | Performance | {e.g., Must complete in < 200ms} |
83
+ | Security | {e.g., No PII in logs} |
84
+
85
+ ## 4. Technical Grounding (The "Shadow Spec")
86
+ *(AI Planning Engine: Populate this strictly from the approved proposal.md)*
87
+
88
+ **Affected Files:**
89
+ - `path/to/file.ext` — {Why it changes}
90
+
91
+ **Data Changes:**
92
+ - Table/Entity: {New column/field}
93
+
94
+ ## 5. Acceptance Criteria
95
+
96
+ ```gherkin
97
+ Feature: {Epic Name}
98
+ Scenario: {Scenario Name}
99
+ Given {precondition}
100
+ When {action}
101
+ Then {outcome}
102
+ ```
103
+
104
+ ## 6. AI Interrogation Loop (Human Input Required)
105
+ *(AI Planning Engine: List edge cases, contradictions, or missing details found while drafting. The Epic stays 🔴 until the Human answers all of these.)*
106
+
107
+ - **AI Question:** "{e.g., You mentioned we need to send an email, but src/services/email doesn't support templates yet. Should we build the template engine first, or hardcode this one?}"
108
+ - **Human Answer:** {Waiting for user}
109
+
110
+ ---
111
+
112
+ ## ClearGate Ambiguity Gate (🟢 / 🟡 / 🔴)
113
+ **Current Status: 🔴 High Ambiguity**
114
+
115
+ Requirements to pass to Green (Ready for Coding Agent):
116
+ - [ ] Proposal document has `approved: true`.
117
+ - [ ] The `<agent_context>` block is complete and validated.
118
+ - [ ] §4 Technical Grounding contains 100% real, verified file paths.
119
+ - [ ] §6 AI Interrogation Loop is empty (all human answers integrated into the spec).
120
+ - [ ] 0 "TBDs" exist in the document.
@@ -0,0 +1,53 @@
1
+ <instructions>
2
+ This is a READ artifact. It is written by cleargate_pull_initiative when syncing from the remote PM tool.
3
+ Do NOT draft this file from scratch. Do NOT invoke cleargate_push_item on this file — it is already synced from the remote.
4
+ Use this file as context input when drafting a Proposal or Epic.
5
+ Output location: .cleargate/plans/INIT-{ID}.md
6
+ Do NOT output these instructions.
7
+ </instructions>
8
+
9
+ ---
10
+ initiative_id: "INIT-{ID}"
11
+ remote_id: "{PM_TOOL_ID}"
12
+ source_tool: "linear | jira"
13
+ status: "{PM native status}"
14
+ synced_at: "{ISO-8601 timestamp}"
15
+ created_at: "2026-04-17T00:00:00Z"
16
+ updated_at: "2026-04-17T00:00:00Z"
17
+ created_at_version: "strategy-phase-pre-init"
18
+ updated_at_version: "strategy-phase-pre-init"
19
+ draft_tokens:
20
+ input: null
21
+ output: null
22
+ cache_read: null
23
+ cache_creation: null
24
+ model: null
25
+ sessions: []
26
+ cached_gate_result:
27
+ pass: null
28
+ failing_criteria: []
29
+ last_gate_check: null
30
+ ---
31
+
32
+ # INIT-{ID}: {Initiative Name}
33
+
34
+ ## 1. Objective & Business Value
35
+ {High-level summary of what this initiative achieves and the expected outcome for the user or system.}
36
+
37
+ ## 2. Success Criteria
38
+ - {Concrete metric or functional requirement 1}
39
+ - {Concrete metric or functional requirement 2}
40
+
41
+ ## 3. Scope & Constraints
42
+
43
+ **In scope:**
44
+ - {What is included}
45
+
46
+ **Out of scope:**
47
+ - {What is explicitly excluded}
48
+
49
+ **Hard constraints:**
50
+ - {Deadlines, architectural rules, compliance requirements}
51
+
52
+ ## 4. Target Sprint / Timeline
53
+ {Sprint number or date range as defined in the PM tool.}
@@ -0,0 +1,52 @@
1
+ <instructions> FOLLOW THIS EXACT STRUCTURE. Output sections in order 1-4.
2
+ YAML Frontmatter: Proposal ID, Status, Author, and the crucial approved boolean.
3
+ §1 Initiative & Context: The "Why" and "What".
4
+ §2 Technical Architecture & Constraints: Architecture constraints, data flow, dependencies.
5
+ §3 Touched Files: Real files that will need modification.
6
+ Output location: .cleargate/delivery/pending-sync/PROPOSAL-{Name}.md
7
+
8
+ Document Hierarchy Position: LEVEL 0 (Proposal → Epic → Story)
9
+
10
+ CRITICAL PHASE GATE: Do NOT generate Epics or Stories, and do NOT invoke cleargate_push_item, until the Human has reviewed this document and manually changed approved: false to approved: true in the frontmatter.
11
+
12
+ Do NOT output these instructions. </instructions>
13
+
14
+ proposal_id: "PROP-{ID}" status: "Draft / In Review / Approved" author: "{AI Agent / Vibe Coder}" approved: false
15
+ created_at: "2026-04-17T00:00:00Z"
16
+ updated_at: "2026-04-17T00:00:00Z"
17
+ created_at_version: "strategy-phase-pre-init"
18
+ updated_at_version: "strategy-phase-pre-init"
19
+ server_pushed_at_version: null
20
+ draft_tokens:
21
+ input: null
22
+ output: null
23
+ cache_read: null
24
+ cache_creation: null
25
+ model: null
26
+ sessions: []
27
+ cached_gate_result:
28
+ pass: null
29
+ failing_criteria: []
30
+ last_gate_check: null
31
+ PROPOSAL-{ID}: {Initiative Name}
32
+ 1. Initiative & Context
33
+ 1.1 Objective
34
+ {1-2 sentences explaining the high-level goal and business value.}
35
+
36
+ 1.2 The "Why"
37
+ {Reason 1}
38
+ {Reason 2}
39
+ 2. Technical Architecture & Constraints
40
+ 2.1 Dependencies
41
+ {List required external APIs, packages, or systems}
42
+ 2.2 System Constraints
43
+ Constraint Details
44
+ Architectural Rules {e.g., Must use purely functional components, etc.}
45
+ Security {e.g., Data must be encrypted at rest.}
46
+ 3. Scope Impact (Touched Files & Data)
47
+ 3.1 Known Files
48
+ path/to/existing/file.ext - {Explanation of expected change}
49
+ 3.2 Expected New Entities
50
+ path/to/new/file.ext - {Explanation of purpose}
51
+ 🔒 Approval Gate
52
+ (Vibe Coder: Review this proposal. If the architecture and context are correct, change approved: false to approved: true in the YAML frontmatter. Only then is the AI authorized to proceed with Epic/Story decomposition.)
@@ -0,0 +1,135 @@
1
+ <instructions>
2
+ FOLLOW THIS EXACT STRUCTURE. Output sections in order 1-4.
3
+ YAML Frontmatter: Story ID, Parent Epic, Status, Ambiguity, Context Source (MUST link to approved proposal.md), Actor, Complexity Label.
4
+ §1 The Spec: User Story + Detailed Requirements + Out of Scope.
5
+ §2 The Truth: Gherkin acceptance criteria + manual verification steps.
6
+ §3 Implementation Guide: Files to modify, technical logic, API contract. Sourced from approved proposal.md.
7
+ §4 Quality Gates: Minimum test expectations + Definition of Done checklist.
8
+ Output location: .cleargate/delivery/pending-sync/STORY-{EpicID}-{StoryID}-{StoryName}.md
9
+
10
+ Document Hierarchy Position: LEVEL 2 (Proposal → Epic → Story)
11
+
12
+ Complexity Labels:
13
+ L1: Trivial — Single file, <1hr, known pattern
14
+ L2: Standard — 2-3 files, known pattern, ~2-4hr (default)
15
+ L3: Complex — Cross-cutting, spike may be needed, ~1-2 days
16
+ L4: Uncertain — Requires probing/spiking, >2 days
17
+
18
+ Granularity Rubric (run this check BEFORE emitting a story during epic-decomposition):
19
+ A candidate story is too big — emit two stories instead, with consecutive IDs (e.g. STORY-007-03 and STORY-007-04, never 03a/03b) — if ANY signal trips:
20
+ • §1.2 Detailed Requirements joins unrelated user goals with "and also" / "additionally".
21
+ • §2.1 Gherkin would need >5 scenarios covering unrelated behaviors.
22
+ • §3.1 Files-to-touch span unrelated subsystems (e.g. API + UI + migration in one story).
23
+ • Complexity would land at L4 (>2 days). L4 is a planning smell — split, or carve out a spike as its own story.
24
+ Also split the inverse: two candidate stories that each touch the same 1-2 files with overlapping scenarios should merge into one L1/L2.
25
+ At epic-decomposition time there are no remote IDs yet — splits and merges are free. Prefer two focused L1/L2 stories over one L3. Prefer L3 over L4.
26
+ When the rubric is ambiguous, surface the decision to the human as a one-liner ("candidate covers A+B — split into X and Y?") rather than guessing.
27
+
28
+ Do NOT output these instructions.
29
+ </instructions>
30
+
31
+ ---
32
+ story_id: "STORY-{EpicID}-{StoryID}-{StoryName}"
33
+ parent_epic_ref: "EPIC-{ID}"
34
+ status: "Draft"
35
+ ambiguity: "🔴 High"
36
+ context_source: "PROPOSAL-{ID}.md"
37
+ actor: "{Persona Name}"
38
+ complexity_label: "L2"
39
+ created_at: "2026-04-17T00:00:00Z"
40
+ updated_at: "2026-04-17T00:00:00Z"
41
+ created_at_version: "strategy-phase-pre-init"
42
+ updated_at_version: "strategy-phase-pre-init"
43
+ server_pushed_at_version: null
44
+ draft_tokens:
45
+ input: null
46
+ output: null
47
+ cache_read: null
48
+ cache_creation: null
49
+ model: null
50
+ sessions: []
51
+ cached_gate_result:
52
+ pass: null
53
+ failing_criteria: []
54
+ last_gate_check: null
55
+ ---
56
+
57
+ # STORY-{EpicID}-{StoryID}: {Story Name}
58
+ **Complexity:** {L1/L2/L3/L4} — {brief description}
59
+
60
+ ## 1. The Spec (The Contract)
61
+
62
+ ### 1.1 User Story
63
+ As a {Persona}, I want to {Action}, so that {Benefit}.
64
+
65
+ ### 1.2 Detailed Requirements
66
+ - Requirement 1: {Specific behavior}
67
+ - Requirement 2: {Specific data or constraint}
68
+
69
+ ### 1.3 Out of Scope
70
+ {What this story explicitly does NOT do.}
71
+
72
+ ## 2. The Truth (Executable Tests)
73
+
74
+ ### 2.1 Acceptance Criteria (Gherkin)
75
+
76
+ ```gherkin
77
+ Feature: {Story Name}
78
+
79
+ Scenario: {Happy Path}
80
+ Given {precondition}
81
+ When {user action}
82
+ Then {system response}
83
+
84
+ Scenario: {Edge Case / Error}
85
+ Given {precondition}
86
+ When {invalid action}
87
+ Then {error message}
88
+ ```
89
+
90
+ ### 2.2 Verification Steps (Manual)
91
+ - [ ] {e.g., "Verify API returns 200 for valid input"}
92
+ - [ ] {e.g., "Verify UI renders correctly on mobile"}
93
+
94
+ ## 3. The Implementation Guide
95
+
96
+ ### 3.1 Context & Files
97
+
98
+ | Item | Value |
99
+ |---|---|
100
+ | Primary File | `{filepath/to/main/component.ts}` |
101
+ | Related Files | `{filepath/to/api/service.ts}`, `{filepath/to/types.ts}` |
102
+ | New Files Needed | Yes/No — {Name of file} |
103
+
104
+ ### 3.2 Technical Logic
105
+ {Describe the logic flow, e.g., "Use the existing useAuth hook to check permissions."}
106
+
107
+ ### 3.3 API Contract (if applicable)
108
+
109
+ | Endpoint | Method | Auth | Request Shape | Response Shape |
110
+ |---|---|---|---|---|
111
+ | `/api/resource` | GET/POST | Bearer/None | `{ id: string }` | `{ status: string }` |
112
+
113
+ ## 4. Quality Gates
114
+
115
+ ### 4.1 Minimum Test Expectations
116
+
117
+ | Test Type | Minimum Count | Notes |
118
+ |---|---|---|
119
+ | Unit tests | {N} | {e.g., "1 per exported function"} |
120
+ | E2E / acceptance tests | {N} | {e.g., "1 per Gherkin scenario in §2.1"} |
121
+
122
+ ### 4.2 Definition of Done (The Gate)
123
+ - [ ] Minimum test expectations (§4.1) met.
124
+ - [ ] All Gherkin scenarios from §2.1 covered.
125
+ - [ ] Peer/Architect Review passed.
126
+
127
+ ---
128
+
129
+ ## ClearGate Ambiguity Gate (🟢 / 🟡 / 🔴)
130
+ **Current Status: 🔴 High Ambiguity**
131
+
132
+ Requirements to pass to Green (Ready for Execution):
133
+ - [ ] Gherkin scenarios completely cover all detailed requirements in §1.2.
134
+ - [ ] Implementation Guide (§3) maps to specific, verified file paths from the approved proposal.
135
+ - [ ] No "TBDs" exist anywhere in the specification or technical logic.
@@ -0,0 +1,42 @@
1
+ # ClearGate — Injected CLAUDE.md Block
2
+
3
+ This file is the content `cleargate init` injects into a downstream user's `CLAUDE.md` between bounded markers. If the user has no existing `CLAUDE.md`, init writes this as a standalone file wrapped with the markers. If one already exists, init appends the bounded block below without touching the user's existing content. Re-running `cleargate init` updates the block in place.
4
+
5
+ ---
6
+
7
+ <!-- CLEARGATE:START -->
8
+ ## 🔄 ClearGate Planning Framework
9
+
10
+ This repository uses **ClearGate** — a standalone planning framework for AI coding agents. ClearGate scaffolds *how work is planned* (proposals → epics → stories → sprints) and defines a four-agent loop for execution. ClearGate does not run builds, tests, or deployments; execution tooling remains the target repo's own.
11
+
12
+ **Session-start orientation (read in this order):**
13
+ 1. `.cleargate/wiki/index.md` — compiled awareness layer (~3k tokens). Lists active sprint, in-flight items, recent shipments, open gates, planned work, and topic synthesis pages. **Read this first** to know what exists before grepping raw files. If absent, run `cleargate wiki build`.
14
+ 2. `.cleargate/knowledge/cleargate-protocol.md` — delivery protocol (non-negotiable rules).
15
+ 3. `.cleargate/FLASHCARD.md` — lessons tagged by topic (`#schema`, `#auth`, etc.). Grep for your area before starting.
16
+
17
+ **Triage first, draft second.** Every user request gets classified (Epic / Story / CR / Bug / Pull / Push) *before* any drafting. If the type is ambiguous, ask ONE targeted question — do not guess.
18
+
19
+ **Duplicate check before drafting.** Before drafting a Proposal or work item, grep `.cleargate/delivery/archive/` + `.cleargate/FLASHCARD.md` for similar past work. If you find overlap, surface it as a one-liner (*"This is very close to STORY-003-05 shipped in SPRINT-01 — are you extending it or redoing it?"*) instead of drafting a duplicate.
20
+
21
+ **Halt at gates.** You halt at Gate 1 (Proposal approval) and Gate 2 (Ambiguity resolution) and wait for explicit human sign-off. You never call `cleargate_push_item` without `approved: true` and explicit human confirmation (Gate 3).
22
+
23
+ **Drafting work items:**
24
+ - Use the templates in `.cleargate/templates/` (`proposal.md`, `epic.md`, `story.md`, `CR.md`, `Bug.md`, `Sprint Plan Template.md`, `initiative.md`).
25
+ - Save drafts to `.cleargate/delivery/pending-sync/{TYPE}-{ID}-{Name}.md`.
26
+ - After `cleargate_push_item` returns a Remote ID, update the frontmatter AND move the file to `.cleargate/delivery/archive/` — these two happen atomically, never one without the other.
27
+ - **Story granularity.** When decomposing an epic into stories, run the Granularity Rubric at the top of `story.md`. If a candidate story trips any signal (unrelated goals joined, >5 Gherkin scenarios, subsystems span, L4 complexity), emit two stories with consecutive IDs instead. Splits and merges are free at decomposition time — no remote IDs exist yet.
28
+
29
+ **Four-agent loop (roles in `.claude/agents/`):**
30
+ - `architect.md` — one plan per milestone; no production code.
31
+ - `developer.md` — one Story end-to-end; one commit per Story; runs typecheck + tests before commit.
32
+ - `qa.md` — independent verification gate; re-runs checks; never commits, never edits.
33
+ - `reporter.md` — one sprint retrospective at sprint end; synthesizes token ledger + git log + flashcards into `REPORT.md`.
34
+
35
+ **Conversational style.** Keep replies terse. Details live in the work-item file and `REPORT.md`, not in chat. State results and next steps; skip narration of your own thought process.
36
+
37
+ **Support infrastructure.** Flashcard protocol: `.claude/skills/flashcard/SKILL.md`. Token-ledger hook: `.claude/hooks/token-ledger.sh`, wired via `.claude/settings.json` (SubagentStop) — auto-logs agent cost per sprint for the Reporter.
38
+
39
+ **Project overrides.** Content OUTSIDE this `<!-- CLEARGATE:START -->...<!-- CLEARGATE:END -->` block takes precedence where it conflicts with ClearGate defaults.
40
+
41
+ **Scope reminder.** ClearGate is a *planning* framework. It scaffolds how work gets planned and how the four-agent loop runs. It does not replace your project's build system, CI, test runner, or deployment tooling.
42
+ <!-- CLEARGATE:END -->