$npx -y skills add ECNU-ICALK/AutoSkill --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 files into well-structured markdown with proper frontmatter, formatting, and typography. |
| 4 | |
| 5 | ## Script Directory |
| 6 | |
| 7 | Scripts in `scripts/` subdirectory. Replace `${SKILL_DIR}` with this SKILL.md's directory path. |
| 8 | |
| 9 | | Script | Purpose | |
| 10 | |--------|---------| |
| 11 | | `scripts/main.ts` | Main entry point with CLI options (uses remark-cjk-friendly for CJK emphasis) | |
| 12 | | `scripts/quotes.ts` | Replace ASCII quotes with fullwidth quotes | |
| 13 | | `scripts/autocorrect.ts` | Add CJK/English spacing via autocorrect | |
| 14 | |
| 15 | ## Preferences (EXTEND.md) |
| 16 | |
| 17 | Use Bash to check EXTEND.md existence (priority order): |
| 18 | |
| 19 | ```bash |
| 20 | # Check project-level first |
| 21 | test -f .baoyu-skills/baoyu-format-markdown/EXTEND.md && echo "project" |
| 22 | |
| 23 | # Then user-level (cross-platform: $HOME works on macOS/Linux/WSL) |
| 24 | test -f "$HOME/.baoyu-skills/baoyu-format-markdown/EXTEND.md" && echo "user" |
| 25 | ``` |
| 26 | |
| 27 | ┌──────────────────────────────────────────────────────────┬───────────────────┐ |
| 28 | │ Path │ Location │ |
| 29 | ├──────────────────────────────────────────────────────────┼───────────────────┤ |
| 30 | │ .baoyu-skills/baoyu-format-markdown/EXTEND.md │ Project directory │ |
| 31 | ├──────────────────────────────────────────────────────────┼───────────────────┤ |
| 32 | │ $HOME/.baoyu-skills/baoyu-format-markdown/EXTEND.md │ User home │ |
| 33 | └──────────────────────────────────────────────────────────┴───────────────────┘ |
| 34 | |
| 35 | ┌───────────┬───────────────────────────────────────────────────────────────────────────┐ |
| 36 | │ Result │ Action │ |
| 37 | ├───────────┼───────────────────────────────────────────────────────────────────────────┤ |
| 38 | │ Found │ Read, parse, apply settings │ |
| 39 | ├───────────┼───────────────────────────────────────────────────────────────────────────┤ |
| 40 | │ Not found │ Use defaults │ |
| 41 | └───────────┴───────────────────────────────────────────────────────────────────────────┘ |
| 42 | |
| 43 | **EXTEND.md Supports**: Default formatting options | Summary length preferences |
| 44 | |
| 45 | ## Usage |
| 46 | |
| 47 | Claude performs content analysis and formatting (Steps 1-6), then runs the script for typography fixes (Step 7). |
| 48 | |
| 49 | ## Workflow |
| 50 | |
| 51 | ### Step 1: Read Source File |
| 52 | |
| 53 | Read the user-specified markdown or plain text file. |
| 54 | |
| 55 | ### Step 1.5: Detect Content Type & Confirm |
| 56 | |
| 57 | **Content Type Detection:** |
| 58 | |
| 59 | | Indicator | Classification | |
| 60 | |-----------|----------------| |
| 61 | | Has `---` YAML frontmatter | Markdown | |
| 62 | | Has `#`, `##`, `###` headings | Markdown | |
| 63 | | Has `**bold**`, `*italic*` | Markdown | |
| 64 | | Has `- ` or `1. ` lists | Markdown | |
| 65 | | Has ``` code blocks | Markdown | |
| 66 | | Has `> ` blockquotes | Markdown | |
| 67 | | None of above | Plain text | |
| 68 | |
| 69 | **Decision Flow:** |
| 70 | |
| 71 | ┌─────────────────┬────────────────────────────────────────────────┐ |
| 72 | │ Content Type │ Action │ |
| 73 | ├─────────────────┼────────────────────────────────────────────────┤ |
| 74 | │ Plain text │ Proceed to Step 2 (format to markdown) │ |
| 75 | ├─────────────────┼────────────────────────────────────────────────┤ |
| 76 | │ Markdown │ Use AskUserQuestion to confirm optimization │ |
| 77 | └─────────────────┴────────────────────────────────────────────────┘ |
| 78 | |
| 79 | **If Markdown detected, ask user:** |
| 80 | |
| 81 | ``` |
| 82 | Detected existing markdown formatting. What would you like to do? |
| 83 | |
| 84 | 1. Optimize formatting (Recommended) |
| 85 | - Add/improve frontmatter, headings, bold, lists |
| 86 | - Run typography script (spacing, emphasis fixes) |
| 87 | - Output: {filename}-formatted.md |
| 88 | |
| 89 | 2. Keep original formatting |
| 90 | - Preserve existing markdown structure |
| 91 | - Run typography script (spacing, emphasis fixes) |
| 92 | - Output: {filename}-formatted.md |
| 93 | |
| 94 | 3. Typography fixes only |
| 95 | - Run typography script on original file in-place |
| 96 | - No copy created, modifies original file directly |
| 97 | ``` |
| 98 | |
| 99 | **Based on user choice:** |
| 100 | - **Optimize**: Continue to Step 2-8 (full workflow) |
| 101 | - **Keep original**: Skip Steps 2-5, copy file → Step 6-8 (run script on copy) |
| 102 | - **Typography only**: Skip Steps 2-6, run Step 7 on original file directly |
| 103 | |
| 104 | ### Step 2: Analyze Content Structure |
| 105 | |
| 106 | Identify: |
| 107 | - Existing title (H1 `#`) |
| 108 | - Paragraph separations |
| 109 | - Keywords suitable for **bold** |
| 110 | - Parallel content convertible to lists |
| 111 | - Code snippets |
| 112 | - Quotations |
| 113 | |
| 114 | ### Step 3: Check/Create Frontmatter |
| 115 | |
| 116 | Check for YAML frontmatter (`---` block). Create if missing. |
| 117 | |
| 118 | **Meta field handling:** |
| 119 | |
| 120 | | Field | Processing | |
| 121 | |-------|------------| |
| 122 | | `title` | See Step 4 | |
| 123 | | `slug` | Infer from file path (e.g., `posts/2026/01/10/vibe-coding/` → `vibe-coding`) or generate from title | |
| 124 | | `summary` | |