siyuan-cli CLAUDE.md

Repository-specific instructions for a Go command-line tool that manages SiYuan Note, a note-taking application, through its API and an interactive text interface.

In plain words
What is it for?
Use it when changing commands, note and document operations, the interactive interface, API integration, configuration, or the build process.
Why use it?
It gives a coding agent the project layout, build commands, configuration location, and important implementation details so it can work in the repository correctly.

Instructions file

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.

agentmods
npx agentmods add instructions/cicbyte/siyuan-cli/claude-md
Clone the repo
git clone --depth 1 https://github.com/cicbyte/siyuan-cli
Per session 714 This file is loaded in full into every session.
When invoked 714 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
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 $0.00714 $0.00714
Opus 5 $0.00357 $0.00357
Sonnet 5 $0.00143 $0.00143
Haiku 4.5 $0.00071 $0.00071

Measured 2d ago against content hash 2b60bc9aab59, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

siyuan-cli CLAUDE.md 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 2d 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.

CLAUDE.md · 54 lines

What it actually says

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

项目概述

思源笔记(SiYuan Note)命令行管理工具,Go 语言编写。通过思源内核 API 实现笔记本管理、文档操作、块编辑等功能,并提供交互式 TUI 界面。

构建与运行

# 开发构建
go build -o siyuan-cli .

# 直接运行
go run cmd/*.go

# 生产构建(含 Web 前端构建 + UPX 压缩)
python build.py

build.py 流程:npm build(web/dist) → 清理 resources/static → 复制前端产物 → go build → UPX 压缩。构建信息(版本号、commit hash、分支)通过 -ldflags 注入 main 包变量。

当前无单元测试框架。

架构

分层结构,职责清晰:

  • cmd/ — Cobra 命令定义,每个子命令一个文件(root.go、notebook.go、document.go、fav.go)
  • internal/logic/ — 业务逻辑层,按领域分包(notebook/、document/、fav/)
  • internal/siyuan/ — 思源内核 API 的 Go SDK 封装。client.go 定义 Client 结构体和 post/postMultipart 基础请求方法;factory.go 从全局配置创建客户端实例
  • internal/ui/ — Bubble Tea TUI 组件(笔记本列表、文档树、路径选择器等)
  • internal/models/ — 数据结构定义,核心是 AppConfig(YAML 配置模型)
  • internal/utils/config.go — 配置管理单例,处理目录创建、配置加载/保存、默认值
  • internal/common/ — 全局变量(AppConfigModel
  • internal/log/ — Zap 日志初始化

关键设计

配置系统:YAML 配置文件位于 ~/.cicbyte/siyuan-cli/config/config.yaml,首次运行自动创建。common.AppConfigModel 是全局配置入口,在 cmd/root.goinit() 中加载。

SiYuan SDKClient 线程安全、可复用。所有 API 均为 POST 请求,返回 {code, msg, data} 结构,code != 0 时返回 *SiYuanError。通过 factory.goGetDefaultSiYuanClient() 获取客户端。

启动流程cmd/root.go init):初始化应用目录 → 加载配置 → 初始化日志 → 连接 SQLite 数据库。

依赖

  • Cobra — CLI 框架
  • Bubble Tea + Lipgloss + Bubbles — TUI
  • Zap + Lumberjack — 日志(按天轮转)
  • GORM + SQLite — 数据持久化
  • go.yaml.in/yaml/v3 — 配置解析
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. 2d ago First seen · 54 lines · 714 tokens per session scan A 2b60bc9aab59

Subscribe to this mod's changes

siyuan-cli CLAUDE.md is an instructions file published in the GitHub repository cicbyte/siyuan-cli (5 stars, last pushed 4mo ago), licensed MIT. It adds 714 tokens to every session, about $0.0036 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.