to-obsidian

to-obsidian is a command for Claude Code from HeminWon/claude-code-marketplace. It costs 32 tokens per session (1,205 once invoked), scanned A, original, MIT.

A command workflow that converts a WeChat article into an Obsidian-ready folder, where Obsidian is a note-taking application built around Markdown files.

In plain words
What is it for?
It accepts a WeChat article link and repository-relative folder, runs the article conversion, and moves the Markdown file and image assets into the required folder layout.
Why use it?
It validates the article link and destination path, then organizes the document and its images into a predictable structure inside an Obsidian repository.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: names the AskUserQuestion tool.

Part of the wechat-article-export plugin — 1 skill, 2 commands shipped together

Good fit It accepts a WeChat article link and repository-relative folder, runs the article conversion, and moves the Markdown file and image assets into the required folder layout.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/heminwon/claude-code-marketplace/to-obsidian
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.

Clone the repo
git clone --depth 1 https://github.com/HeminWon/claude-code-marketplace

Made for: Claude Code.

Or install wechat-article-export, the plugin that ships this one along with the rest of its 1 skill, 2 commands.

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 to-obsidian

README.md
[![agentmods](https://agentmods.dev/badge/commands/heminwon/claude-code-marketplace/to-obsidian.svg)](https://agentmods.dev/commands/heminwon/claude-code-marketplace/to-obsidian)
Your own site
<a href="https://agentmods.dev/commands/heminwon/claude-code-marketplace/to-obsidian"><img src="https://agentmods.dev/badge/commands/heminwon/claude-code-marketplace/to-obsidian.svg" alt="Measured on agentmods" height="20"></a>
Per session 32 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,205 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00032 $0.01205
Opus 5 $0.00016 $0.00602
Sonnet 5 $0.00006 $0.00241
Haiku 4.5 $0.00003 $0.00120

Measured 8d ago against content hash 4a1e046e92e0, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

to-obsidian 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 8d 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.

plugins/wechat-article-export/commands/to-obsidian.md · 135 lines

How it starts

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

To Obsidian Command

Goal

把微信公众号文章链接转换为 Markdown,并落盘为 Obsidian 友好的目录结构。

Inputs

  • 原始参数:$ARGUMENTS
  • 必填:
    • 文章链接(mp.weixin.qq.com
    • 保存目录(Obsidian 仓库内相对路径,如 xxx/xxx

Workflow

1) 参数与路径检查

  1. $ARGUMENTS 解析文章链接与保存目录。
  2. 缺少任一必填参数时,使用 AskUserQuestion 补齐。
  3. 保存目录必须是仓库内相对路径:
    • / 开头(绝对路径)→ 报错并停止。
    • 包含 ..(如 ../..\\、独立 .. 段)→ 报错并停止。
  4. 目录存在性检查:
    • test -d "<保存目录>"
    • 不存在时先询问是否创建;确认后 mkdir -p "<保存目录>",拒绝则停止。

2) 抓取并转换(调用 skill)

调用 wechat-article-export skill 执行下载与转换,不在本 command 内重复实现。

完成后必须拿到并记录:

  • 文章标题
  • 作者
  • 发布时间
  • Markdown 产物路径

规则:

  • 优先从工具输出提取。
  • 输出不一致时,可基于已生成文件和目录结构回溯定位。
  • 无法确认 Markdown 路径则视为失败并停止。

3) 文件重组(仅用 mv

目标结构:

保存目录/
├── safe_title.md
└── assets/
    └── a1b2c3/
        ├── image-001.png
        ├── image-002.png
        └── ...

执行规则:

  1. 先定位源 .md 与图片目录(可验证优先,禁止猜测)。
  2. 生成 safe_title
    • / \\ : * ? " < > | 替换为 -
    • 去首尾空白与尾随 .,连续空白折叠为单个空格
    • 为空时回退为 untitled-article
  3. 生成 6 位小写字母或数字的 asset_id,并创建目录:
    • mkdir -p "<保存目录>/assets/${asset_id}"
  4. 移动文件:
    • mv "<源md路径>" "<保存目录>/<safe_title>.md"
    • 图片资源 mv"<保存目录>/assets/${asset_id}/"
  5. 禁止 cp
  6. 重组后仅在目录已空时使用 rmdir 清理源目录(可逐级)。
  7. 路径含空格必须加引号。

4) Obsidian Markdown 规范整理

仅做格式整理,不改动事实信息。

允许项:

  • 图片链接统一为标准 Markdown:![alt](path)(不用 wikilink)
  • frontmatter 至少补齐:titlesourceauthorcreated
  • 标题层级修正为单一 H1,子级不跳级
  • 统一空行、列表缩进(每级 2 空格)、引用、代码块
  • 表格补齐表头分隔并对齐
  • 分割线统一为 ---
  • 中英文、中文与数字之间按规范补空格

执行顺序(先计划、后确认、再改动):

  1. 在任何 Markdown 文本改动前,先进入 Plan 模式(EnterPlanMode)。
  2. 读取当前 Markdown 后,输出“拟变更点清单”,至少包含:
    • 将新增或修正的 frontmatter 字段
    • 图片路径/写法将如何调整(含目标路径模式)
    • 标题层级、空行/缩进、表格、分割线、空格规范中将触发的具体项
  3. 使用 ExitPlanMode 展示计划并请求用户批准。
  4. 仅在用户同意后执行规范化编辑;用户拒绝时,仅完成文件重组并保留原文。

Output

返回固定字段(按实际填值):

title: <文章标题>
author: <作者>
created: <发布时间>
markdown_path: <源md路径>
final_path: <保存目录>/<safe_title>.md
assets_path: <保存目录>/assets/<asset_id>/

可附加:已保存到 <保存目录>/<safe_title>.md

Failure Policy

  • 抓取或转换失败:报告原因并停止。
  • 路径非法或不可写:提示修正后重试。
  • 任一步骤失败:不继续后续链路。

Read the full file on GitHub · 135 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. 8d ago First seen · 135 lines · 32 tokens per session scan A 4a1e046e92e0

Subscribe to this mod's changes

to-obsidian is a command published in the GitHub repository HeminWon/claude-code-marketplace (2 stars, last pushed 3mo ago), licensed MIT. It adds 32 tokens to every session and 1,205 once invoked, about $0.0002 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-31.