Split large markdown files into manageable sections with automatic navigation
Split large markdown files into manageable sections with automatic table of contents and navigation links. Use when files exceed 2000 lines or become difficult to navigate.
/plugin marketplace add moinsen-dev/claude_code_marketplace/plugin install guard@moinsen-coderIntelligently split a large markdown file into context-friendly sections with automatic table of contents and navigation.
# Split a specific markdown file
/guard:split-markdown <file-path>
# Examples
/guard:split-markdown task.md
/guard:split-markdown docs/PRD.md
/guard:split-markdown ./planning/requirements.md
When you split a markdown file, the Guard plugin will:
00-<basename>.md with table of contents and navigation01-, 02-, etc.) for each section<filename>.backupFor a file named task.md, you'll get:
task.md.backup # Original file (backup)
00-task.md # Index with TOC
01-task.md # First section
02-task.md # Second section
03-task.md # Third section
...
Contains:
Each section includes:
The splitting behavior is controlled by .claude/quality_config.json:
{
"markdown_splitter": {
"enabled": true,
"auto_suggest_threshold": 2000,
"target_chunk_size": 800,
"split_strategy": "headers",
"preserve_original": true,
"create_index": true
}
}
auto_suggest_threshold (default: 2000)
target_chunk_size (default: 800)
split_strategy (default: "headers")
"headers" - Split at each top-level header (# title)"smart" - Group sections to target chunk size while respecting boundariespreserve_original (default: true)
<filename>.backupcreate_index (default: true)
00-<basename>.md index fileSplits at every top-level header (# Title):
Pros:
Cons:
Best for:
Groups sections to target chunk size while respecting header boundaries:
Pros:
Cons:
Best for:
/guard:split-markdown requirements.md
Before:
requirements.md (3500 lines)
# Overview
# User Stories
# Technical Requirements
# Architecture
# Testing Strategy
After:
requirements.md.backup
00-requirements.md (index)
01-requirements.md (Overview - 400 lines)
02-requirements.md (User Stories - 900 lines)
03-requirements.md (Technical Requirements - 1100 lines)
04-requirements.md (Architecture - 700 lines)
05-requirements.md (Testing Strategy - 400 lines)
/guard:split-markdown tasks.md
Before:
tasks.md (4200 lines)
# Backend Tasks
## API Endpoints (many subtasks)
## Database Schema (many subtasks)
# Frontend Tasks
## Components (many subtasks)
## Pages (many subtasks)
After:
tasks.md.backup
00-tasks.md (index)
01-tasks.md (Backend Tasks - 2100 lines)
02-tasks.md (Frontend Tasks - 2100 lines)
/guard:split-markdown api-docs.md
With "split_strategy": "smart" in config:
Before:
api-docs.md (5000 lines)
# Authentication
# User Endpoints (50+ endpoints)
# Data Endpoints (40+ endpoints)
# Admin Endpoints (30+ endpoints)
After:
api-docs.backup
00-api-docs.md (index)
01-api-docs.md (Authentication - 600 lines)
02-api-docs.md (User Endpoints Part 1 - 800 lines)
03-api-docs.md (User Endpoints Part 2 - 850 lines)
04-api-docs.md (Data Endpoints Part 1 - 800 lines)
05-api-docs.md (Data Endpoints Part 2 - 750 lines)
06-api-docs.md (Admin Endpoints - 700 lines)
Split a markdown file when:
The markdown splitter integrates with Guard's file size checking:
This provides proactive splitting suggestions without manual command invocation.
This command launches the markdown-splitter agent with the specified file:
# The agent will:
# 1. Read and analyze the file structure
# 2. Present a proposed split plan
# 3. Ask for confirmation
# 4. Execute the split using split_markdown.py
# 5. Verify results and report success
/guard:config - View and configure splitting thresholds/guard:init - Initialize Guard with default configuration.claude/quality_config.json - Configuration fileNeed help? The markdown-splitter agent will guide you through the process and explain each step.