From iwatchme-skills
Use when preparing a Markdown article for an Obsidian-hosted blog: generate fixed YAML frontmatter, sanity-check code fences and mermaid blocks, and write the finished note into an Obsidian Blog folder via the Obsidian CLI.
How this skill is triggered — by the user, by Claude, or both
Slash command
/iwatchme-skills:iwatchme-obsidian-blog-publisherThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
把原始 Markdown 文章整理成可发布的博客文章,并通过 Obsidian CLI 写入当前 vault 的 `Blog/` 目录。
把原始 Markdown 文章整理成可发布的博客文章,并通过 Obsidian CLI 写入当前 vault 的 Blog/ 目录。
.md 文件路径,并希望把它变成博客文章开始前先拿到文章的完整内容:
不要只根据文件名生成标题、描述或 slug。
目标 frontmatter 结构固定为:
---
title: ""
description: ""
pubDate: ""
tags: []
draft: false
publish: true
slug: ""
---
字段约束:
title:通常使用文章正文语言;内容偏中文时默认生成中文标题;20 个字符以内description:中文摘要;100-200 字最佳,脚本接受 50-300 字pubDate:必须用系统当天日期,格式 YYYY-MM-DDtags:1-3 个英文 tag,全部小写,1-2 个词draft:固定为 falsepublish:固定为 trueslug:英文 kebab-case,建议 3-6 个词如果源文件已经有 frontmatter,直接整体替换,不做合并。
在写入 Obsidian 前,先检查正文:
```ts、```bash```textgraph TD、flowchart LR、sequenceDiagramscripts/process_blog.py 负责做确定性的 frontmatter 重写和 lint 提示,但不会自动修正文中歧义内容。
uv优先使用 skill 自带的 uv 环境。脚本目录约定和 iwatchme-markdown-to-styled-docx 一致:
cd <skill-install-dir>
scripts/bootstrap_uv.sh
其中 <skill-install-dir> 指包含 SKILL.md 和 scripts/ 的目录。
标准调用:
scripts/process_blog.sh \
--input <source.md> \
--output /tmp/processed.md \
--title "中文标题" \
--description "中文描述……" \
--pub-date "$(date +%Y-%m-%d)" \
--tags kotlin,coroutine \
--slug kotlin-coroutine-deep-dive
如果只想直接调用 Python,也应通过 uv:
UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple \
uv run --python .venv/bin/python python scripts/process_blog.py \
--input <source.md> \
--output /tmp/processed.md \
--title "中文标题" \
--description "中文描述……" \
--pub-date "$(date +%Y-%m-%d)" \
--tags kotlin,coroutine \
--slug kotlin-coroutine-deep-dive
脚本行为:
--output如果需要把 lint warning 视为失败,可附加 --strict。
前提:
obsidian CLI 已安装且可调用强约束:
obsidian create、obsidian append 这类写入命令先验证 CLI:
obsidian help
obsidian version
obsidian vault info=path
注意:
obsidian help 查看帮助,不要用 obsidian --helpobsidian 通常只是桌面应用的 wrapper,不是独立后台服务obsidian help 正常,但 REST/API 端口连不上,不影响 CLI 写入;两者是不同通道ECONNREFUSED 127.0.0.1:27124,不要把它当成 CLI 不可用;改走 obsidian CLI 即可不要直接 cp 到 Obsidian/iCloud 路径。统一使用 Obsidian CLI 写入当前 vault 中的相对路径:
content=$(python3 -c "
import pathlib
text = pathlib.Path('/tmp/processed.md').read_text(encoding='utf-8')
print(text.replace('\\\\', '\\\\\\\\').replace('\"', '\\\\\"').replace('\n', '\\\\n'))
")
obsidian create path="Blog/文章标题.md" content="$content" silent overwrite
更稳的做法:
content=...python3 -c 调 subprocess.run(["obsidian", ...])content 参数传单个字符串,内容先做 \n、\、" 转义,再交给 CLISIGABRT 或者写入失败,这通常是参数传递问题,不是文章内容问题推荐写法:
python3 -c '
from pathlib import Path
import subprocess
text = Path("/tmp/processed.md").read_text(encoding="utf-8")
content = text.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n")
subprocess.run(
[
"obsidian",
"create",
"path=Blog/文章标题.md",
f"content={content}",
"silent",
"overwrite",
],
check=True,
)
'
约定:
Blog/<title>.mdtitleoverwrite 允许重复运行slug 不是英文 kebab-casecontent= 参数,导致转义错乱或 SIGABRTnpx claudepluginhub iwatchme/iwatchme-skills --plugin iwatchme-skillsCreates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.