编程

Siyuan Note Cli

试用

Connect to and operate SiYuan Note through the siyuan-note-cli command-line tool, using notes as context for AI tasks. Use when the user asks to query, creat...

它能做什么

If unavailable, use without requiring a global install:

技能文档

SiYuan Note CLI Skill

Command Invocation

First try the globally installed CLI:

siyuan --version

If unavailable, use npx without requiring a global install:

npx siyuan-note-cli --version

Prefer writing commands as npx siyuan-note-cli to avoid environment differences.

Startup Workflow: Read "AI Assistant Guide" First

Whenever this skill is triggered, the first step is to search for and read the SiYuan document named "AI Assistant Guide":

  1. Search documents:

    npx siyuan-note-cli search docs "AI Assistant Guide"
    
  2. Read the full document by ID:

    npx siyuan-note-cli document get 
    
  3. If the guide contains Markdown rules, available tool lists, naming conventions, tag systems, database templates, or other instructions, follow them strictly.

If "AI Assistant Guide" is not found, tell the user and continue with the normal operation.

Prerequisites

  1. The SiYuan Note client is running, usually at http://127.0.0.1:6806.
  2. API token is configured in one of these ways:
    • Environment variables: SIYUAN_API_URL, SIYUAN_API_TOKEN
    • CLI login: npx siyuan-note-cli auth login --url --token
    • Config file: ~/.config/siyuan-cli/config.yml

Best Practices

  1. Locate before operating: use search, notebook list, and document list before modifications.
  2. Prefer IDs: document and block IDs are more stable than paths.
  3. Use structured output: use --format json for batch operations.
  4. Confirm dangerous operations: use --force only after confirmation; database operations are experimental and should be used carefully.
  5. Verify writes: after write operations, confirm the result with document get or block get.
  6. Create new notes by default: unless the user explicitly asks to modify or append to an existing note, create a separate new document.
  7. Default to the AgentWork notebook: if the user does not specify a location, write content to the root of the AgentWork notebook. If it does not exist, create it first.

Operation Boundary: Create vs Modify

Core principle: create by default, modify only when explicit. This prevents accidental overwrites or pollution of existing notes.

User RequestBehavior
"Record this note", "save this", "keep this"Create a new document under AgentWork
"Update note xxx", "append to xxx", "modify xxx"Modify the specified existing document
No location specifiedCreate under the AgentWork notebook root
Notebook/path specifiedCreate at the specified location

AgentWork notebook handling:

npx siyuan-note-cli notebook list --format json
npx siyuan-note-cli notebook create "AgentWork"
npx siyuan-note-cli document create  "Document Name" \
  --title "Title" \
  --file "$TEMP/siyuan-draft.md"

Do not add a leading / to the path; otherwise the CLI may resolve it as a workspace filesystem path.

Writing Notes: Prefer --file, Avoid --content

Markdown content should be passed through a file, not a command-line string. Command-line parsing can damage line breaks and special characters such as backticks, #, and $.

MethodFormattingUse Case
document create --file Preserves formattingPreferred for complete documents
block append --parent --content "..."Single block onlyAppend one paragraph or heading
block update --content "..."Single block onlyUpdate an existing block
document create --content "..."Easy to damageNot recommended for multi-line Markdown

Recommended pattern:

# Windows Git Bash: $TEMP/siyuan-draft.md
# Linux/macOS: /tmp/siyuan-draft.md
# Cross-platform fallback: ${TMPDIR:-/tmp}/siyuan-draft.md

npx siyuan-note-cli document create  "path/document-name" \
  --title "Document Title" \
  --file "$TEMP/siyuan-draft.md"

Avoid this for multi-line Markdown:

npx siyuan-note-cli document create  "path/document-name" \
  --title "Title" \
  --content "# Title\n\nBody **bold**\n\n```python\nprint('hello')\n```"

Incremental Append: One Block at a Time

block append appends only one block per call. If multiple paragraphs are passed, only the first block may be preserved.

npx siyuan-note-cli block append --parent  --content "## Section Title"
npx siyuan-note-cli block append --parent  --content "Body paragraph."

Do not pass multiple paragraphs in one block append call.

Path Rules

In SiYuan, folders are also documents. Do not add a leading / in any scenario.

ScenarioPath FormatExample
Notebook root"Document Name""My Note"
Existing subdirectory"dir/subdir/document""Projects/App/New Doc"
Child document under existing document"parent/document""Project Plan/Weekly Note"
New nested path"new-dir/document""Test Folder/Scenario Three"

Examples:

npx siyuan-note-cli document create  "Document Name" \
  --title "Title" \
  --file "$TEMP/siyuan-draft.md"

npx siyuan-note-cli document create  "Project/Subdir/New Document" \
  --title "Title" \
  --file "$TEMP/siyuan-draft.md"

Common Commands

Connection:

npx siyuan-note-cli auth status
npx siyuan-note-cli auth login --url http://127.0.0.1:6806 --token 

Notebooks:

npx siyuan-note-cli notebook list
npx siyuan-note-cli notebook create "Project Management"

Documents:

npx siyuan-note-cli document list  --path / --depth 2
npx siyuan-note-cli document get 
npx siyuan-note-cli document create  "path/document-name" \
  --title "Title" \
  --file ./content.md
npx siyuan-note-cli document rename  "New Title"
npx siyuan-note-cli document delete  --force

Blocks:

npx siyuan-note-cli block get 
npx siyuan-note-cli block append  --content "New paragraph"
npx siyuan-note-cli block update  --content "Updated content"

Search and query:

npx siyuan-note-cli search docs "Project Plan"
npx siyuan-note-cli search blocks "Key conclusion"
npx siyuan-note-cli query "SELECT * FROM blocks WHERE type='d' LIMIT 10"

Attributes:

npx siyuan-note-cli attr get 
npx siyuan-note-cli attr set  custom-status=done custom-priority=high

References

  • Command details: references/commands.md
  • Workflow examples: references/workflow-examples.md

相关技能

按用户明确指令,在得到大脑(Get笔记)中保存、搜索并管理笔记与知识库。

作者 iswalle763 次安装66 星标

在本地磁盘以分类纯 Markdown 文件保存需要长期留存的事实,与智能体内置记忆并存。

作者 Iván555 次安装18 星标

把自然语言描述转为结构化 JSON,并由 mcp-diagram-generator MCP 服务生成 Draw.io、Mermaid 或 Excalidraw 图表文件。

作者 nssa.io1.0k 次安装47 星标

以 AI 机器人身份加入视频会议,提供语音、虚拟形象与屏幕共享四种模式。

作者 johnpatternai21 次安装8 星标

诊断生产力系统反复失效的根因,给出最小干预——容量测算、瓶颈定位、可靠的本地记录。

作者 Iván854 次安装69 星标

通过托管的 OAuth GraphQL 接口查询与管理 Linear 的 issue、项目、团队、周期、标签和评论。

作者 byungkyu518 次安装18 星标

agilebuilder 的更多技能

浏览全部技能

Collaborative workflow for converting a complete business project into a reusable base skeleton. Use when the user asks to remove business features, pages, o...

作者 agilebuilder2 次安装

Connect to remote Linux servers through SSH and execute commands non-interactively. Covers password authentication, key authentication, file transfer, and cr...

作者 agilebuilder1 次安装

Manage Tencent Cloud CVM instances with the TCCLI command-line tool. Covers instance creation, querying, deletion, launch template management, price inquiry,...

作者 agilebuilder

Use AgileBuilder MCP for template-based project creation and document-constrained implementation. Trigger when the user asks to create, bootstrap, scaffold,...

作者 agilebuilder1 次安装