360 Secure SkillHub
360 安全技能中心

document-conversion

核心功能是通过三级 fallback策略(MCP工具→原生工具→用户提示)将PDF、DOCX、URL等多格式内容转Markdown,并做内容 sanitize。适用于下游处理需Markdown格式、技能需导入外部非纯文本/MD文档的场景,已为MD/纯文本或小文件无需使用。作为基础设施技能供其他技能依赖调用,输入为文档URI,输出为Markdown内容或配置提示。

athola
athola
热度 62.68
最近更新 2026-08-26 21:15:29
分类:效率依赖:MCP 服务 / 联网浏览搜索 / 读写文件应用场景:文件转换 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add nm-leyline-document-conversion
Metadata
name
document-conversion
description
Converts documents and URLs to markdown via tiered fallback (MCP markitdown, native tools, user notice)
version
1.9.8
triggers
["conversion","markitdown","mcp","documents","pdf","docx","a skill must ingest PDF","DOCX","or URL content"]
metadata
{"openclaw":{"homepage":"https://github.com/athola/claude-night-market/tree/master/plugins/leyline","emoji":"🦞","requires":{"config":["night-market.content-sanitization","night-market.error-patterns"]}}}
source
claude-night-market
source_plugin
leyline

Night Market Skill — ported from claude-night-market/leyline. For the full experience with agents, hooks, and commands, install the Claude Code plugin.

Document Conversion

Convert documents and URLs to markdown using a three-tier fallback strategy. This skill is infrastructure: consumer skills reference it via dependency rather than reimplementing conversion logic.

When To Use

  • Converting PDF, DOCX, PPTX, XLSX, HTML, or images to markdown for downstream processing
  • Any skill that ingests external documents
  • File format is not plain text or markdown

When NOT To Use

  • Content is already markdown or plain text
  • You only need to read a small text file (use Read directly)

Format Detection

Identify the document type from the URI before converting.

Extension Format Tier 1 Tier 2
.pdf PDF Yes Read tool (pages)
.docx, .doc Word Yes None
.pptx, .ppt PowerPoint Yes None
.xlsx, .xls Excel Yes None
.html, .htm HTML Yes WebFetch
.csv CSV Yes Read tool
.json JSON Yes Read tool
.xml XML Yes Read tool
.png, .jpg, .jpeg, .gif, .webp Image Yes Read tool (visual)
.mp3, .wav, .m4a Audio Yes None
.zip Archive Yes None
.epub E-book Yes None

See modules/format-matrix.md for quality comparison across tiers.

Conversion Protocol

To convert a document to markdown:

1. DETECT  -- Identify format from URI extension or context
2. TRY     -- Tier 1: MCP markitdown (best quality)
3. DEGRADE -- Tier 2: native Claude Code tools (if Tier 1 fails)
4. INFORM  -- Tier 3: tell user what's needed (if no coverage)
5. SANITIZE -- Apply content-sanitization (external content)

Tier 1: MCP markitdown

Call the convert_to_markdown MCP tool with the document URI. See modules/uri-construction.md for URI formatting rules.

If the tool is available and succeeds, you have the best possible conversion. Proceed to the SANITIZE step.

If the tool is not available (not found, connection error) or fails, proceed to Tier 2.

Tier 2: Native Claude Code Tools

Use built-in tools as format-specific fallbacks. See modules/fallback-tiers.md for per-format instructions.

Supported in Tier 2: PDF, HTML, images, CSV, JSON, XML. Not supported in Tier 2: DOCX, PPTX, XLSX, audio, archives, e-books. Proceed to Tier 3 for these.

Tier 3: User Notification

When neither Tier 1 nor Tier 2 can handle the format:

I cannot convert this {format} file without the markitdown MCP server. To enable conversion, add this to .mcp.json:

{
  "mcpServers": {
    "markitdown": {
      "type": "stdio",
      "command": "uvx",
      "args": ["markitdown-mcp"]
    }
  }
}

Alternatively, convert the file to PDF or HTML first, which I can read with built-in tools.

SANITIZE Step

All converted content is external. Apply the leyline:content-sanitization checklist:

  • Size check (truncate sections over 2000 words)
  • Strip system/instruction tags
  • Wrap in external content boundary markers

Integration

Consumer skills depend on this skill and reference the protocol by name:

dependencies:
- leyline:document-conversion

Then in their workflow: "Convert the document using the leyline:document-conversion protocol."

Detailed References

  • Format support details: modules/format-matrix.md
  • Per-format fallback instructions: modules/fallback-tiers.md
  • URI construction rules: modules/uri-construction.md