---
phase: 01-foundation-templates
plan: 04
type: execute
wave: 3
depends_on: [01-01, 01-02, 01-03]
files_modified: []
autonomous: false

must_haves:
  truths:
    - "User can read any template and understand what to fill in without external documentation"
    - "User can find systematic ID format (LOOP-NNN) by reading LOOPS template"
    - "User can identify checkpoint emoji meanings from PROTOCOL_REFERENCE"
    - "User can initialize session without MCP access (copy-paste workflow viable)"
    - "User can navigate template directory using README as entry point"
  artifacts:
    - path: ".planning/templates/LOOPS_TEMPLATE.md"
      provides: "Loop capture template"
      verified: "clear systematic ID format, lifecycle documented"
    - path: ".planning/templates/CONTEXT_TEMPLATE.md"
      provides: "Token budget template"
      verified: "thresholds defined, dbt examples present"
    - path: ".planning/templates/STATE_TEMPLATE.md"
      provides: "Session state template"
      verified: "available actions menu, context stack example"
    - path: ".planning/templates/BOOTLOADER_TEMPLATE.md"
      provides: "Session initialization template"
      verified: "sticky note template copy-pasteable"
    - path: ".planning/templates/SUMMARY_TEMPLATE.md"
      provides: "Session export template"
      verified: "GTD format clear"
    - path: ".planning/templates/PROTOCOL_REFERENCE.md"
      provides: "Protocol quick reference"
      verified: "all patterns documented"
    - path: ".planning/templates/README.md"
      provides: "Template navigation"
      verified: "workflow diagram present"
    - path: ".planning/AGENTS.md"
      provides: "Agent configuration"
      verified: "valid AGENTS.md format"
  key_links:
    - from: "User reading experience"
      to: "Template clarity"
      via: "Human review of inline comments"
      pattern: "Can user understand without external docs?"
    - from: "Template usability"
      to: "Copy-paste workflow"
      via: "Test without MCP access"
      pattern: "Does template work with copy-paste?"
    - from: "Educational value"
      to: "GSD mechanics understanding"
      via: "WHY comments in templates"
      pattern: "Does user learn from reading?"
---

<objective>
Verify that all templates are clear, actionable, and educational through automated pre-checks and human review.

Purpose: Ensure templates work for their intended audience (user learning GSD, agent following protocol) before considering Phase 1 complete.

Output: Verification confirmation that templates are production-ready, or identified gaps that need addressing.
</objective>

<execution_context>
@./.claude/get-shit-done/workflows/execute-plan.md
@./.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/01-foundation-templates/01-CONTEXT.md
@.planning/phases/01-foundation-templates/01-RESEARCH.md

# All created templates
@.planning/templates/LOOPS_TEMPLATE.md
@.planning/templates/CONTEXT_TEMPLATE.md
@.planning/templates/STATE_TEMPLATE.md
@.planning/templates/BOOTLOADER_TEMPLATE.md
@.planning/templates/SUMMARY_TEMPLATE.md
@.planning/templates/PROTOCOL_REFERENCE.md
@.planning/templates/README.md
@.planning/AGENTS.md
</context>

<tasks>

<task type="auto">
  <name>Task 1: Automated pre-verification of template completeness</name>
  <files>None (verification only)</files>
  <action>
Run automated checks to verify all templates were created by Plans 01-01, 01-02, 01-03 before human review:

**File existence checks:**
```bash
# Verify all template files exist
for file in LOOPS_TEMPLATE.md CONTEXT_TEMPLATE.md STATE_TEMPLATE.md BOOTLOADER_TEMPLATE.md SUMMARY_TEMPLATE.md PROTOCOL_REFERENCE.md README.md; do
  test -f ".planning/templates/$file" || echo "MISSING: .planning/templates/$file"
done

# Verify AGENTS.md exists
test -f ".planning/AGENTS.md" || echo "MISSING: .planning/AGENTS.md"
```

**Line count verification** (from must_haves):
```bash
# Check minimum line counts
wc -l .planning/templates/LOOPS_TEMPLATE.md | awk '{if ($1 < 80) print "LOOPS_TEMPLATE.md has "$1" lines, expected min 80"}'
wc -l .planning/templates/CONTEXT_TEMPLATE.md | awk '{if ($1 < 60) print "CONTEXT_TEMPLATE.md has "$1" lines, expected min 60"}'
wc -l .planning/templates/STATE_TEMPLATE.md | awk '{if ($1 < 70) print "STATE_TEMPLATE.md has "$1" lines, expected min 70"}'
wc -l .planning/templates/BOOTLOADER_TEMPLATE.md | awk '{if ($1 < 100) print "BOOTLOADER_TEMPLATE.md has "$1" lines, expected min 100"}'
wc -l .planning/templates/SUMMARY_TEMPLATE.md | awk '{if ($1 < 50) print "SUMMARY_TEMPLATE.md has "$1" lines, expected min 50"}'
wc -l .planning/templates/PROTOCOL_REFERENCE.md | awk '{if ($1 < 120) print "PROTOCOL_REFERENCE.md has "$1" lines, expected min 120"}'
wc -l .planning/templates/README.md | awk '{if ($1 < 30) print "README.md has "$1" lines, expected min 30"}'
wc -l .planning/AGENTS.md | awk '{if ($1 < 80) print "AGENTS.md has "$1" lines, expected min 80"}'
```

**Pattern verification** (from key_links in must_haves):
```bash
# Check for systematic ID pattern in LOOPS_TEMPLATE (fixed: use -E for extended regex)
grep -E 'LOOP-[0-9]{3}' .planning/templates/LOOPS_TEMPLATE.md || echo "LOOPS_TEMPLATE.md missing systematic ID pattern (LOOP-NNN)"

# Check for threshold patterns in CONTEXT_TEMPLATE
grep -q 'threshold="comfortable\|deliberate\|warning\|stop"' .planning/templates/CONTEXT_TEMPLATE.md || echo "CONTEXT_TEMPLATE.md missing threshold patterns"

# Check for action menu pattern in STATE_TEMPLATE
grep -q '/continue\|/pause\|/status' .planning/templates/STATE_TEMPLATE.md || echo "STATE_TEMPLATE.md missing action menu pattern"

# Check for sticky note marker in BOOTLOADER_TEMPLATE
grep -q '```gsd-status' .planning/templates/BOOTLOADER_TEMPLATE.md || echo "BOOTLOADER_TEMPLATE.md missing sticky note marker"

# Check for session metadata in SUMMARY_TEMPLATE
grep -q 'session_date\|loops_captured\|context_decisions' .planning/templates/SUMMARY_TEMPLATE.md || echo "SUMMARY_TEMPLATE.md missing session metadata pattern"

# Check for template links in PROTOCOL_REFERENCE
grep -q '@\.planning/templates/' .planning/templates/PROTOCOL_REFERENCE.md || echo "PROTOCOL_REFERENCE.md missing template links"

# Check for command patterns in AGENTS.md
grep -q '/[a-z-]\+' .planning/AGENTS.md || echo "AGENTS.md missing command patterns"
```

**Cross-reference verification:**
```bash
# Check README lists all templates
for template in LOOPS_TEMPLATE CONTEXT_TEMPLATE STATE_TEMPLATE BOOTLOADER_TEMPLATE SUMMARY_TEMPLATE; do
  grep -q "$template" .planning/templates/README.md || echo "README.md missing reference to $template"
done

# Check PROTOCOL_REFERENCE links to templates
grep -q 'PROTOCOL_REFERENCE' .planning/AGENTS.md || echo "AGENTS.md missing link to PROTOCOL_REFERENCE.md"
```

If any checks fail, report them clearly. This ensures human isn't reviewing incomplete work.
  </action>
  <verify>
Run all verification commands above. Expected output: No error messages (all files exist, meet line counts, contain expected patterns, cross-references work).
  </verify>
  <done>
All automated pre-checks pass: templates exist, meet minimum requirements, contain expected patterns, and cross-references are intact
  </done>
</task>

<task type="checkpoint:human-verify" gate="blocking">
  <what-built>
Complete template foundation for data engineering copilot patterns:

**Templates created:**
- LOOPS_TEMPLATE.md (loop capture with systematic IDs)
- CONTEXT_TEMPLATE.md (token budget tracking)
- STATE_TEMPLATE.md (session state management)
- BOOTLOADER_TEMPLATE.md (session initialization and sticky note protocol)
- SUMMARY_TEMPLATE.md (session export for GTD)
- PROTOCOL_REFERENCE.md (quick reference for all patterns)
- README.md (template directory navigation)

**Configuration:**
- AGENTS.md (cross-platform agent configuration)

**Location:** `.planning/templates/` and `.planning/AGENTS.md`

**Automated pre-verification:** Task 1 confirmed all files exist, meet minimum requirements, and contain expected patterns.
  </what-built>

  <how-to-verify>
Review templates for clarity, actionability, and educational value:

**1. Clarity Check** (Can user understand what to do?)
   - Open each template in `.planning/templates/`
   - Check: Is it clear what information goes in each section?
   - Check: Are examples realistic and from data engineering domain?
   - Check: Is the structure obvious (headers, sections, formatting)?

**2. Educational Value** (Can user learn from reading?)
   - Look for inline comments explaining WHY sections exist
   - Check: Do comments explain GSD mechanics?
   - Check: Do comments explain data engineering patterns?
   - Check: Would reading template teach someone new to GSD?

**3. Actionability** (Can agent/user follow template?)
   - For LOOPS: Is systematic ID format (LOOP-NNN) clear?
   - For CONTEXT: Are token budget thresholds (20/40/50%) defined?
   - For STATE: Is available actions menu present?
   - For BOOTLOADER: Is sticky note template copy-pasteable?
   - For SUMMARY: Is GTD export format clear?

**4. Cross-references** (Do templates link appropriately?)
   - Check README.md lists all templates with purposes
   - Check PROTOCOL_REFERENCE.md links to all templates
   - Check AGENTS.md links to PROTOCOL_REFERENCE
   - Check BOOTLOADER links to other templates

**5. Workflow Coverage** (Do templates cover single-session workflow?)
   - Session start: BOOTLOADER initializes
   - During work: STATE tracked, LOOPS captured, CONTEXT managed
   - Session end: SUMMARY exports to GTD
   - Can user follow this workflow with just these templates?

**6. Platform Compatibility** (MCP vs copy-paste)
   - Check templates have dual instructions where relevant
   - Check AGENTS.md mentions fallback for non-supporting platforms
   - Check templates work without assuming MCP access

**7. Cross-Platform Testing** (NEW - addresses phase success criterion)
   - **MCP scenario**: Verify BOOTLOADER mentions file access via MCP tools
   - **Copy-paste scenario**: Verify BOOTLOADER includes "Please paste STATE.md contents" workflow
   - Test workflow: Can user initialize session without MCP by following BOOTLOADER instructions?
   - Test workflow: Can agent maintain protocol using sticky notes regardless of file access method?
   - Expected: Both scenarios are explicitly supported in BOOTLOADER with clear instructions

**8. Requirements Coverage** (Phase 1 goals met?)
   - META-01: Templates heavily commented? (check inline comments)
   - META-02: File-based protocol works via MCP or copy-paste? (check dual instructions in BOOTLOADER, verify both modes explicitly documented)
   - Success criteria from ROADMAP: Inline GSD explanations, works across agents, user understands what and why?

**Expected observations:**
✓ Each template has clear structure and examples
✓ Inline comments explain WHY for major sections
✓ Systematic IDs, checkpoints, sticky notes documented
✓ README provides entry point and workflow diagram
✓ AGENTS.md valid format with protocol summary
✓ Cross-references work (README → templates, AGENTS.md → PROTOCOL_REFERENCE → templates)
✓ Templates cover full single-session workflow
✓ Works in both MCP and copy-paste scenarios (explicitly tested and verified)
  </how-to-verify>

  <resume-signal>
**If templates are clear and complete:**
Type "approved" to mark Phase 1 complete

**If issues found:**
Describe specific gaps (e.g., "LOOPS template missing lifecycle documentation", "BOOTLOADER sticky note format unclear", "README workflow diagram missing", "Copy-paste workflow not clearly explained in BOOTLOADER")

Agent will create gap closure plan to address identified issues before marking phase complete.
  </resume-signal>
</task>

</tasks>

<verification>
After Task 1, verify:
- All template files exist at expected paths
- Files meet minimum line counts from must_haves
- Files contain expected patterns (systematic IDs, XML structures, etc.)

After Task 2, human verification covers:
- Template clarity (can user/agent understand what to do?)
- Educational value (do inline comments teach GSD mechanics?)
- Actionability (are formats copy-pasteable, examples realistic?)
- Cross-references (do documents link appropriately?)
- Workflow coverage (do templates support full session lifecycle?)
- Platform compatibility (MCP and copy-paste both work?)
- Cross-platform testing (both workflows explicitly tested and verified functional)
- Requirements coverage (META-01, META-02 satisfied?)
</verification>

<success_criteria>
Phase 1 complete when:
- Automated pre-checks pass (Task 1 confirms templates meet basic requirements)
- User confirms all templates are clear and actionable
- Inline comments explain GSD mechanics and data engineering patterns
- Templates work in both MCP and copy-paste workflows (explicitly verified through cross-platform testing)
- Template directory navigable via README
- Requirements META-01 and META-02 satisfied
- No blocking gaps identified in verification

If gaps found: Create gap closure plan before marking phase complete
</success_criteria>

<output>
After approval, create `.planning/phases/01-foundation-templates/01-04-SUMMARY.md`
</output>
