Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By diegomarinov1.1.0MITIn 1 marketplace
Cleans up markdown files so agents spend fewer tokens reading them, fixing whitespace, heading order and code block style. A hook runs markdownlint --fix on every .md file Claude writes or edits, unless the file opts out.
Trending plugins
7-day copy clicks
Claude loads one when your task matches it, or you run it by name.
1 caution to review before installing
A hook runs when Claude writes or edits files
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
1 marketplace, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Trim and optimize markdown files for LLM agent consumption. Removes token waste (extra blank lines, trailing whitespace, hard tabs), normalizes document structure (heading hierarchy, code block style), and produces a summary of changes.
See the root README for a quick overview.
/plugin install trim-md@claude-toolshed
Requires: Node.js (for npx markdownlint-cli2, auto-downloaded on first run)
| Command | What it does |
|---|---|
/trim-md docs/ | Fix all markdown files in docs/ |
/trim-md file.md other.md | Fix specific files |
/trim-md dry-run . | Preview what would change without modifying files |
/trim-md | Fix all markdown files in current directory |
The dry-run flag is flexible — dry, dry-run, --dry-run, and dryrun are all recognized.
The plugin includes a PostToolUse hook that automatically formats .md files whenever Claude writes or edits them. No manual invocation needed — every markdown file touched during a session gets lint-fixed and table-compacted on the fly.
The hook is registered in hooks/hooks.json and activates automatically when the plugin is installed. It:
.md files immediately (zero overhead for other file types)trim-md.sh on the single file (markdownlint --fix + table compaction)To disable the hook without uninstalling the plugin, use /hooks in Claude Code and delete the trim-md entry.
The skill delegates to a bash script (trim-md.sh) that:
.md and .markdown files from the given paths (recursive for directories)node_modules/, .worktrees/, .git/, .pytest_cache/, .venv/, __pycache__/<!-- trim-md:disable --> opt-out commentnpx markdownlint-cli2 --fix (or lint-only in dry-run mode)The plugin ships two markdownlint configs to avoid conflicts with existing project linters:
| Mode | Config | When used | Rules |
|---|---|---|---|
| full | full.markdownlint-cli2.jsonc | No existing markdownlint config detected | 15 rules (token waste + heading hierarchy + structural clarity) |
| safe | safe.markdownlint-cli2.jsonc | Existing .markdownlint* config found at project root | 4 rules (universally non-conflicting) |
Detection: The script resolves the project root via git rev-parse --show-toplevel (fallback: pwd), then checks for any file matching .markdownlint* or .markdownlint-cli2* at that root. No config parsing — just file existence.
Add this HTML comment on its own line anywhere in a markdown file to exclude it from processing:
<!-- trim-md:disable -->
The comment must appear as a standalone line (with optional leading/trailing whitespace). Inline mentions within prose, code blocks, or frontmatter are ignored. The comment is invisible in rendered markdown.
Token waste reduction — removes bytes that get tokenized but carry zero semantic value:
| Rule | Name | LLM rationale |
|---|---|---|
| MD009 | No trailing spaces | Invisible bytes that still consume tokens |
| MD010 | No hard tabs | Tabs tokenize inconsistently across models |
| MD012 | No multiple blank lines (max: 1) | Each blank line wastes ~1 token |
| MD047 | File ends with newline | Prevents tokenization edge cases at file boundaries |
Heading hierarchy — headings are the #1 structural signal for RAG chunking:
| Rule | Name | LLM rationale |
|---|---|---|
| MD001 | Heading increment | Skipped levels break semantic hierarchy; RAG uses headings as chunk boundaries |
| MD003 | ATX heading style | Consistent # headings; Setext underlines waste tokens |
| MD022 | Blanks around headings | Clean section boundaries for chunking |
| MD025 | Single top-level H1 | Unambiguous document root for hierarchy parsing |
Structural clarity — clean boundaries help LLMs parse document structure:
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub diegomarino/claude-toolshed --plugin trim-mdPlugins from other owners that cover similar ground