[[LLM: First, check if markdownExploder is set to true in .bmad-core/core-config.yaml. If it is, attempt to run the command: md-tree explode {input file} {output path}.
If the command succeeds, inform the user that the document has been sharded successfully and STOP - do not proceed further.
If the command fails (especially with an error indicating the command is not found or not available), inform the user: "The markdownExploder setting is enabled but the md-tree command is not available. Please either:
npm install -g @kayvan/markdown-tree-parserIMPORTANT: STOP HERE - do not proceed with manual sharding until one of the above actions is taken."
If markdownExploder is set to false, inform the user: "The markdownExploder setting is currently false. For better performance and reliability, you should:
npm install -g @kayvan/markdown-tree-parserI will now proceed with the manual sharding process."
Then proceed with the manual method below ONLY if markdownExploder is false.]]
Install globally:
npm install -g @kayvan/markdown-tree-parser
Use the explode command:
# For PRD
md-tree explode docs/prd.md docs/prd
# For Architecture
md-tree explode docs/architecture.md docs/architecture
# For any document
md-tree explode [source-document] [destination-folder]
What it does:
If the user has @kayvan/markdown-tree-parser installed, use it and skip the manual process below.
docs/ with the same name as the document (without extension)docs/prd.md → create folder docs/prd/CRITICAL AEGNT SHARDING RULES:
CRITICAL: Use proper parsing that understands markdown context. A ## inside a code block is NOT a section header.]]
For each extracted section:
Generate filename: Convert the section heading to lowercase-dash-case
tech-stack.mdAdjust heading levels:
All subsection levels decrease by 1:
- ### → ##
- #### → ###
- ##### → ####
- etc.
Write content: Save the adjusted content to the new file
Create an index.md file in the sharded folder that:
Lists all the sharded files with links:
# Original Document Title
[Original introduction content if any]
## Sections
- [Section Name 1](./section-name-1.md)
- [Section Name 2](./section-name-2.md)
- [Section Name 3](./section-name-3.md)
...
Code blocks: Must capture complete blocks including:
content
Mermaid diagrams: Preserve complete syntax:
graph TD
...
Tables: Maintain proper markdown table formatting
Lists: Preserve indentation and nesting
Inline code: Preserve backticks
Links and references: Keep all markdown links intact
Template markup: If documents contain {{placeholders}} ,preserve exactly
After sharding:
Provide a summary:
Document sharded successfully:
- Source: [original document path]
- Destination: docs/[folder-name]/
- Files created: [count]
- Sections:
- section-name-1.md: "Section Title 1"
- section-name-2.md: "Section Title 2"
...