convert-to-md

convert-to-md is a command for Claude Code from gatelynch/llm-knowledge-base. It costs 25 tokens per session (3,099 once invoked), scanned A, original, MIT.

A conversion command that turns EPUB ebooks, PDF files, DOCX documents, or Facebook export data into clean Obsidian Markdown notes.

In plain words
What is it for?
Use it to convert one file or a folder of books, process Facebook JSON exports, and check whether the required conversion tools are installed.
Why use it?
It saves the work of converting documents manually and places the text and related media in an organized folder structure.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/gatelynch/llm-knowledge-base/convert-to-md
Clone the repo
git clone --depth 1 https://github.com/gatelynch/llm-knowledge-base

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for convert-to-md

README.md
[![agentmods](https://agentmods.dev/badge/commands/gatelynch/llm-knowledge-base/convert-to-md.svg)](https://agentmods.dev/commands/gatelynch/llm-knowledge-base/convert-to-md)
Your own site
<a href="https://agentmods.dev/commands/gatelynch/llm-knowledge-base/convert-to-md"><img src="https://agentmods.dev/badge/commands/gatelynch/llm-knowledge-base/convert-to-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 25 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,099 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00025 $0.03099
Opus 5 $0.00013 $0.01550
Sonnet 5 $0.00005 $0.00620
Haiku 4.5 $0.00003 $0.00310

Measured 5d ago against content hash 7fa90accf482, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

convert-to-md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/convert-to-md.md · 270 lines

How it starts

The opening of the file, as written. The whole thing — 270 lines — stays where its author put it; the contents beside it link to each section on GitHub.

轉檔:EPUB / PDF / DOCX / Facebook JSON → Obsidian Markdown

將電子書、報告、文件或社群平台匯出轉成乾淨的 Markdown。

來源格式 輸出位置 媒體位置
EPUB / PDF / DOCX raw/books/ raw/books/assets/
Facebook JSON 匯出 raw/notes/social/facebook/ raw/notes/social/facebook/assets/

輸入

$ARGUMENTS 為檔案或資料夾路徑。

  • 單一檔案:轉換該檔案(支援 .epub.pdf.docx
  • 資料夾(書籍):掃描資料夾內所有 .epub.pdf.docx,逐一轉換
  • 資料夾(Facebook 匯出):偵測到 your_facebook_activity/ 子目錄時,自動走 Facebook 轉換路徑
  • 若無提供,問使用者:「請提供要轉換的檔案或資料夾路徑」

流程

Step 0:確認環境

檢查必要工具,缺少則安裝或提示使用者:

pandoc --version 2>&1 | head -1          # EPUB、DOCX 都需要
python3 -c "import fitz; print('OK')"    # PDF 需要 pymupdf
  • pandoc 未安裝 → 提示:brew install pandoc
  • pymupdf 未安裝 → 執行:pip3 install pymupdf

Step 1:判斷輸入類型

# 判斷是檔案還是資料夾
if [ -d "$ARGUMENTS" ]; then
  # 先檢查是否為 Facebook 匯出(含 your_facebook_activity/ 子目錄)
  if [ -d "$ARGUMENTS/your_facebook_activity" ]; then
    echo "FACEBOOK_EXPORT"
  else
    # 一般資料夾:列出所有支援的檔案
    find "$ARGUMENTS" -maxdepth 1 -type f \( -iname "*.epub" -o -iname "*.pdf" -o -iname "*.docx" \)
  fi
else
  # 單一檔案
  file "$ARGUMENTS"
fi
  • 若偵測到 Facebook 匯出 → 跳至「Facebook JSON 路徑」
  • 若為一般資料夾,列出找到的檔案清單,告訴使用者即將轉換哪些檔案,確認後逐一執行 Step 2-7
  • 若為單一檔案 → 依副檔名走對應路徑

Step 2:提取書名與 metadata

格式 方法
EPUB pandoc metadata 或解壓讀 nav.xhtml
PDF fitz.open(path).metadata['title']
DOCX pandoc --metadata 或讀 docProps/core.xml

若提取失敗,用檔名(去副檔名)當書名。

產出檔名:raw/books/{書名}.md

Step 3:轉換


EPUB 路徑
  1. pandoc 轉換--wrap=none 避免斷行):
pandoc "$FILE" -t markdown --wrap=none --extract-media=raw/books/assets -o raw/books/{書名}_raw.md
  1. 後處理

    • 移除 pandoc 屬性:{.class}[]{#id}::: div
    • 移除翻譯外掛殘留(.immersive-translate-*.notranslate
    • 圖片路徑改為相對路徑
    • 中英文間距統一(pangu spacing)
    • ------——
    • 移除行首殘留 ] [
    • 移除索引頁和廣告頁
  2. 圖片:加書名前綴避免衝突,更新 markdown 路徑


PDF 路徑

Read the full file on GitHub · 270 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 270 lines · 25 tokens per session scan A 7fa90accf482

Subscribe to this mod's changes

convert-to-md is a command published in the GitHub repository gatelynch/llm-knowledge-base (329 stars, last pushed 5mo ago), licensed MIT. It adds 25 tokens to every session and 3,099 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.