skills/siyuan-note/SKILL.md
思源笔记 API 集成与知识库管理。Use when "思源笔记", "SiYuan Note", "知识库管理", "笔记操作", "siyuan API". 支持笔记 CRUD、SQL 查询、批量操作、备份导出。 需要 SIYUAN_HOST 和 SIYUAN_TOKEN 环境变量。
npx skillsauth add sunchendd/good_skills siyuan-noteInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
export SIYUAN_HOST="http://127.0.0.1:6806"
export SIYUAN_TOKEN="your-api-token"
export SIYUAN_HOST="http://your-siyuan.example.com:6806"
export SIYUAN_TOKEN="your-api-token"
⚠️ 安全提示:公网访问时 Token 会明文传输,建议配置 HTTPS(需反向代理配置 SSL 证书)。
API token is found in SiYuan Settings → About.
Test connection:
python3 scripts/siyuan.py test
List all notebooks:
curl -X POST ${SIYUAN_HOST}/api/notebook/lsNotebooks \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" -d '{}'
Create notebook:
curl -X POST ${SIYUAN_HOST}/api/notebook/createNotebook \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"name": "My Notebook"}'
Delete notebook by ID:
curl -X POST ${SIYUAN_HOST}/api/notebook/removeNotebook \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"notebook": "notebook-id"}'
List documents in notebook:
curl -X POST ${SIYUAN_HOST}/api/filetree/listDocsByPath \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"notebook": "notebook-id", "path": "/"}'
Create document with Markdown:
curl -X POST ${SIYUAN_HOST}/api/filetree/createDocWithMd \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"notebook": "notebook-id", "path": "/my-note", "markdown": "# Title\nContent"}'
Delete document by ID:
curl -X POST ${SIYUAN_HOST}/api/filetree/removeDocByID \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"id": "doc-id"}'
Export document as Markdown:
curl -X POST ${SIYUAN_HOST}/api/export/exportMdContent \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"id": "doc-id"}'
Search content with SQL query:
curl -X POST ${SIYUAN_HOST}/api/query/sql \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"stmt": "SELECT * FROM blocks WHERE content LIKE '\''%keyword%'\'' LIMIT 10"}'
Get block content:
curl -X POST ${SIYUAN_HOST}/api/block/getBlockKramdown \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"id": "block-id"}'
Append block to document:
curl -X POST ${SIYUAN_HOST}/api/block/appendBlock \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"dataType": "markdown", "data": "New content", "parentID": "doc-id"}'
The bundled Python script provides common operations:
# Test connection
python3 scripts/siyuan.py test
# List notebooks
python3 scripts/siyuan.py ls-notebooks
# Create notebook
python3 scripts/siyuan.py create-notebook "My Notebook"
# Delete notebook
python3 scripts/siyuan.py delete-notebook "notebook-id"
# List documents in notebook
python3 scripts/siyuan.py ls-docs "notebook-id"
# Create document
python3 scripts/siyuan.py create-doc "notebook-id" "/my-path" "# Title\nContent"
# Delete document
python3 scripts/siyuan.py delete-doc "doc-id"
# Search
python3 scripts/siyuan.py search "keyword"
# Export markdown
python3 scripts/siyuan.py export-md "doc-id" /path/to/save.md
# Export all documents to directory
python3 scripts/siyuan.py export-all-notebooks "/backup/path"
# Get statistics
python3 scripts/siyuan.py stats
# Find duplicate documents
python3 scripts/siyuan.py find-duplicates
# Find documents by name pattern
python3 scripts/siyuan.py find "pattern"
# Export documents from a specific notebook
python3 scripts/siyuan.py export-notebook "notebook-id" "/output/path"
# 1. List notebooks to get ID
python3 scripts/siyuan.py ls-notebooks
# 2. Create document in notebook
python3 scripts/siyuan.py create-doc "notebook-id" "/my-new-note" "# My New Note\n\nContent here"
# 1. Search for content
python3 scripts/siyuan.py search "keyword"
# 2. Get document ID from results and export
python3 scripts/siyuan.py export-md "doc-id" "/output/note.md"
# Export all notebooks to backup directory
python3 scripts/siyuan.py export-all-notebooks "~/Desktop/siyuan_backup_$(date +%Y%m%d)"
# 1. List documents in notebook
python3 scripts/siyuan.py ls-docs "notebook-id"
# 2. Find documents by pattern
python3 scripts/siyuan.py find "test" --notebook "notebook-id"
# 3. Delete unwanted documents in batch
echo "id1\nid2\nid3" | xargs -I {} python3 scripts/siyuan.py delete-doc {}
# Create new notebook
python3 scripts/siyuan.py create-notebook "Project Docs"
# Get notebook ID (or use directly)
NOTEBOOK_ID="new-notebook-id"
# Create folder structure
python3 scripts/siyuan.py create-doc "$NOTEBOOK_ID" "/Documentation" "# Documentation"
python3 scripts/siyuan.py create-doc "$NOTEBOOK_ID" "/Documentation/Getting Started" "# Getting Started"
python3 scripts/siyuan.py create-doc "$NOTEBOOK_ID" "/Documentation/API Reference" "# API Reference"
python3 scripts/siyuan.py create-doc "$NOTEBOOK_ID" "/Documentation/Examples" "# Examples"
# Get notebook statistics
python3 scripts/siyuan.py stats
# Find potential duplicates
python3 scripts/siyuan.py find-duplicates
# Export all notes for analysis
python3 scripts/siyuan.py export-all-notebooks "backup_dir"
# Then import organized notes as needed
All endpoints return:
{
"code": 0,
"msg": "",
"data": {...}
}
Check code === 0 for success. msg contains error details on failure.
Common error codes:
-1: Parameter/execution error401: Unauthorized (invalid token)403: Permission denied404: Resource not found503: Service unavailable (SiYuan not running)Check msg field for details.
# Create document in subfolder
python3 scripts/siyuan.py create-doc "notebook-id" "/category/subcategory/doc-name" "# Title"
# List documents in subfolder
python3 scripts/siyuan.py ls-docs "notebook-id" "/category"
Export all documents preserving folder structure:
python3 scripts/siyuan.py export-all-notebooks "/backup" --hierarchy
# Find documents by title
curl -X POST ${SIYUAN_HOST}/api/query/sql \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"stmt": "SELECT * FROM blocks WHERE type = \"d\" AND content LIKE \"My Title%\""}'
# Get document tree
curl -X POST ${SIYUAN_HOST}/api/filetree/getDocTree \
-H "Authorization: Token ${SIYUAN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"notebook": "notebook-id"}'
See references/api_reference.md for complete API documentation including:
| Variable | Description | Default |
|----------|-------------|---------|
| SIYUAN_HOST | SiYuan Note server URL | http://127.0.0.1:6806 (本地) 或 http://your-siyuan.example.com:6806 (公网) |
| SIYUAN_TOKEN | API authentication token | (required) |
如果你在外网需要访问运行在家中或服务器上的 SiYuan Note:
# 公网域名访问
export SIYUAN_HOST="http://your-siyuan.example.com:6806"
export SIYUAN_TOKEN="你的Token"
server {
listen 443 ssl;
server_name your-siyuan.example.com;
ssl_certificate /path/to/ssl/cert.pem;
ssl_certificate_key /path/to/ssl/key.pem;
location / {
proxy_pass http://127.0.0.1:6806;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
配置 HTTPS 后使用:
export SIYUAN_HOST="https://your-siyuan.example.com"
ls-docs to list available documentstest commanddevelopment
通用开发验证工作流,用于 AI/ML 推理服务的开发、测试和验证。支持多种硬件后端(Ascend NPU、GPU)和推理引擎(vLLM、MindIE)。包含完整的需求对齐、代码检查、服务部署、性能测试和结果分析流程。当用户提到"开发"、"测试"、"性能对比"、"服务部署"、"推理验证"等需求时使用此工作流。
tools
小红书检索与发布工具。Use when "小红书检索", "发布小红书", "xhs MCP", "搜索小红书内容". 基于本地 MCP Server 或 xhs-mcp CLI,支持搜索、查看、发布三种操作。
data-ai
自动周报生成。Use when "周报", "本周工作总结", "weekly report", "自动生成周报". 汇总本周日历、GitHub 活动,AI 生成工作总结+时间分析+下周规划,通过邮件和 Bark 推送。
testing
Use when testing vLLM performance, running benchmarks, comparing inference configurations, cleaning up GPU environments, or generating performance reports. Activates for benchmarking throughput/latency, configuring vLLM serve parameters, using evalscope or vllm bench, and producing comparison tables.