obsidian-gh-knowledge
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseObsidian GitHub Knowledge
Obsidian GitHub 知识库
Use this skill to operate on a remote Obsidian vault stored in a GitHub repository without relying on local filesystem edits.
This skill should NOT guess which repo is your vault.
If the user does not provide , require the user to either:
--repo- Provide explicitly, or
--repo <owner/repo> - Set up the local config file described below, then use its .
default_repo
使用本技能操作存储在GitHub仓库中的远程Obsidian库,无需依赖本地文件系统编辑。
本技能不会猜测哪个仓库是你的库。
如果用户未提供,需要求用户执行以下操作之一:
--repo- 明确提供,或
--repo <owner/repo> - 配置以下本地配置文件,然后使用其中的。
default_repo
Practical Tips (Paths & Emoji)
实用技巧(路径与表情符号)
- Always wrap values and file paths in quotes (emoji and spaces are common).
--path - Prefer copy/pasting the exact returned by
path/listinstead of hand-typing emoji segments.search - Treat URL-encoded emoji in API output (e.g., ) as normal.
%EF%B8%8F%E2%83%A3 - If you get , assume the path is wrong or the file does not exist; verify with
HTTP 404orlist.search
- 始终用引号包裹值和文件路径(表情符号和空格很常见)。
--path - 优先复制粘贴/
list返回的精确search,而非手动输入含表情符号的部分。path - 将API输出中的URL编码表情符号(如)视为正常内容。
%EF%B8%8F%E2%83%A3 - 如果收到错误,假设路径错误或文件不存在;使用
HTTP 404或list进行验证。search
SAFETY RULES (CRITICAL)
安全规则(至关重要)
These rules prevent accidental data loss. NEVER bypass them.
这些规则可防止意外数据丢失。绝不要违反它们。
1. NEVER Force Push to Main
1. 绝不要强制推送到Main分支
bash
undefinedbash
undefinedFORBIDDEN - This can delete all files
禁止操作 - 这会删除所有文件
gh api -X PATCH repos/.../git/refs/heads/main -F force=true
gh api -X PATCH repos/.../git/refs/heads/main -F force=true
FORBIDDEN - Direct reset
禁止操作 - 直接重置
git push --force origin main
undefinedgit push --force origin main
undefined2. ALWAYS Use Feature Branches for Writes
2. 写入操作必须使用功能分支
All write operations MUST use a dedicated feature branch:
- ,
write,movecommands requirecopy--branch <name> - Branch name should be descriptive (e.g., )
update-cmux-docs-20260222 - NEVER commit directly to
main
所有写入操作必须使用专用功能分支:
- 、
write、move命令需要copy参数--branch <name> - 分支名称应具备描述性(例如)
update-cmux-docs-20260222 - 绝不要直接提交到分支
main
3. ALWAYS Create PR for Merge
3. 合并必须创建PR
After writing to a branch, create a PR and let user review:
bash
gh pr create --repo <owner/repo> --head <branch> --base main \
--title "Update notes" --body "Changes: ..."NEVER auto-merge without user confirmation.
向分支写入内容后,创建PR并等待用户审核:
bash
gh pr create --repo <owner/repo> --head <branch> --base main \
--title "Update notes" --body "Changes: ..."绝不要在未获得用户确认的情况下自动合并。
4. Prefer Local Vault When Available
4. 优先使用本地库
If a local vault exists at :
~/Documents/obsidian_vault/- Use local git operations instead of GitHub API
- Commit changes locally first
- Push with (not force push)
git push - This preserves git history and allows easy recovery via
git reflog
如果路径下存在本地库:
~/Documents/obsidian_vault/- 使用本地git操作而非GitHub API
- 先在本地提交更改
- 使用推送(不要强制推送)
git push - 这样可以保留git历史记录,并且可通过轻松恢复数据
git reflog
5. Read Before Write
5. 先读后写
Before updating any file:
- the existing file content
read - Show diff to user if content differs significantly
- Only proceed with user confirmation for large changes
更新任何文件前:
- 使用命令读取现有文件内容
read - 如果内容差异较大,向用户展示差异
- 仅在用户确认后再进行大的更改
6. Single-File Operations Only
6. 仅支持单文件操作
- Write/move/copy ONE file per commit
- NEVER batch multiple unrelated files in one branch
- This makes rollback easier if something goes wrong
- 每次提交仅对单个文件执行写入/移动/复制操作
- 绝不要在一个分支中批量处理多个不相关文件
- 这样在出现问题时更容易回滚
Obsidian Note Authoring Guidelines
Obsidian 笔记编写指南
When creating or editing notes in an Obsidian vault, follow these conventions:
- If the workspace/repo has an , read it and follow it (it overrides these defaults).
AGENTS.md
在Obsidian库中创建或编辑笔记时,请遵循以下约定:
- 如果工作区/仓库中存在文件,请先阅读并遵循其中的规则(它会覆盖以下默认规则)。
AGENTS.md
Markdown
Markdown 规范
- Prefer a short near the top for human scanning.
## TL;DR - Use Obsidian wikilinks () for internal references instead of raw URLs.
[[note-title]] - Keep headings stable; rename/move only when explicitly asked (links depend on titles/paths).
- Use YAML frontmatter for metadata (tags, aliases, dates).
- 优先在顶部附近添加简短的部分,方便人工快速浏览。
## TL;DR - 使用Obsidian维基链接()进行内部引用,而非原始URL。
[[note-title]] - 保持标题稳定;仅在明确要求时才重命名/移动(链接依赖于标题/路径)。
- 使用YAML前置元数据存储标签、别名、日期等信息。
Mermaid (Obsidian Compatibility)
Mermaid(Obsidian 兼容性)
Obsidian's Mermaid renderer has quirks. Follow these rules to avoid rendering failures:
- Prefer /
graph TBover newer Mermaid syntaxes.sequenceDiagram - Avoid style; use quoted titles:
subgraph ID[Label].subgraph "Title" - Avoid in node labels; use
\nor keep labels single-line.<br/> - Avoid parentheses and slashes in node labels; Obsidian chokes on or
(...)insidea/b.[...] - Keep node IDs ASCII and simple (,
OC_GW); avoid punctuation in IDs.CMUX_DB - If a diagram fails to render, simplify first (remove subgraphs/line breaks), then add complexity back.
Obsidian的Mermaid渲染器有一些特性。请遵循以下规则避免渲染失败:
- 优先使用/
graph TB,而非较新的Mermaid语法。sequenceDiagram - 避免使用格式;使用带引号的标题:
subgraph ID[Label]。subgraph "Title" - 避免在节点标签中使用;使用
\n或保持标签为单行。<br/> - 避免在节点标签中使用括号和斜杠;Obsidian在内遇到
[...]或(...)时会出现问题。a/b - 节点ID使用简单的ASCII字符(例如、
OC_GW);避免在ID中使用标点符号。CMUX_DB - 如果图表渲染失败,先简化(移除子图/换行符),然后再逐步添加复杂内容。
Vault Organization Conventions
库组织约定
Typical Obsidian vault folder structure (emoji prefixes for sorting):
| Directory | Purpose |
|---|---|
| Uncategorized new notes |
| Maps of content (MOCs), overviews |
| Work-in-progress ideas |
| Plugin docs and configs |
| Non-image assets (PDFs, sheets) |
| Project documentation by category |
| Images and media |
| Reusable note templates |
典型的Obsidian库文件夹结构(使用表情符号前缀排序):
| 目录 | 用途 |
|---|---|
| 未分类的新笔记 |
| 内容地图(MOC)、概览文档 |
| 正在开发中的想法 |
| 插件文档和配置文件 |
| 非图片资源(PDF、表格等) |
| 按分类整理的项目文档 |
| 图片和媒体文件 |
| 可复用的笔记模板 |
Project Folder Convention (5️⃣-Projects/
)
5️⃣-Projects/项目文件夹约定(5️⃣-Projects/
)
5️⃣-Projects/Each project folder MUST have a file as its Map of Content (MOC):
_Overview.md5️⃣-Projects/
├── GitHub/
│ ├── cmux/
│ │ ├── _Overview.md # MOC index (required)
│ │ ├── cmux-tech-stack.md
│ │ └── ...
│ └── openclaw/
│ ├── _Overview.md # MOC index (required)
│ ├── openclaw-local-status.md
│ └── ...
├── Infrastructure/
│ └── k8s/
│ └── _Overview.md
└── Research/
└── _Overview.md_Overview.md- Start with heading
# Project Name (MOC) - Use callout with project metadata (repo, stack, updated date)
> [!info] Map of Content - Include Quick Navigation table linking key documents
- Include Documentation Index with Status column (Current, Reference, Active, etc.)
- Add architecture diagram (Mermaid) if applicable
- Include Cross-References section by topic
- End with Document Status Legend and Last Updated date
When creating a new project folder:
- Create the folder under appropriate category (GitHub, Infrastructure, Research)
- Create as the first file
_Overview.md - Follow the MOC template structure
- Link all related documents from the overview
When creating new notes:
- Place uncategorized notes in for later review.
Inbox - Use links and tags for navigation, not deep folder nesting.
- Check existing structure with before assuming folder names.
list
每个项目文件夹必须包含一个文件作为其内容地图(MOC):
_Overview.md5️⃣-Projects/
├── GitHub/
│ ├── cmux/
│ │ ├── _Overview.md # 必填的MOC索引
│ │ ├── cmux-tech-stack.md
│ │ └── ...
│ └── openclaw/
│ ├── _Overview.md # 必填的MOC索引
│ ├── openclaw-local-status.md
│ └── ...
├── Infrastructure/
│ └── k8s/
│ └── _Overview.md
└── Research/
└── _Overview.md_Overview.md- 以标题开头
# Project Name (MOC) - 使用提示框展示项目元数据(仓库、技术栈、更新日期)
> [!info] Map of Content - 包含快速导航表格,链接到关键文档
- 包含带状态列(当前、参考、活跃等)的文档索引
- 如有需要,添加架构图(Mermaid格式)
- 按主题添加交叉引用部分
- 末尾添加文档状态图例和最后更新日期
创建新项目文件夹时:
- 在适当的分类(GitHub、Infrastructure、Research)下创建文件夹
- 首先创建文件
_Overview.md - 遵循MOC模板结构
- 从概览文档链接所有相关文档
创建新笔记时:
- 将未分类的笔记放在中,待后续审核。
Inbox - 使用链接和标签进行导航,而非深层文件夹嵌套。
- 在假设文件夹名称前,使用命令检查现有结构。
list
Templates
模板使用
- For GitHub project notes, read and use as the starting structure.
100-Templates/github-project-template.md - Read the template:
bash
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo <owner/repo> read \ "100-Templates/github-project-template.md" - To scaffold a new project folder with :
_Overview.mdbash# Create the _Overview.md as the MOC index python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo <owner/repo> copy \ "100-Templates/github-project-template.md" \ "5️⃣-Projects/GitHub/<project>/_Overview.md" \ --branch "add-project-docs" \ --message "Add project overview MOC" - For additional notes in the project folder:
bash
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo <owner/repo> write \ "5️⃣-Projects/GitHub/<project>/<note-name>.md" \ --stdin \ --branch "add-project-docs" \ --message "Add project note"
- 对于GitHub项目笔记,请阅读并使用作为起始结构。
100-Templates/github-project-template.md - 读取模板:
bash
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo <owner/repo> read \ "100-Templates/github-project-template.md" - 使用模板搭建带的新项目文件夹:
_Overview.mdbash# 创建作为MOC索引的_Overview.md python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo <owner/repo> copy \ "100-Templates/github-project-template.md" \ "5️⃣-Projects/GitHub/<project>/_Overview.md" \ --branch "add-project-docs" \ --message "Add project overview MOC" - 为项目文件夹添加额外笔记:
bash
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo <owner/repo> write \ "5️⃣-Projects/GitHub/<project>/<note-name>.md" \ --stdin \ --branch "add-project-docs" \ --message "Add project note"
Repo Resolution Policy
仓库解析规则
Resolve the repository in this order:
- If the user provides , use it.
--repo <owner/repo> - If the user provides (no
--repo <key>), resolve it via/at~/.config/obsidian-gh-knowledge/config.json.repos.<key> - If is omitted, use
--repofrom the same config file.default_repo - If none of the above is available, ask the user for the repo or ask them to set local config.
Never guess repo names.
按以下顺序解析仓库:
- 如果用户提供,则使用该仓库。
--repo <owner/repo> - 如果用户提供(不含
--repo <key>),则通过/文件中的~/.config/obsidian-gh-knowledge/config.json解析。repos.<key> - 如果未提供,则使用同一配置文件中的
--repo。default_repo - 如果以上都不可用,请用户提供仓库信息或指导用户配置本地文件。
绝不要猜测仓库名称。
Requirements
环境要求
- GitHub CLI installed:
gh - Authenticated:
gh auth status
- 已安装GitHub CLI:
gh - 已完成身份验证:
gh auth status
Commands
命令说明
All operations are performed via the bundled script:
bash
python3 scripts/github_knowledge_skill.py --repo <owner/repo> <command> [args]If the skill is installed globally, the script is typically located at:
bash
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo <owner/repo> <command> [args]- : List files in a directory.
list --path <path> - : Read file content.
read <file_path> - : Search code/content.
search <query> - : Move/rename a file by creating the destination file and deleting the source file on a branch.
move <src> <dest> --branch <branch_name> --message <commit_msg> - : Copy a file by creating the destination file on a branch.
copy <src> <dest> --branch <branch_name> --message <commit_msg> - : Create or update a file on a branch.
write <file_path> --stdin|--from-file <path> --branch <branch_name> --message <commit_msg>
所有操作均通过捆绑的脚本执行:
bash
python3 scripts/github_knowledge_skill.py --repo <owner/repo> <command> [args]如果技能已全局安装,脚本通常位于:
bash
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo <owner/repo> <command> [args]- :列出目录中的文件。
list --path <path> - :读取文件内容。
read <file_path> - :搜索代码/内容。
search <query> - :通过在分支上创建目标文件并删除源文件来移动/重命名文件。
move <src> <dest> --branch <branch_name> --message <commit_msg> - :在分支上创建目标文件以完成复制操作。
copy <src> <dest> --branch <branch_name> --message <commit_msg> - :在分支上创建或更新文件。
write <file_path> --stdin|--from-file <path> --branch <branch_name> --message <commit_msg>
Repo Selection (Local Config)
仓库选择(本地配置)
To avoid hard-coding a personal repo in prompts, store your vault repo(s) locally and have the agent/tooling read it.
First-time setup: create :
~/.config/obsidian-gh-knowledge/config.jsonjson
{
"default_repo": "<owner>/<vault-repo>",
"repos": {
"personal": "<owner>/<vault-repo>",
"work": "<org>/<work-vault-repo>"
}
}Usage (resolve repo at runtime):
bash
REPO="$(python3 -c 'import json,os; p=os.path.expanduser("~/.config/obsidian-gh-knowledge/config.json"); print(json.load(open(p))["default_repo"])')"
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" list --path "0️⃣-Inbox"If the user specifies a repo key (e.g., ), resolve it from instead of .
workrepos.<key>default_repoExample (resolve repo key):
bash
REPO="$(python3 -c 'import json,os; p=os.path.expanduser("~/.config/obsidian-gh-knowledge/config.json"); c=json.load(open(p)); print(c["repos"]["work"])')"
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" search "dev plan"为避免在提示中硬编码个人仓库,请将你的库仓库信息存储在本地,让代理/工具读取。
首次设置:创建文件:
~/.config/obsidian-gh-knowledge/config.jsonjson
{
"default_repo": "<owner>/<vault-repo>",
"repos": {
"personal": "<owner>/<vault-repo>",
"work": "<org>/<work-vault-repo>"
}
}使用方法(运行时解析仓库):
bash
REPO="$(python3 -c 'import json,os; p=os.path.expanduser("~/.config/obsidian-gh-knowledge/config.json"); print(json.load(open(p))["default_repo"])')"
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" list --path "0️⃣-Inbox"如果用户指定了仓库密钥(例如),则从而非解析。
workrepos.<key>default_repo示例(解析仓库密钥):
bash
REPO="$(python3 -c 'import json,os; p=os.path.expanduser("~/.config/obsidian-gh-knowledge/config.json"); c=json.load(open(p)); print(c["repos"]["work"])')"
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" search "dev plan"Quick Workflow Example
快速工作流示例
When asked to find and read a note:
-
List to discover exact paths:bash
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" list --path "1️⃣-Index" -
Search if the path is unknown:bash
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" search "MOC" -
Read the target file:bash
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" read "1️⃣-Index/README.md"
当用户要求查找并读取笔记时:
-
列出目录以获取精确路径:bash
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" list --path "1️⃣-Index" -
如果路径未知,使用搜索:bash
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" search "MOC" -
读取目标文件:bash
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" read "1️⃣-Index/README.md"
Search Query Tips
搜索查询技巧
The command uses GitHub code search. Include qualifiers directly in your query string:
searchbash
undefinedsearchbash
undefinedSearch in specific folder
在特定文件夹中搜索
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" search "TODO path:1️⃣-Index/"
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" search "TODO path:1️⃣-Index/"
Search project notes
搜索项目笔记
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" search "project plan path:5️⃣-Projects/ extension:md"
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" search "project plan path:5️⃣-Projects/ extension:md"
Find all project overviews
查找所有项目概览文件
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" search "filename:_Overview.md"
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" search "filename:_Overview.md"
Find specific project overview
查找特定项目概览文件
python3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" search "filename:_Overview.md path:5️⃣-Projects/GitHub/cmux"
undefinedpython3 ~/.agents/skills/obsidian-gh-knowledge/scripts/github_knowledge_skill.py --repo "$REPO" search "filename:_Overview.md path:5️⃣-Projects/GitHub/cmux"
undefinedWorkflow Reference
工作流参考
See for a concrete organizing workflow that uses these commands.
references/obsidian-organizer.md请查看文件,获取使用这些命令的具体整理工作流。
references/obsidian-organizer.mdNotes
注意事项
- uses GitHub code search; results may be empty for new commits until GitHub indexes them (typically seconds to minutes).
search - Qualifiers like ,
path:,extension:can narrow results - include them directly in the query string.filename: - Paths must match the repo exactly (including emoji and normalization). Use to discover the exact directory names.
list - Every project folder under MUST have a
5️⃣-Projects/file as its MOC index._Overview.md - When creating new project documentation, always create first, then add related notes.
_Overview.md
- 命令使用GitHub代码搜索;新提交的内容可能需要几秒到几分钟的时间才能被GitHub索引,因此可能会出现无结果的情况。
search - 、
path:、extension:等限定符可缩小搜索范围 - 直接在查询字符串中包含它们即可。filename: - 路径必须与仓库中的路径完全匹配(包括表情符号和标准化格式)。使用命令获取精确的目录名称。
list - 下的每个项目文件夹必须包含一个
5️⃣-Projects/文件作为其MOC索引。_Overview.md - 创建新项目文档时,请始终先创建,再添加相关笔记。
_Overview.md
Recovery Procedures
恢复流程
If files are accidentally deleted or corrupted:
如果文件被意外删除或损坏:
From Local Vault (Preferred)
从本地库恢复(优先推荐)
bash
cd ~/Documents/obsidian_vault
git reflog # Find good commit
git reset --hard <commit-sha> # Restore locally
git push --force origin main # Sync to remote (only if local is source of truth)bash
cd ~/Documents/obsidian_vault
git reflog # 查找可用的提交记录
git reset --hard <commit-sha> # 在本地恢复
git push --force origin main # 同步到远程(仅当本地为可信数据源时使用)From Remote (if local is lost)
从远程恢复(如果本地库丢失)
bash
undefinedbash
undefinedList commits to find pre-deletion state
列出提交记录以查找删除前的状态
gh api repos/<owner>/<repo>/commits --jq '.[].sha' | head -10
gh api repos/<owner>/<repo>/commits --jq '.[].sha' | head -10
Check file count at each commit
检查每个提交的文件数量
gh api repos/<owner>/<repo>/git/trees/<sha>?recursive=1 --jq '.tree | length'
gh api repos/<owner>/<repo>/git/trees/<sha>?recursive=1 --jq '.tree | length'
Reset remote to good commit (DANGEROUS - confirm with user first)
将远程仓库重置到可用的提交记录(危险操作 - 请先获得用户确认)
gh api -X PATCH repos/<owner>/<repo>/git/refs/heads/main
-F sha=<good-commit-sha> -F force=true
-F sha=<good-commit-sha> -F force=true
undefinedgh api -X PATCH repos/<owner>/<repo>/git/refs/heads/main
-F sha=<good-commit-sha> -F force=true
-F sha=<good-commit-sha> -F force=true
undefinedComparison: GitHub API vs Local Git
GitHub API vs 本地Git 对比
| Operation | GitHub API | Local Git |
|---|---|---|
| Recovery | Hard (no reflog) | Easy (reflog) |
| Atomic commits | Per-file only | Multi-file |
| Speed | Slower (HTTP) | Faster |
| Offline | No | Yes |
| Audit trail | Limited | Full |
Recommendation: When exists, prefer local git operations.
~/Documents/obsidian_vault/| 操作 | GitHub API | 本地Git |
|---|---|---|
| 数据恢复 | 困难(无reflog) | 简单(有reflog) |
| 原子提交 | 仅支持单文件 | 支持多文件 |
| 速度 | 较慢(HTTP请求) | 较快 |
| 离线支持 | 不支持 | 支持 |
| 审计追踪 | 有限 | 完整 |
推荐:当路径存在时,优先使用本地git操作。
~/Documents/obsidian_vault/