5.8 KiB
5.8 KiB
Document Migration Task
Purpose
Migrate BMAD-METHOD documents to match V4 template structure exactly, preserving all content while enforcing strict template compliance.
Task Requirements
- Input: User MUST specify the document to migrate (e.g.,
docs/prd.md) - Template: User MUST specify the V4 template to use (e.g.,
.bmad-core/templates/prd-tmpl.md) - Validation: Verify document and template are compatible types
- Output: Creates migrated document with original name, backs up original with
.bakextension
[[LLM: VALIDATION REQUIREMENTS:
- Both input document and template paths MUST be provided by the user
- Do NOT assume or select templates automatically
- Validate that document type matches template type (e.g., PRD → PRD template)
- Reject incompatible migrations (e.g., PRD → architecture template)
]]
Migration Rules
Strict Template Compliance
[[LLM: CRITICAL RULES:
- The ONLY Level 2 headings (##) allowed are EXACTLY those in the V4 template
- No additions, no removals, no modifications to Level 2 headings
- All user content must be preserved and placed under appropriate template sections
- Remove any existing table of contents
- Never delete user content - find the most appropriate section
- DO NOT add any LLM prompts, placeholders, or "TBD" content
- Leave empty sections empty - no instructions or guidance text
]]
Content Migration Process
-
Read Template Structure
- Extract all Level 2 headings from the V4 template
- These are the ONLY Level 2 headings allowed in the final document
-
Analyze Original Document
- Identify all content blocks
- Note original section organization
- Flag any custom sections
-
Create Backup First
- Rename original file:
mv filename.md filename.md.bak - This preserves the original completely
- Rename original file:
-
Create New File
- Create new
filename.mdfrom scratch - Start with template structure (all Level 2 headings)
- For each content block from original:
- Find the most appropriate V4 template section
- If original had Level 2 heading not in template, demote to Level 3
- Preserve all text, lists, code blocks, diagrams, tables
- Remove only table of contents sections
- IMPORTANT: Do NOT add any LLM prompts, placeholders, or instructions
- If a template section has no matching content, leave it empty
- Create new
-
Validate Content Preservation
- For each major content block from original (excluding headings):
- Use grep or search to verify it exists in new file
- Report any content that couldn't be verified
- This ensures no accidental content loss
- For each major content block from original (excluding headings):
Example Migration
Original (prd.md):
## Executive Summary
[content...]
## Custom Feature Section
[content...]
## Table of Contents
[toc...]
Template (prd-tmpl.md):
## Goals and Background Context
## Functional Requirements
## Success Metrics and KPIs
Result (prd.md):
## Goals and Background Context
[executive summary content moved here]
### Custom Feature Section
[content preserved but demoted to Level 3]
## Functional Requirements
## Success Metrics and KPIs
Execution Instructions
[[LLM: When executing this task:
- Ask user for BOTH: input file path AND template path (do not assume)
- Validate compatibility:
- Check document title/type (PRD, Architecture, etc.)
- Ensure template matches document type
- REJECT if types don't match (e.g., "Cannot migrate PRD to architecture template")
- Read both files completely
- Rename original to .bak:
mv original.md original.md.bak - Extract Level 2 headings from template - these are MANDATORY
- Create NEW file with original name
- Build new content:
- Start with all template Level 2 sections
- Map original content to appropriate sections
- Demote any non-template Level 2 headings to Level 3
- Leave empty sections empty (no placeholders or instructions)
- Validate content preservation:
- Extract key content snippets from .bak file
- Use grep to verify each exists in new file
- Report any missing content
- Report migration summary:
- Sections moved/demoted
- Content validation results
- Any manual review needed
]]
Document Type Detection
[[LLM: Detect document type by examining:
- File name (prd.md, architecture.md, etc.)
- Main title (# Product Requirements Document, # Architecture, etc.)
- Content patterns (user stories → PRD, technology stack → Architecture)
Template compatibility:
- prd-tmpl.md → Only for PRD documents
- architecture-tmpl.md → Only for backend/single architecture
- full-stack-architecture-tmpl.md → Only for architecture documents (can merge multiple)
]]
Common Migrations
Valid migrations:
prd.md→.bmad-core/templates/prd-tmpl.mdarchitecture.md→.bmad-core/templates/architecture-tmpl.mdarchitecture.md+front-end-architecture.md→.bmad-core/templates/full-stack-architecture-tmpl.md
Invalid migrations (MUST REJECT):
prd.md→.bmad-core/templates/architecture-tmpl.mdarchitecture.md→.bmad-core/templates/prd-tmpl.mdux-ui-spec.md→.bmad-core/templates/prd-tmpl.md
Validation
After migration verify:
- All Level 2 headings match template exactly
- All original content is preserved (use grep validation)
- No table of contents remains
- Backup file exists with .bak extension
- Custom sections demoted to Level 3 or lower
Content Validation Example
[[LLM: Example validation approach:
- Extract significant text blocks from .bak file (>20 words)
- For each block, grep in new file:
grep -F "first 10-15 words of content block" newfile.md - Track validation results:
- ✓ Found: content successfully migrated
- ✗ Missing: needs investigation
- Report any content that couldn't be found
]]