brain-link-discipline
它能做什么
这个技能为智能体在知识大脑中创建或编辑页面时设定了报告规则。适合需要打开智能体所提及页面的人。
适用场景
- ✓当你的智能体在大脑中创建或编辑页面,并向你报告结果时。
- ✓当智能体一次报告多个页面,且每个页面都需要自己的链接时。
- ✓当子智能体的结果中提到你需要打开的大脑页面时。
技能链接
https://github.com/garrytan/gbrain/blob/master/plugin-variants/gbrain-coding/skills/brain-link-discipline/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“你更新了大脑中的入职页面吗?请把链接发给我。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体先确定页面路径,在生成链接之前推送修改,检查链接是否有效;如果无法生成,则退回到一个已说明的替代方案。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
brain-link-discipline — The Link Is Part of the Deliverable
Convention: see _output-rules.md — the Deterministic Links section carries the cross-skill canon (in-page relative vs in-message verified, plus the fallback chain). This skill carries the mechanics: path derivation, push-before-link ordering, verification, the subagent-relay rewrite, and bulk-list formatting.
Convention: conventions/brain-first.md states the one-line principle ("every brain page reference in output should use a clickable link format appropriate to the deployment"). This skill is that line's full expansion.
This is a reporting convention the harness routes brain-page delivery messages through — a standing rule to apply when composing such messages, not a mechanical guarantee enforced by tooling.
The rule (same message)
If you commit and push a brain page, the link goes in the SAME message that reports the work. Every time. No "let me commit and push" without the link landing in that same reply once the push succeeds. The user should never have to ask "give me the link" or "where is the page."
This applies to:
- Any message reporting a created or edited brain page
- Bulk reports ("5 pages created" — every page gets its own link line)
- Referencing a brain page in normal conversation
- Relaying subagent results that mention brain paths (rewrite first — see below)
The most common link bug is committing a brain page and forcing the user to go find it. The link is a deliverable, not a follow-up.
Scope split: in-message vs in-page (the inversion)
The two output surfaces take OPPOSITE link forms:
| Surface | Link form | Why |
|---|---|---|
| Chat message to the user | Absolute, verified URL (or the fallback chain below) | Repo-relative paths aren't clickable in chat surfaces |
| Inside a brain page body | RELATIVE markdown link: [Alice Example](../people/alice-example.md) |
gbrain's link extraction builds the links/backlinks graph — which powers relational retrieval — from filesystem-relative links. An absolute URL between two brain pages is invisible to that graph |
Never write absolute URLs for page-to-page references inside a brain
page. Absolute URLs in a page body are for genuinely external targets
only. Frontmatter related: / people: keys stay bare relative paths
(machine-parsed, not rendered prose). After a link-heavy write,
gbrain check-backlinks check audits the graph and gbrain sync --no-pull
makes the pages searchable.
Deriving the path mechanically
The repo-relative path a hosted git remote serves is relative to the git
repo root (git rev-parse --show-toplevel), NOT your current working
directory. When the repo root sits above your working directory, hand-
stripping your cwd prefix silently drops the intermediate directory segment
and every link you build 404s. Never hand-strip a prefix. Derive:
# From anywhere inside the repo, prints the EXACT path the remote serves:
cd "$(dirname <file>)" && git ls-files --full-name "$(basename <file>)"
# e.g. people/alice-example.md
Then assemble:
https://<host>/<owner>/<repo>/blob/<branch>/<that-exact-path>
<host>/<owner>/<repo>fromgit remote get-url origin<branch>fromgit rev-parse --abbrev-ref HEAD(or the remote's default branch)/blob/for files,/tree/for directories (GitHub-style hosts)
Sequence (push BEFORE link)
- Write/edit the brain file.
scripts/brain-commit-push.sh "<msg>" <file>(orgbrain git commit-push -m "<msg>" -- <file>when the brain has no helper). It commits only that file under the checkout's writer lock and pushes, merging remote commits without touching other agents' files.- Verify the push landed — the command must exit 0 and print
pushed <sha> to origin/<branch>(ornothing to commit; a[gbrain notice]that the checkout lags is still a landed push). A hosted URL 404s until the push completes. On a non-zero exit, output no link: retry once oncommit_lock_busy; stop and tell the user onintegrate_conflictorwriter_coordinator_required; never fall back to stash,pull --rebaseor a plain push (outcomes). - In the SAME message that reports the commit, output the link — as a clickable markdown link or bare URL, never a backticked code span.
常见问题
为什么要先推送再生成链接?
技能说明,链接应指向已在线上存在的内容,因此推送要先完成。
如果没有托管的远程仓库怎么办?
技能为这种情况描述了一套备用方案,因此你仍能获得可用的引用。
这条规则也适用于大脑页面内部吗?
技能说明,在页面内部,这条规则的运作方式有所不同,因为会使用相对链接。
详情
作者的原始描述
When you report a brain page to the user — created, edited, committed, or relayed from a subagent — a working link is part of the deliverable, in the SAME message. Derive the path mechanically (git ls-files --full-name), push BEFORE linking, verify the link resolves when a hosted remote exists, and degrade through a defined fallback chain when it doesn't. Inside brain pages the rule inverts: relative links preserve the link graph; absolute URLs are for chat deliverables only.
repo: garrytan/gbrain
热度
- GitHub 星标
- 31k
- 排名
- #9249
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …