Format Markdown File Code Block
Purpose
Make technical Markdown notes easier to scan by formatting command-like content consistently:
- Multi-line command sequences -> fenced
bash code blocks
- Single command lines -> inline code
Scope
Use this skill when editing .md notes that contain shell/CLI commands mixed with prose.
Formatting Rules
- Preserve existing non-shell fenced blocks
- Do not alter fences such as
mermaid, json, yaml, python, typescript, etc.
- Rebuild shell-like formatting safely
- If needed, remove and rebuild only removable shell/text fences (
bash, sh, shell, zsh, fish, text, or empty language) to get consistent output.
- Multi-line sequences -> fenced block
- Group contiguous command/continuation lines into:
<command lines>
- Single command lines -> inline code
- Convert a single standalone command-like line to:
command ...
- Never format inside fenced blocks
- Skip all transformations while inside any existing fenced block.
Command Detection Heuristics
Treat a line as command-like when it matches one or more:
- Starts with known CLI verbs (
git, ssh, curl, docker, kubectl, python, npm, yarn, pnpm, brew, systemctl, etc.)
- Starts with prompt form (
$ ...)
- Looks like env assignment (
KEY=value)
- Looks like shell function/brace snippets (
name() {, {, })
- Uses shell operators (
|, &&, ||, >, <, ;) or explicit continuation (\\)
Heading Handling
Some notes store commands as headings (for example ### curl ... or ### -H ...).
- If a heading body is clearly command-like, demote it to a normal command line before block formatting.
- Keep true semantic headings unchanged.
Continuation Handling
While inside a command sequence, include continuation lines such as:
- option lines (
--foo, -H ..., including escaped variants like \-H ...)
- assignment lines
- lines ending with
\\
- connector/operator lines
Safety Guardrails
- Do not wrap prose paragraphs as code.
- Do not destroy Markdown links or note structure.
- Keep edits deterministic and minimal.
- Prefer one pass that is idempotent (running again should produce no further changes).
Verification Checklist
After formatting:
- Non-shell fences (e.g.,
mermaid) still exist and are unchanged.
- Multi-line commands are fenced.
- Single command lines are inline-coded.
- No command lines were formatted inside existing code fences.
- Spot-check beginning, middle, and end of each modified file.
Output Policy
- Keep original command text unchanged unless required to avoid formatting breakage.
- Use
bash language tag for inserted fenced shell blocks.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: format-markdownfile-code-block3description: Normalize Markdown notes so command/code lines are easy to read. Use fenced code blocks for multi-line command sequences and inline code for single-line commands while preserving existing non-shell code fences. Use when this capability is needed.4---56# Format Markdown File Code Block78## Purpose910Make technical Markdown notes easier to scan by formatting command-like content consistently:1112- Multi-line command sequences -> fenced `bash` code blocks13- Single command lines -> inline code1415## Scope1617Use this skill when editing `.md` notes that contain shell/CLI commands mixed with prose.1819## Formatting Rules20211. Preserve existing non-shell fenced blocks22- Do not alter fences such as `mermaid`, `json`, `yaml`, `python`, `typescript`, etc.23242. Rebuild shell-like formatting safely25- If needed, remove and rebuild only removable shell/text fences (`bash`, `sh`, `shell`, `zsh`, `fish`, `text`, or empty language) to get consistent output.26273. Multi-line sequences -> fenced block28- Group contiguous command/continuation lines into:2930```bash31<command lines>32```33344. Single command lines -> inline code35- Convert a single standalone command-like line to:3637`command ...`38395. Never format inside fenced blocks40- Skip all transformations while inside any existing fenced block.4142## Command Detection Heuristics4344Treat a line as command-like when it matches one or more:4546- Starts with known CLI verbs (`git`, `ssh`, `curl`, `docker`, `kubectl`, `python`, `npm`, `yarn`, `pnpm`, `brew`, `systemctl`, etc.)47- Starts with prompt form (`$ ...`)48- Looks like env assignment (`KEY=value`)49- Looks like shell function/brace snippets (`name() {`, `{`, `}`)50- Uses shell operators (`|`, `&&`, `||`, `>`, `<`, `;`) or explicit continuation (`\\`)5152## Heading Handling5354Some notes store commands as headings (for example `### curl ...` or `### -H ...`).5556- If a heading body is clearly command-like, demote it to a normal command line before block formatting.57- Keep true semantic headings unchanged.5859## Continuation Handling6061While inside a command sequence, include continuation lines such as:6263- option lines (`--foo`, `-H ...`, including escaped variants like `\-H ...`)64- assignment lines65- lines ending with `\\`66- connector/operator lines6768## Safety Guardrails6970- Do not wrap prose paragraphs as code.71- Do not destroy Markdown links or note structure.72- Keep edits deterministic and minimal.73- Prefer one pass that is idempotent (running again should produce no further changes).7475## Verification Checklist7677After formatting:7879- Non-shell fences (e.g., `mermaid`) still exist and are unchanged.80- Multi-line commands are fenced.81- Single command lines are inline-coded.82- No command lines were formatted inside existing code fences.83- Spot-check beginning, middle, and end of each modified file.8485## Output Policy8687- Keep original command text unchanged unless required to avoid formatting breakage.88- Use `bash` language tag for inserted fenced shell blocks.8990---91> Converted and distributed by [TomeVault](https://tomevault.io/claim/ye99) — claim your Tome and manage your conversions.92<!-- tomevault:4.0:skill_md:2026-04-14 -->