$npx -y skills add jimliu/baoyu-skills --skill baoyu-format-markdownFormats plain text or markdown files with frontmatter, titles, summaries, headings, bold, lists, and code blocks. Use when user asks to "format markdown", "beautify article", "add formatting", or improve article layout. Outputs to {filename}-formatted.md.
| 1 | # Markdown Formatter |
| 2 | |
| 3 | Transforms plain text or markdown into well-structured, reader-friendly markdown. The goal is to help readers quickly grasp key points, highlights, and structure — without changing any original content. |
| 4 | |
| 5 | **Core principle**: Only adjust formatting and fix obvious typos. Never add, delete, or rewrite content. |
| 6 | |
| 7 | ## User Input Tools |
| 8 | |
| 9 | When this skill prompts the user, follow this tool-selection rule (priority order): |
| 10 | |
| 11 | 1. **Prefer built-in user-input tools** exposed by the current agent runtime — e.g., `AskUserQuestion`, `request_user_input`, `clarify`, `ask_user`, or any equivalent. |
| 12 | 2. **Fallback**: if no such tool exists, emit a numbered plain-text message and ask the user to reply with the chosen number/answer for each question. |
| 13 | 3. **Batching**: if the tool supports multiple questions per call, combine all applicable questions into a single call; if only single-question, ask them one at a time in priority order. |
| 14 | |
| 15 | Concrete `AskUserQuestion` references below are examples — substitute the local equivalent in other runtimes. |
| 16 | |
| 17 | ## Script Directory |
| 18 | |
| 19 | Scripts in `scripts/` subdirectory. `{baseDir}` = this SKILL.md's directory path. Resolve `${BUN_X}` runtime: if `bun` installed → `bun`; if `npx` available → `npx -y bun`; else suggest installing bun. Replace `{baseDir}` and `${BUN_X}` with actual values. |
| 20 | |
| 21 | | Script | Purpose | |
| 22 | |--------|---------| |
| 23 | | `scripts/main.ts` | Main entry point with CLI options (uses remark-cjk-friendly for CJK emphasis) | |
| 24 | | `scripts/quotes.ts` | Replace ASCII quotes with fullwidth quotes | |
| 25 | | `scripts/autocorrect.ts` | Add CJK/English spacing via autocorrect | |
| 26 | |
| 27 | ## Preferences (EXTEND.md) |
| 28 | |
| 29 | Check EXTEND.md in priority order — the first one found wins: |
| 30 | |
| 31 | | Priority | Path | Scope | |
| 32 | |----------|------|-------| |
| 33 | | 1 | `.baoyu-skills/baoyu-format-markdown/EXTEND.md` | Project | |
| 34 | | 2 | `${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-format-markdown/EXTEND.md` | XDG | |
| 35 | | 3 | `$HOME/.baoyu-skills/baoyu-format-markdown/EXTEND.md` | User home | |
| 36 | |
| 37 | If none found, use defaults — no first-time setup required for this skill. |
| 38 | |
| 39 | **EXTEND.md supports**: |
| 40 | |
| 41 | | Setting | Values | Default | Description | |
| 42 | |---------|--------|---------|-------------| |
| 43 | | `auto_select` | `true`/`false` | `false` | Skip both title and summary selection, auto-pick best | |
| 44 | | `auto_select_title` | `true`/`false` | `false` | Skip title selection only | |
| 45 | | `auto_select_summary` | `true`/`false` | `false` | Skip summary selection only | |
| 46 | | Other | — | — | Default formatting options, typography preferences | |
| 47 | |
| 48 | ## Usage |
| 49 | |
| 50 | The workflow has two phases: **Analyze** (understand the content) then **Format** (apply formatting). Claude performs content analysis and formatting (Steps 1-5), then runs the script for typography fixes (Step 6). |
| 51 | |
| 52 | ## Workflow |
| 53 | |
| 54 | ### Step 1: Read & Detect Content Type |
| 55 | |
| 56 | Read the user-specified file, then detect content type: |
| 57 | |
| 58 | | Indicator | Classification | |
| 59 | |-----------|----------------| |
| 60 | | Has `---` YAML frontmatter | Markdown | |
| 61 | | Has `#`, `##`, `###` headings | Markdown | |
| 62 | | Has `**bold**`, `*italic*`, lists, code blocks, blockquotes | Markdown | |
| 63 | | None of above | Plain text | |
| 64 | |
| 65 | **If Markdown detected, use `AskUserQuestion` to ask:** |
| 66 | |
| 67 | ``` |
| 68 | Detected existing markdown formatting. What would you like to do? |
| 69 | |
| 70 | 1. Optimize formatting (Recommended) |
| 71 | - Analyze content, improve headings, bold, lists for readability |
| 72 | - Run typography script (spacing, emphasis fixes) |
| 73 | - Output: {filename}-formatted.md |
| 74 | |
| 75 | 2. Keep original formatting |
| 76 | - Preserve existing markdown structure |
| 77 | - Run typography script only |
| 78 | - Output: {filename}-formatted.md |
| 79 | |
| 80 | 3. Typography fixes only |
| 81 | - Run typography script on original file in-place |
| 82 | - No copy created, modifies original file directly |
| 83 | ``` |
| 84 | |
| 85 | **Based on user choice:** |
| 86 | - **Optimize**: Continue to Step 2 (full workflow) |
| 87 | - **Keep original**: Skip to Step 5, copy file then run Step 6 |
| 88 | - **Typography only**: Skip to Step 6, run on original file directly |
| 89 | |
| 90 | ### Step 2: Analyze Content (Reader's Perspective) |
| 91 | |
| 92 | Read the entire content carefully. Think from a reader's perspective: what would help them quickly understand and remember the key information? |
| 93 | |
| 94 | Produce an analysis covering these dimensions: |
| 95 | |
| 96 | **2.1 Highlights & Key Insights** |
| 97 | - Core arguments or conclusions the author makes |
| 98 | - Surprising facts, data points, or counterintuitive claims |
| 99 | - Memorable quotes or well-phrased sentences (golden quotes) |
| 100 | |
| 101 | **2.2 Structure Assessment** |
| 102 | - Does the content have a clear logical flow? What is it? |
| 103 | - Are there natural section boundaries that lack headin |