Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
Linking — mechanics
(Core carries the MUST: link noun-phrases with standard markdown links, every link resolves, read brokenLinks on each write/edit. This file carries the full rule set.)
- Every noun-phrase that names another document should be linked using standard markdown link syntax. Two forms are valid: relative (
[text](./sibling.md),[text](../folder/doc.md)) — the recommended default, native in GitHub / Obsidian / VS Code and what published sites expect — and root-absolute ([text](/folder/doc.md), leading slash = content root), handy for a cross-folder link. - Never glue
./onto a content-root path../wiki/modules/tasks, written from a doc already insidewiki/, resolves to the doubled garbagewiki/wiki/modules/tasks— correct resolution of a malformed path, i.e. a silently broken link. Pick ONE form: a relative path from your doc (./tasks.md,../modules/tasks.md), or a/-rooted absolute path (/wiki/modules/tasks.md). The./prefix and a content-root path never combine. - External web sources are NOT inline body links. Per the Grounding rule, web URLs live in the
source_url:frontmatter of an ingested doc underexternal-sources/(or the project's equivalent raw-sources folder); the body cites the local path:[source name](./external-sources/source-slug.md). A raw[source](https://...)inline in the body is a TODO, not a citation — see Grounding for the closed-loop contract. - Internal cross-refs between OK docs →
[text](./other-doc.md)— link liberally to aid navigation. - Link the section when you mean one part of a long document —
[text](./spec.md#heading-slug), in docs and in chat replies alike, so the reader lands on the heading instead of scrolling a long file (in the WYSIWYG editor; the source editor ignores the fragment and opens at the top). In a chat reply there is no document for a relative path to start from: write the path from the content root, as./specs/spec.md#heading-slugor/specs/spec.md#heading-slug, never with../, which the chat cannot resolve. The slug is the heading's text lowercased, accents on Latin, Greek, Cyrillic, Arabic and Hebrew letters dropped (other scripts keep their marks, so## ガラス→#ガラス), with each run of characters that are not letters or digits replaced by one-and edge hyphens removed (## Data model: v2→#data-model-v2); the second identical heading in a doc gets-1, the third-2. Copy the heading text rather than guessing:brokenLinksandauditcheck only the path before#, so a wrong slug still resolves as a link to the top of the doc. - Every link must resolve to a doc that exists by the time you're done. Within a single multi-doc authoring pass, linking a page you'll create later in the same pass is fine —
brokenLinksreports it asno-such-docuntil the target lands, an expected transient forward-reference rather than a wrong-path error. What's not acceptable is leaving a dead link behind: create the target in the same pass, or record it as a tracked task (TaskCreate, or your host's task tool — if the host has none, tell the user) and leave the mention as plain prose. - Never wrap a link in backticks.
`[text](./foo.md)`is a bug — the backticks make it render as literal code rather than a link. - Never use HTML anchors (
<a href="...">). Markdown link syntax only. brokenLinkson the write/edit response is your primary check — read it before walking away. Everywrite/editreturnsbrokenLinksin the SAME payload:[]means every outbound link resolves only whenbrokenLinkSuppressionis absent andwarningshas nolink-check-deferredentry (that entry means the server was still starting, or busy with other writes, and checked nothing — that doc's links are re-checked only when you write or edit it again later, or by anaudit, which can time out while the server is still starting); a populated list names each brokenhrefwith itsresolvedTo+reason(no-such-doc= resolved to a doc that doesn't exist;no-such-file= resolved to a linked asset / source file that isn't on disk at that path;excluded= the file is on disk but a.gitignoreor.okignorerule keeps it out of the project, so re-include it or its folder with a!rule in.okignore(for example!ignored/) or link something else;unresolvable= the path escapes the content root, usually one../too many). This validates every local link, not just doc links: a wrong-depth[src](../../foo.py)to a source file is caught too. It is report-only — the write landed regardless; fix or remove every one in a follow-upedit.- An empty
brokenLinksalongside abrokenLinkSuppressiondoes not mean every link resolves. That field appears only when the project's reserved-log policy withheld findings, and it carries{ reason: "reserved-log-policy", count: N }and nothing else. No href comes back because none of them is repair work: the write landed in a lowercase-stemmedlog.mdorlog.mdx, an append-only history whose entries deliberately reference pages that moved or were never written. Never rewrite a reserved log's existing entries to clear a link. Append new entries instead, and treatlinks({ kind: "dead" })on that file as a deliberate audit of raw state, never as a repair queue. The project can turn the policy off (Settings ▸ This project ▸ Preferences ▸ Content rules), in which case those findings come back through the normal channels. auditis the authoritative end-state link check — run it once at the end of a multi-doc pass. ReadbrokenLinkSuppressionon its result too: when present, the reserved-log policy withheldcountfindings, so a clean result is filtered rather than proof that every raw link resolves. Do not repair those log findings; uselinks({ kind: "dead" })only when deliberately inspecting raw state. Caveat:auditreports links only while the project'svalidation.linkssetting is notoff(atoffit returns clean with no warning), so if the project has silenced link validation, fall back tolinks({ kind: "dead" })— the unconditional read of the dead-link graph, which also lists skill-bundle docs excluded from the Problems plane (optionally scoped:links({ kind: "dead", sourceDocuments: ["your/doc"] })). Otherwiselinksis the graph-navigation reader, supplemental toaudit, not a substitute. Companionlinkskinds:backlinks(incoming),forward(outgoing),orphans(no incoming),hubs(high-incoming),suggest(untextualized mentions worth linking).- The tool and the editor agree. Both resolve a bare name the same way — exact, then slug, then folder index, then basename — so a link that opens when you click it is never reported dead, and a link reported dead is genuinely unresolvable. A target that names an asset, or names nothing at all, stays silent rather than being reported as a broken doc link.
Note on wiki-link syntax ([[Page]]): the parser still handles it for legacy content, but it's NO LONGER the recommended default. Write new content with standard markdown links per above. Seed-pack templates (ok seed --pack <name>) may still emit [[Page]] placeholders inside template body text — those are legacy. When you instantiate a seed-pack template, replace the legacy placeholders with standard markdown links during the {shape}-fill pass.