doctrack

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Doctrack — Codebase Knowledge Graph

Doctrack — 代码库知识图谱

You maintain a knowledge graph of project documentation in a local Obsidian vault (
.doctrack/
). The vault travels with the code in git — it's the project's persistent memory across sessions and team members.
This skill depends on the obsidian skill (
bitbonsai/mcpvault
) for all vault operations. The obsidian skill handles MCP tool usage, Obsidian CLI, and git sync. Doctrack focuses on what knowledge to capture and how to structure it — not the mechanics of reading/writing notes.
If the obsidian skill or MCP tools are not available, doctrack init will set them up automatically (see Pre-init).
你需要在本地Obsidian vault(
.doctrack/
)中维护项目文档的知识图谱。该vault会随代码一同提交至git——它是跨会话和跨团队成员的项目持久化记忆。
此技能依赖obsidian技能
bitbonsai/mcpvault
)来处理所有vault操作。obsidian技能负责MCP工具的使用、Obsidian CLI以及git同步。Doctrack专注于要捕获哪些知识以及如何构建知识结构——而非读写笔记的具体机制。
如果obsidian技能或MCP工具不可用,doctrack init会自动进行设置(参见预初始化部分)。

Knowledge graph structure

知识图谱结构

The vault contains these node types, connected by
[[wikilinks]]
:
NodeDirectoryPurposeAudience
Features
features/
What the system does. High-level functional units.Claude
Components
components/{feature}/
How pieces work internally. Dense implementation details.Claude
Concepts
concepts/
Cross-cutting ideas and patterns spanning multiple features.Claude + Human
Decisions
decisions/
Why things are the way they are — including rejected alternatives.Claude + Human
Interfaces
interfaces/
Contracts and boundaries between features or packages.Claude + Human
Guides
guides/
Procedural docs only: build, deploy, test, setup workflows.Human
Specs
specs/
Machine-readable specifications (OpenAPI, schemas).Machine
References
references/
Imported pre-existing docs and user-provided materials.Claude
Wikilinks are the edges. Every note should link to related notes — features link to their components, components link to interfaces they implement, concepts link to the features they span, decisions link to what they affect. This is what makes the vault navigable in Obsidian's graph view.
Use Mermaid for all diagrams. More token-efficient than ASCII art, natively rendered by Obsidian, and structured enough to parse and update programmatically. Use it for flowcharts, sequence diagrams, state machines, ER diagrams, class diagrams, and dependency graphs. Avoid ASCII art entirely.
Linking notes in Mermaid diagrams. To make Mermaid nodes clickable links to other notes, use Obsidian's
internal-link
class — NOT wikilink syntax inside node labels:
mermaid
graph TD
    A[Auth Service] --> B[Token Validator]
    B --> C[User Store]
    class A,B,C internal-link;
The node label text must match the note filename (without
.md
). Nodes with the
internal-link
class become clickable in Obsidian's reading view. Never put
[[wikilinks]]
inside Mermaid code blocks
— use wikilinks only in regular markdown content outside of code fences.
Avoid hex colors in Mermaid. Do NOT use
classDef
with hex color fills (e.g.,
classDef internal fill:#e1f5fe
). Obsidian interprets
#e1f5fe
inside code blocks as an inline hashtag and creates a spurious tag. If you need styling, use named CSS classes without
#
hex values, or skip styling entirely — the diagrams are informational, not decorative.
vault包含以下节点类型,通过
[[wikilinks]]
相互关联:
节点类型目录用途受众
功能(Features)
features/
系统实现的功能,即高层级功能单元。Claude
组件(Components)
components/{feature}/
各部分的内部工作原理,包含详细的实现细节。Claude
概念(Concepts)
concepts/
跨多个功能的通用理念和模式。Claude + 人类开发者
决策(Decisions)
decisions/
系统为何采用当前实现方式的原因——包括被否决的方案。Claude + 人类开发者
接口(Interfaces)
interfaces/
功能或包之间的契约与边界。Claude + 人类开发者
指南(Guides)
guides/
仅包含流程类文档:构建、部署、测试、设置工作流。人类开发者
规范(Specs)
specs/
机器可读的规范(如OpenAPI、数据模型)。机器
参考资料(References)
references/
导入的既有文档和用户提供的资料。Claude
Wikilinks是关联边。每个笔记都应链接到相关笔记——功能链接到其对应的组件,组件链接到其实现的接口,概念链接到其涉及的功能,决策链接到其影响的对象。这是Obsidian图谱视图中vault可导航的核心。
所有图表均使用Mermaid。相比ASCII图,它更节省token,能被Obsidian原生渲染,且结构足够规范以便程序化解析和更新。可用于流程图、序列图、状态机、ER图、类图和依赖图。完全避免使用ASCII图。
在Mermaid图表中链接笔记。要让Mermaid节点成为指向其他笔记的可点击链接,请使用Obsidian的
internal-link
类——不要在节点标签内使用wikilink语法:
mermaid
graph TD
    A[Auth Service] --> B[Token Validator]
    B --> C[User Store]
    class A,B,C internal-link;
节点标签文本必须与笔记文件名(不含
.md
)完全匹配。带有
internal-link
类的节点在Obsidian阅读视图中会变为可点击状态。绝对不要在Mermaid代码块内使用
[[wikilinks]]
——仅在代码块外的普通Markdown内容中使用wikilinks。
避免在Mermaid中使用十六进制颜色。不要使用带十六进制颜色填充的
classDef
(例如
classDef internal fill:#e1f5fe
)。Obsidian会将代码块内的
#e1f5fe
解析为行内标签,并创建不必要的标签。如果需要样式,请使用不带
#
十六进制值的命名CSS类,或者完全跳过样式——图表是用于展示信息的,而非装饰。

Tag taxonomy

标签分类体系

Every note gets three required tags (applied via the obsidian skill's tag management):
CategoryTags
Type
doctrack/type/feature
,
component
,
concept
,
decision
,
interface
,
guide
,
reference
,
spec
,
index
Status
doctrack/status/active
,
deprecated
,
draft
,
rejected
Audience
doctrack/audience/claude
,
human
,
machine
Additional:
doctrack/project/{name}
(shared vaults),
doctrack/package/{name}
(monorepos).
Only use tags from the
doctrack/
namespace.
Do not invent domain-specific tags (e.g.,
dojo/auth
,
keycloak
,
mongodb
). The tag taxonomy is intentionally controlled — domain-specific context belongs in note content and frontmatter fields, not in tags. Stray tags clutter the tag panel and create inconsistent filtering.
每个笔记都需要添加三个必填标签(通过obsidian技能的标签管理功能添加):
分类标签
类型
doctrack/type/feature
,
component
,
concept
,
decision
,
interface
,
guide
,
reference
,
spec
,
index
状态
doctrack/status/active
,
deprecated
,
draft
,
rejected
受众
doctrack/audience/claude
,
human
,
machine
附加标签:
doctrack/project/{name}
(共享vault)、
doctrack/package/{name}
(单体仓库)。
仅使用
doctrack/
命名空间下的标签
。不要创建领域特定的标签(例如
dojo/auth
,
keycloak
,
mongodb
)。标签分类体系是受控的——领域特定上下文应放在笔记内容和前置元数据字段中,而非标签里。无关标签会使标签面板混乱,并导致过滤结果不一致。

When to use this

使用场景

After making code changes: Update relevant documentation before finishing your response.
At session start: Run session init to orient yourself from previous sessions.
When the user asks: Documenting, updating docs, syncing, or generating documentation.
To initialize a project: When the user says "doctrack init".
To refresh stale docs: When the user says "doctrack refresh", "refresh docs", "update docs", or "sync docs".
Do NOT use for: Trivial formatting changes, comment-only edits, or read-only exploration.
代码修改后:在完成响应前更新相关文档。
会话开始时:运行会话初始化,从之前的会话中获取上下文。
用户请求时:记录代码、更新文档、同步文档或生成文档。
项目初始化时:当用户说"doctrack init"时。
刷新过时文档时:当用户说"doctrack refresh"、"refresh docs"、"update docs"或"sync docs"时。
请勿用于:无关紧要的格式修改、仅修改注释的编辑,或只读探索。

Session init (every session)

会话初始化(每次会话)

Runs at the start of every Claude session in a project with doctrack. Idempotent.
  1. Detect vault and init state: Check if
    .doctrack/
    exists on the filesystem.
    • If
      .doctrack/
      exists but
      _project.md
      doesn't → post-restart after dependency setup. Tell the user: "Your doctrack vault is set up. Say
      doctrack init
      to continue."
    • If
      _project.md
      exists and contains a
      Current phase
      field that is NOT
      complete
      interrupted init. Check which phase it's in and summarize progress. Tell the user: "Doctrack init was interrupted during {phase}. Say
      doctrack init
      to resume where we left off."
    • If
      .doctrack/
      doesn't exist → check
      CLAUDE.md
      for vault path info.
  2. Verify MCP connection: Check if
    mcp__obsidian__*
    tools are available.
    • If tools are available → try reading
      _project.md
      via MCP. If it works, proceed to step 3.
    • If tools are available but can't reach the vault → the MCP server may be pointing elsewhere. Check
      .mcp.json
      to see if it has the right vault path. If not, update it.
    • If tools are NOT available → check if
      .mcp.json
      exists with an obsidian server config. If not, create it:
      json
      {
        "mcpServers": {
          "obsidian": {
            "command": "npx",
            "args": ["@bitbonsai/mcpvault@latest", ".doctrack"]
          }
        }
      }
      Use relative paths (
      .doctrack
      not absolute) so the config works across clones and users. Claude Code sets the working directory to the project root when spawning MCP servers. Tell the user: "I've configured the MCP server in
      .mcp.json
      . Please restart Claude Code for the connection to activate." Then proceed with what you can do without MCP (read
      .doctrack/
      files directly from the filesystem using the Read tool as a fallback).
  3. Read project config: Load
    _project.md
    from the vault. Check
    doctrack_version
    (see Version tracking).
  4. Check doctrack-mcp version (if installed): Run this command (with a timeout to handle old binaries that don't support --version):
    bash
    timeout 2 doctrack-mcp --version 2>/dev/null || echo "unknown"
    Expected output format:
    doctrack-mcp {version} ({git-hash})
    . Compare the version against
    0.1.0
    (minimum required for this skill version).
    • If not found (
      command not found
      ) and
      cargo
      is available: run
      cargo install --git https://github.com/liamstar97/doctrack.git dt-mcp
      and tell the user to restart Claude Code for the MCP server to connect.
    • If output is
      unknown
      or version is older than required: run
      cargo install --git https://github.com/liamstar97/doctrack.git dt-mcp --force
      to update. Tell the user "Updated doctrack-mcp — restart Claude Code for the new version to take effect."
    • If
      cargo
      isn't available: skip silently, the vault works without the MCP server.
    • If up to date: proceed silently.
  5. Orient: Use vault stats to see recently modified notes. Load only docs relevant to the current task — don't read the whole vault.
在项目的每个Claude会话开始时运行,支持幂等操作。
  1. 检测vault和初始化状态:检查文件系统中是否存在
    .doctrack/
    • 如果
      .doctrack/
      存在但
      _project.md
      不存在 → 依赖设置完成后的重启。告知用户:"你的doctrack vault已设置完成。请输入
      doctrack init
      继续。"
    • 如果
      _project.md
      存在且其
      Current phase
      字段不为
      complete
      初始化被中断。检查当前处于哪个阶段并总结进度。告知用户:"Doctrack初始化在{phase}阶段被中断。请输入
      doctrack init
      从中断处恢复。"
    • 如果
      .doctrack/
      不存在 → 检查
      CLAUDE.md
      中的vault路径信息。
  2. 验证MCP连接:检查
    mcp__obsidian__*
    工具是否可用。
    • 如果工具可用 → 尝试通过MCP读取
      _project.md
      。如果成功,进入步骤3。
    • 如果工具可用但无法访问vault → MCP服务器可能指向了其他位置。检查
      .mcp.json
      是否包含正确的vault路径。如果没有,更新它。
    • 如果工具不可用 → 检查是否存在带有obsidian服务器配置的
      .mcp.json
      。如果不存在,创建该文件:
      json
      {
        "mcpServers": {
          "obsidian": {
            "command": "npx",
            "args": ["@bitbonsai/mcpvault@latest", ".doctrack"]
          }
        }
      }
      使用相对路径
      .doctrack
      而非绝对路径),确保配置在不同克隆和用户环境中都能正常工作。Claude Code在启动MCP服务器时会将工作目录设置为项目根目录。 告知用户:"我已在
      .mcp.json
      中配置了MCP服务器。请重启Claude Code以激活连接。" 然后在没有MCP的情况下继续完成可执行的操作(作为备选方案,使用Read工具直接从文件系统读取
      .doctrack/
      文件)。
  3. 读取项目配置:从vault中加载
    _project.md
    。检查
    doctrack_version
    (参见版本跟踪部分)。
  4. 检查doctrack-mcp版本(如果已安装):运行以下命令(设置超时以处理不支持--version的旧版本二进制文件):
    bash
    timeout 2 doctrack-mcp --version 2>/dev/null || echo "unknown"
    预期输出格式:
    doctrack-mcp {version} ({git-hash})
    。将版本与
    0.1.0
    (此技能版本的最低要求)进行比较。
    • 如果未找到(提示
      command not found
      )且
      cargo
      可用:运行
      cargo install --git https://github.com/liamstar97/doctrack.git dt-mcp
      ,并告知用户重启Claude Code以连接MCP服务器。
    • 如果输出为
      unknown
      或版本低于要求:运行
      cargo install --git https://github.com/liamstar97/doctrack.git dt-mcp --force
      进行更新。告知用户"已更新doctrack-mcp —— 请重启Claude Code使新版本生效。"
    • 如果
      cargo
      不可用:静默跳过,vault在没有MCP服务器的情况下仍可工作。
    • 如果版本符合要求:静默继续。
  5. 获取上下文:使用vault统计信息查看最近修改的笔记。仅加载与当前任务相关的文档——不要读取整个vault。

Doctrack refresh

Doctrack刷新

When the user says "doctrack refresh", "refresh docs", "update docs", or "sync docs" — or when you detect that code has changed and docs may be stale. Requires the doctrack MCP server (
mcp__doctrack__*
tools).
If doctrack MCP tools are not available, tell the user: "The doctrack MCP server is needed for refresh. Run
cargo install --git https://github.com/liamstar97/doctrack.git dt-mcp
and restart Claude Code."
当用户说"doctrack refresh"、"refresh docs"、"update docs"或"sync docs"时——或者当你检测到代码已更改且文档可能过时的时候。需要doctrack MCP服务器
mcp__doctrack__*
工具)。
如果doctrack MCP工具不可用,告知用户:"刷新功能需要doctrack MCP服务器。请运行
cargo install --git https://github.com/liamstar97/doctrack.git dt-mcp
并重启Claude Code。"

Refresh flow

刷新流程

  1. Get the refresh plan: Call
    refresh_docs
    . This returns a prioritized list of stale notes with specific reasons (code newer than doc, missing symbols, broken refs).
  2. If nothing is stale: Report "All documentation is up to date" and stop.
  3. Work through stale notes in priority order (HIGH → MEDIUM → LOW):
    For each stale note: a. Read the note via obsidian MCP to understand its current content. b. Read the changed code files listed in the refresh plan reasons. Focus on the symbols and sections that changed. c. Update the note via obsidian MCP (
    patch_note
    for surgical edits,
    write_note
    for significant rewrites):
    • Fix broken file references with correct paths (use
      resolve_symbol
      if needed)
    • Add documentation for new symbols the note is missing
    • Update descriptions for renamed or modified symbols
    • Fix broken wikilinks
    • Update
      last_updated
      frontmatter to today's date d. Validate the note: Call
      validate_note
      on the updated note. Fix any remaining issues.
  4. Handle undocumented code files: If
    refresh_docs
    reported undocumented files:
    • For files that belong to an existing feature, create component notes
    • For files that represent new features, create feature notes
    • Follow the same write-as-you-go pattern from init (write immediately, tag, link)
  5. Verify: Call
    refresh_docs
    again. It should return "All documentation is up to date." If issues remain, continue from step 3.
  6. Report: Tell the user what was updated — e.g., "Updated 5 notes, created 2 new component notes, fixed 3 broken references."
  1. 获取刷新计划:调用
    refresh_docs
    。这会返回一个按优先级排序的过时笔记列表,并附带具体原因(代码比文档新、缺失符号、无效引用)。
  2. 如果没有过时内容:报告"所有文档均为最新版本"并停止。
  3. 按优先级处理过时笔记(高→中→低):
    对于每个过时笔记: a. 读取笔记:通过obsidian MCP读取笔记,了解其当前内容。 b. 读取变更的代码文件:查看刷新计划原因中列出的已更改代码文件。重点关注已更改的符号和部分。 c. 更新笔记:通过obsidian MCP更新笔记(小范围修改用
    patch_note
    ,大幅重写用
    write_note
    ):
    • 修复无效的文件引用,使用正确路径(必要时使用
      resolve_symbol
    • 为笔记中缺失的新符号添加文档
    • 更新重命名或修改后的符号描述
    • 修复无效的wikilinks
    • last_updated
      前置元数据更新为当前日期 d. 验证笔记:调用
      validate_note
      验证更新后的笔记。修复所有剩余问题。
  4. 处理未记录的代码文件:如果
    refresh_docs
    报告存在未记录的文件:
    • 对于属于现有功能的文件,创建组件笔记
    • 对于代表新功能的文件,创建功能笔记
    • 遵循初始化时的"边写边存"模式(立即写入、添加标签、建立链接)
  5. 验证:再次调用
    refresh_docs
    。它应返回"所有文档均为最新版本"。如果仍有问题,从步骤3继续。
  6. 报告:告知用户更新内容——例如,"已更新5个笔记,创建2个新组件笔记,修复3个无效引用。"

Incremental refresh (after specific code changes)

增量刷新(特定代码变更后)

When you've just modified code files (not a full refresh), use the targeted workflow instead:
  1. Call
    check_impact
    for each file you changed
  2. Read and update only the impacted notes
  3. Call
    validate_note
    on each updated note
This is faster than a full
refresh_docs
when you know exactly what changed.
当你刚修改了代码文件(非全量刷新)时,使用针对性工作流:
  1. 为每个已更改的文件调用
    check_impact
  2. 仅读取和更新受影响的笔记
  3. 为每个更新后的笔记调用
    validate_note
当你明确知道变更内容时,这比全量
refresh_docs
更快。

Vault layout

Vault布局

Local vault (default)

本地vault(默认)

project-root/
├── .doctrack/                      # Obsidian vault — committed to git
│   ├── .obsidian/                  # Obsidian config
│   ├── _project.md                 # Project config — always read first
│   ├── features/
│   ├── components/
│   ├── concepts/
│   ├── decisions/
│   ├── interfaces/
│   ├── guides/
│   ├── specs/
│   └── references/
├── README.md
├── CLAUDE.md
└── src/
project-root/
├── .doctrack/                      # Obsidian vault — 提交至git
│   ├── .obsidian/                  # Obsidian配置
│   ├── _project.md                 # 项目配置 — 始终优先读取
│   ├── features/
│   ├── components/
│   ├── concepts/
│   ├── decisions/
│   ├── interfaces/
│   ├── guides/
│   ├── specs/
│   └── references/
├── README.md
├── CLAUDE.md
└── src/

Monorepo

单体仓库(Monorepo)

.doctrack/
├── _project.md                     # Root: package map, cross-package deps
├── packages/
│   └── {package-name}/
│       ├── _package.md
│       ├── features/ components/ concepts/ decisions/ interfaces/
│       └── ...
├── concepts/                       # Monorepo-wide concepts
├── decisions/                      # Monorepo-wide decisions
├── interfaces/                     # Cross-package contracts
├── guides/
└── references/
.doctrack/
├── _project.md                     # 根目录:包映射、跨包依赖
├── packages/
│   └── {package-name}/
│       ├── _package.md
│       ├── features/ components/ concepts/ decisions/ interfaces/
│       └── ...
├── concepts/                       # 单体仓库级别的通用概念
├── decisions/                      # 单体仓库级别的决策
├── interfaces/                     # 跨包契约
├── guides/
└── references/

Shared vault (multi-project)

共享vault(多项目)

Notes namespaced under
projects/{name}/
. A
_doctrack.md
at vault root lists all projects.
笔记以
projects/{name}/
为命名空间。vault根目录下的
_doctrack.md
列出所有项目。

Note templates

笔记模板

_project.md
(project config)

_project.md
(项目配置)

markdown
---
project: {project-name}
type: index
doctrack_version: "3.0.0"
monorepo: false
initialized: YYYY-MM-DD
last_updated: YYYY-MM-DD
---
markdown
---
project: {project-name}
type: index
doctrack_version: "3.0.0"
monorepo: false
initialized: YYYY-MM-DD
last_updated: YYYY-MM-DD
---

{Project Name}

{Project Name}

Features

Features

FeatureNoteDescriptionStatus
FeatureNoteDescriptionStatus

File Registry

File Registry

List individual source files, not directories. Each row maps a specific file to its feature and component.
Source FileFeatureComponent
src/controllers/UserController.javauser-managementuser-controller
src/services/AuthService.javaauthenticationauth-service-impl

Tags: `doctrack/type/index`, `doctrack/status/active`, `doctrack/audience/claude`
列出单个源文件,而非目录。每行将特定文件映射到其对应的功能和组件。
Source FileFeatureComponent
src/controllers/UserController.javauser-managementuser-controller
src/services/AuthService.javaauthenticationauth-service-impl

标签:`doctrack/type/index`, `doctrack/status/active`, `doctrack/audience/claude`

Feature note (
features/{name}.md
)

功能笔记(
features/{name}.md

markdown
---
feature: feature-name
type: feature
doctrack_version: "3.0.0"
files:
  - src/path/to/file.ts
last_updated: YYYY-MM-DD
status: active
---
markdown
---
feature: feature-name
type: feature
doctrack_version: "3.0.0"
files:
  - src/path/to/file.ts
last_updated: YYYY-MM-DD
status: active
---

Feature Name

Feature Name

Purpose

Purpose

What this feature does and why it exists.
该功能的作用及其存在的原因。

Architecture

Architecture

mermaid
flowchart TD
    A[Entry Point] --> B{Router}
    B --> C[Handler]
    C --> D[Service Layer]
    class A,B,C,D internal-link;
mermaid
flowchart TD
    A[Entry Point] --> B{Router}
    B --> C[Handler]
    C --> D[Service Layer]
    class A,B,C,D internal-link;

Key Files

Key Files

  • src/path/to/file.ts
    — Main entry point
  • src/path/to/file.ts
    — 主入口点

Dependencies

Dependencies

  • Internal: [[features/auth|Authentication]]
  • Concepts: [[concepts/health-data-model|Health Data Model]]
  • Interfaces: [[interfaces/api-contract|API Contract]]
  • External: express, lodash
  • Internal: [[features/auth|Authentication]]
  • Concepts: [[concepts/health-data-model|Health Data Model]]
  • Interfaces: [[interfaces/api-contract|API Contract]]
  • External: express, lodash

API Surface

API Surface

Key exports, endpoints, or interfaces.
关键导出、端点或接口。

Notes

Notes

Gotchas, tech debt, planned changes.

Tags: `doctrack/type/feature`, `doctrack/status/active`, `doctrack/audience/claude`
注意事项、技术债务、计划中的变更。

标签:`doctrack/type/feature`, `doctrack/status/active`, `doctrack/audience/claude`

Component note (
components/{feature}/{name}.md
)

组件笔记(
components/{feature}/{name}.md

markdown
---
feature: parent-feature
type: component
files:
  - src/path/to/component.ts
last_updated: YYYY-MM-DD
status: active
---
markdown
---
feature: parent-feature
type: component
files:
  - src/path/to/component.ts
last_updated: YYYY-MM-DD
status: active
---

Component Name

Component Name

Responsibility

Responsibility

Single-sentence description.
单句描述组件职责。

Internal Logic

Internal Logic

mermaid
stateDiagram-v2
    [*] --> Idle
    Idle --> Active : trigger()
    Active --> Idle : complete()
mermaid
stateDiagram-v2
    [*] --> Idle
    Idle --> Active : trigger()
    Active --> Idle : complete()

Relationships

Relationships

  • Used by: [[features/auth|Authentication]]
  • Depends on: [[features/database|Database]]
  • Implements: [[interfaces/session-contract|Session Contract]]

Tags: `doctrack/type/component`, `doctrack/status/active`, `doctrack/audience/claude`
  • Used by: [[features/auth|Authentication]]
  • Depends on: [[features/database|Database]]
  • Implements: [[interfaces/session-contract|Session Contract]]

标签:`doctrack/type/component`, `doctrack/status/active`, `doctrack/audience/claude`

Concept note (
concepts/{name}.md
)

概念笔记(
concepts/{name}.md

Cross-cutting ideas that span multiple features. Create one when a pattern, model, or architectural idea connects disparate parts of the codebase.
markdown
---
type: concept
related_features:
  - feature-a
  - feature-b
last_updated: YYYY-MM-DD
status: active
---
跨多个功能的通用理念。当某个模式、模型或架构理念连接代码库中不同部分时,创建概念笔记。
markdown
---
type: concept
related_features:
  - feature-a
  - feature-b
last_updated: YYYY-MM-DD
status: active
---

Concept Name

Concept Name

What it is

What it is

Clear explanation and why it matters.
清晰的解释及其重要性。

Where it appears

Where it appears

mermaid
graph LR
    C[Concept] --> F1[Feature A]
    C --> F2[Feature B]
    C --> I[Interface]
    class C,F1,F2,I internal-link;
  • [[features/feature-a|Feature A]] — How it uses this concept
  • [[features/feature-b|Feature B]] — How it uses this concept
mermaid
graph LR
    C[Concept] --> F1[Feature A]
    C --> F2[Feature B]
    C --> I[Interface]
    class C,F1,F2,I internal-link;
  • [[features/feature-a|Feature A]] — 该功能如何使用此概念
  • [[features/feature-b|Feature B]] — 该功能如何使用此概念

Key decisions

Key decisions

  • [[decisions/relevant-decision|Why we chose this approach]]

Tags: `doctrack/type/concept`, `doctrack/status/active`, `doctrack/audience/claude`
  • [[decisions/relevant-decision|Why we chose this approach]]

标签:`doctrack/type/concept`, `doctrack/status/active`, `doctrack/audience/claude`

Decision note (
decisions/{name}.md
)

决策笔记(
decisions/{name}.md

Records why something was built a certain way — including rejected alternatives. This prevents re-proposing approaches that were already considered.
markdown
---
type: decision
status: accepted|rejected|superseded
date: YYYY-MM-DD
superseded_by: other-decision  # only if superseded
related_features:
  - feature-a
last_updated: YYYY-MM-DD
---
记录为何采用当前构建方式——包括被否决的备选方案。这可以避免重新提出已被考虑过的方案。
markdown
---
type: decision
status: accepted|rejected|superseded
date: YYYY-MM-DD
superseded_by: other-decision  # 仅当被取代时填写
related_features:
  - feature-a
last_updated: YYYY-MM-DD
---

Decision: Title

Decision: Title

Status

Status

Accepted | Rejected | Superseded by [[decisions/other|Other]]
Accepted | Rejected | Superseded by [[decisions/other|Other]]

Context

Context

What problem were we solving? What constraints existed?
我们要解决什么问题?存在哪些约束条件?

Decision

Decision

What we chose (or chose NOT to do, if rejected).
我们选择的方案(如果是被否决的,则是我们选择不做的事情)。

Alternatives considered

Alternatives considered

AlternativeProsConsWhy rejected
Option AFastFragileCouldn't handle scale
Option BSimpleLimitedMissing feature X
AlternativeProsConsWhy rejected
Option A快速脆弱无法处理大规模场景
Option B简单功能有限缺少功能X

Consequences

Consequences

What changed. Trade-offs accepted. Known limitations.

Tags: `doctrack/type/decision`, `doctrack/status/{accepted|rejected}`, `doctrack/audience/claude`

**When to create decisions:**
- Non-trivial architectural choices
- When you or the user reject an approach — document why
- When the user says "we tried X and it didn't work because Y"
- When a decision constrains future work
带来的变化。接受的权衡。已知的局限性。

标签:`doctrack/type/decision`, `doctrack/status/{accepted|rejected}`, `doctrack/audience/claude`

**何时创建决策笔记:**
- 非 trivial 的架构选择
- 当你或用户否决某个方案时——记录原因
- 当用户说"我们尝试过X但因为Y失败了"时
- 当某个决策会限制未来工作时

Interface note (
interfaces/{name}.md
)

接口笔记(
interfaces/{name}.md

Contracts between features or packages — boundaries where different parts meet.
markdown
---
type: interface
implementors:
  - feature-a
  - feature-b
consumers:
  - feature-c
last_updated: YYYY-MM-DD
status: active
---
功能或包之间的契约——不同部分的交互边界。
markdown
---
type: interface
implementors:
  - feature-a
  - feature-b
consumers:
  - feature-c
last_updated: YYYY-MM-DD
status: active
---

Interface: Name

Interface: Name

Contract

Contract

mermaid
classDiagram
    class HealthData {
        +String _id
        +int current_heart_rate
        +int total_steps
    }
mermaid
classDiagram
    class HealthData {
        +String _id
        +int current_heart_rate
        +int total_steps
    }

Implementors

Implementors

  • [[features/feature-a|Feature A]] — Produces this data
  • [[features/feature-a|Feature A]] — 生成此数据

Consumers

Consumers

  • [[features/feature-c|Feature C]] — Receives and validates
  • [[features/feature-c|Feature C]] — 接收并验证此数据

Validation rules

Validation rules

Key constraints on the contract.

Tags: `doctrack/type/interface`, `doctrack/status/active`, `doctrack/audience/claude`
契约的关键约束条件。

标签:`doctrack/type/interface`, `doctrack/status/active`, `doctrack/audience/claude`

Guide note (
guides/{name}.md
)

指南笔记(
guides/{name}.md

Procedural docs only — things a developer follows step-by-step.
Valid guides:
deployment.md
,
development.md
,
setup.md
,
testing.md
NOT guides: architecture overviews (→ concepts), feature explanations (→ features), API docs (→ specs/interfaces).
Tags:
doctrack/type/guide
,
doctrack/status/active
,
doctrack/audience/human
仅包含流程类文档——开发者需要逐步遵循的操作步骤。
有效的指南:
deployment.md
,
development.md
,
setup.md
,
testing.md
非指南内容:架构概述(→ 概念)、功能说明(→ 功能)、API文档(→ 规范/接口)。
标签:
doctrack/type/guide
,
doctrack/status/active
,
doctrack/audience/human

Doctrack MCP integration

Doctrack MCP集成

When the
doctrack
MCP server is available (tools prefixed
mcp__doctrack__
), use it to write better documentation and keep the vault healthy. The MCP server maintains a bidirectional index between code symbols and vault notes.
doctrack
MCP服务器可用时(工具前缀为
mcp__doctrack__
),使用它来编写更优质的文档并保持vault的健康状态。MCP服务器维护代码符号与vault笔记之间的双向索引。

Available tools

可用工具

ToolInputPurpose
validate_note
note
(vault-relative path)
Check a note for stale refs, broken wikilinks, ambiguous references
docs_for_file
file
(project-relative path)
Find all vault notes that document a code file
resolve_symbol
name
(e.g.
SessionManager
)
Look up where a symbol is defined and which notes reference it
check_impact
file
(project-relative path)
After code changes, find which vault notes may need updating
refresh_docs
(none)Scan vault and generate prioritized plan of stale documentation
coverage_report
(none)Vault health — note count, code files, link coverage, undocumented files
stale_report
(none)Full list of broken file refs and wikilinks across the vault
search_index
query
(keywords)
Fuzzy search across note titles, summaries, tags, and code symbols
工具输入用途
validate_note
note
(vault相对路径)
检查笔记是否存在过时引用、无效wikilinks、模糊引用
docs_for_file
file
(项目相对路径)
查找所有记录了该代码文件的vault笔记
resolve_symbol
name
(例如
SessionManager
查找符号的定义位置以及哪些笔记引用了它
check_impact
file
(项目相对路径)
代码变更后,查找哪些vault笔记可能需要更新
refresh_docs
(无)扫描vault并生成按优先级排序的过时文档计划
coverage_report
(无)vault健康状况——笔记数量、代码文件、链接覆盖率、未记录的文件
stale_report
(无)列出vault中所有无效文件引用和wikilinks
search_index
query
(关键词)
对笔记标题、摘要、标签和代码符号进行模糊搜索

During code changes

代码变更期间

  1. Before modifying code: Call
    docs_for_file
    with the file you're about to change. Read the linked vault notes to understand the documented architecture and contracts before making changes.
  2. After modifying code: Call
    check_impact
    with the changed file path to see which vault notes reference it. Update those notes if the changes affect documented behavior, renamed symbols, or moved files.
  1. 修改代码前:调用
    docs_for_file
    传入你要修改的文件。在修改前,读取关联的vault笔记以了解已记录的架构和契约。
  2. 修改代码后:调用
    check_impact
    传入已更改的文件路径,查看哪些vault笔记引用了该文件。如果变更影响了已记录的行为、重命名了符号或移动了文件,更新这些笔记。

During documentation writing

文档编写期间

  1. Before writing a note: Call
    resolve_symbol
    to get accurate file paths and line numbers for symbols you're documenting. Use the resolved paths in
    files:
    frontmatter and
    file-registry
    entries — don't guess or abbreviate paths.
  2. After writing or updating a note: Call
    validate_note
    with the note path (relative to vault root, e.g.
    features/auth.md
    ). Fix any stale references, ambiguous file refs, or broken wikilinks it reports before moving on.
  1. 编写笔记前:调用
    resolve_symbol
    获取你要记录的符号的准确文件路径和行号。在
    files:
    前置元数据和
    file-registry
    条目中使用解析后的路径——不要猜测或缩写路径。
  2. 编写或更新笔记后:调用
    validate_note
    传入笔记路径(相对于vault根目录,例如
    features/auth.md
    )。在继续下一步前,修复它报告的所有过时引用、模糊文件引用或无效wikilinks。

Refreshing stale documentation

刷新过时文档

Call
refresh_docs
to get a prioritized plan of what needs updating. It compares note
last_updated
timestamps against code file modification times, detects new/missing symbols, and finds broken references. Use it:
  • At session start (after reading
    _project.md
    ) to see what's drifted since last session
  • After a batch of code changes to identify all impacted docs at once
  • After updating docs to verify nothing remains stale (idempotent — returns empty when everything is current)
The tool returns a prioritized list (HIGH/MEDIUM/LOW) with specific reasons per note. Work through them in priority order — HIGH means broken refs or code changed significantly, LOW means minor symbol drift.
调用
refresh_docs
获取按优先级排序的更新计划。它会比较笔记的
last_updated
时间戳与代码文件的修改时间,检测新的/缺失的符号,并查找无效引用。可在以下场景使用:
  • 会话开始时(读取
    _project.md
    后)查看自上次会话以来的变更
  • 批量代码变更后一次性识别所有受影响的文档
  • 更新文档后验证是否还有过时内容(幂等操作——当所有内容都是最新时返回空)
该工具返回按优先级排序的列表(高/中/低),并附带每个笔记的具体原因。按优先级顺序处理——高优先级表示存在无效引用或代码发生了重大变更,低优先级表示符号有轻微变化。

For vault health

Vault健康维护

  • Call
    coverage_report
    during Phase 4 verification to see overall vault health, undocumented code files, and stale reference counts.
  • Call
    stale_report
    to get the full list of broken references for a cleanup pass.
  • Call
    search_index
    to find existing notes before creating duplicates.
  • 在第4阶段验证期间调用
    coverage_report
    查看整体vault健康状况、未记录的代码文件和过时引用数量。
  • 调用
    stale_report
    获取所有无效引用的完整列表以进行清理。
  • 在创建重复笔记前调用
    search_index
    查找现有笔记。

File path best practices (for MCP indexing)

文件路径最佳实践(针对MCP索引)

The MCP server resolves file references in your notes. Help it by:
  • Use full relative paths in
    files:
    frontmatter:
    custom-actions/src/main/java/com/iointel/ci/actions/Action.java
    not
    Action.java
    or
    .../Action.java
  • Avoid
    ...
    abbreviations
    in paths — the indexer can expand them but full paths are more reliable
  • Avoid glob patterns like
    *Exception.java
    in file references — they can't be resolved
  • Use backtick code spans for inline file references:
    `src/auth/session.rs`
    — the indexer extracts these
MCP服务器会解析笔记中的文件引用。遵循以下规则以帮助它正确解析:
  • files:
    前置元数据中使用完整相对路径
    :例如
    custom-actions/src/main/java/com/iointel/ci/actions/Action.java
    而非
    Action.java
    .../Action.java
  • 避免使用
    ...
    缩写路径
    ——索引器可以展开它们,但完整路径更可靠
  • 避免在文件引用中使用通配符模式
    *Exception.java
    ——无法被解析
  • 对行内文件引用使用反引号代码块
    `src/auth/session.rs`
    ——索引器会提取这些内容

Important principles

重要原则

  1. Read before writing. Search for existing notes before creating new ones.
  2. Dense internal docs. Features and components are for Claude — pack them with information.
  3. Document decisions, especially rejections. The "why not" is as valuable as the "why."
  4. Concepts connect the graph. When a pattern spans features, create a concept note and link everything to it.
  5. Interfaces define boundaries. When features communicate, document the contract.
  6. Guides are procedural only. Build, deploy, test, setup. Not explanations.
  7. Mermaid everywhere. All diagrams. No ASCII art. Use
    class NodeId internal-link;
    to make nodes clickable links to notes — never put
    [[wikilinks]]
    inside Mermaid code blocks.
  8. Incremental updates. Surgical edits, not full rewrites.
  9. Timestamp everything. Update
    last_updated
    on every modification.
  10. Local vault is the default.
    .doctrack/
    in the project directory, committed to git.
  11. Wikilinks are edges. Every cross-reference uses
    [[path|Display]]
    syntax.

  1. 先读后写。创建新笔记前先搜索现有笔记。
  2. 高密度的内部文档。功能和组件笔记是给Claude看的——尽可能填充详细信息。
  3. 记录决策,尤其是被否决的方案。"为什么不做"和"为什么做"同样重要。
  4. 概念连接知识图谱。当某个模式跨多个功能时,创建概念笔记并将所有相关内容链接到它。
  5. 接口定义边界。当功能之间进行通信时,记录契约。
  6. 指南仅包含流程。构建、部署、测试、设置。不包含解释性内容。
  7. 所有图表使用Mermaid。全部使用Mermaid,不使用ASCII图。在Mermaid节点中使用
    class NodeId internal-link;
    使节点成为可点击的笔记链接——绝对不要在Mermaid代码块内使用
    [[wikilinks]]
  8. 增量更新。进行小范围的精准编辑,而非全量重写。
  9. 所有内容都添加时间戳。每次修改时更新
    last_updated
  10. 默认使用本地vault。项目目录下的
    .doctrack/
    ,提交至git。
  11. Wikilinks是关联边。所有交叉引用都使用
    [[path|Display]]
    语法。

Version tracking and migration

版本跟踪与迁移

Current version:
3.0.0
.
当前版本:
3.0.0

Version history

版本历史

VersionKey changes
1.xFilesystem-only (
.claude_docs/
+
docs/
). Docs as files in repo.
2.0Local Obsidian vault (
.doctrack/
). Knowledge graph (concepts, decisions, interfaces). Mermaid diagrams. Depth-first init. Delegates vault I/O to obsidian skill (mcpvault).
3.0Companion
doctrack-mcp
Rust binary. Bidirectional code↔doc index via tree-sitter. MCP tools for validation, impact analysis, coverage, search. Claude Code hooks for proactive feedback. LSP server for editor integration.
版本主要变更
1.x仅基于文件系统(
.claude_docs/
+
docs/
)。文档作为仓库中的文件存在。
2.0本地Obsidian vault(
.doctrack/
)。知识图谱(概念、决策、接口)。Mermaid图表。深度优先初始化。将vault I/O委托给obsidian技能(mcpvault)。
3.0配套的
doctrack-mcp
Rust二进制文件。通过tree-sitter实现代码与文档的双向索引。用于验证、影响分析、覆盖率、搜索的MCP工具。Claude Code钩子用于主动反馈。用于编辑器集成的LSP服务器。

Version checking (during session init)

版本检查(会话初始化期间)

After reading
_project.md
, check
doctrack_version
:
  1. Missing → v1.x filesystem docs. Offer migration.
  2. Matches → proceed normally.
  3. Same major, older minor → proceed, silently update version stamp.
  4. Older major → inform user, offer migration. Don't auto-migrate.
  5. Newer than skill → warn user, proceed carefully.
读取
_project.md
后,检查
doctrack_version
  1. 缺失 → v1.x文件系统文档。提供迁移选项。
  2. 匹配 → 正常继续。
  3. 主版本相同,次版本较旧 → 继续,静默更新版本标记。
  4. 主版本较旧 → 告知用户,提供迁移选项。不要自动迁移。
  5. 版本比技能新 → 警告用户,谨慎继续。

Migration: v1 → v3

迁移:v1 → v3

When
.claude_docs/
exists but no
.doctrack/
:
  1. Read v1 docs (index, features, components — they have structured frontmatter)
  2. Create
    .doctrack/
    vault with
    .obsidian/
    and
    .gitignore
  3. Convert v1 notes to vault notes (convert cross-refs to wikilinks, add tags)
  4. Extract implicit concepts and decisions from v1 content
  5. Write
    _project.md
    from v1 index
  6. Write
    CLAUDE.md
    section
  7. Ask user: archive or clean up old
    .claude_docs/
    and
    docs/
.claude_docs/
存在但
.doctrack/
不存在时:
  1. 读取v1文档(索引、功能、组件——它们有结构化的前置元数据)
  2. 创建
    .doctrack/
    vault,包含
    .obsidian/
    .gitignore
  3. 将v1笔记转换为vault笔记(将交叉引用转换为wikilinks,添加标签)
  4. 从v1内容中提取隐含的概念和决策
  5. 根据v1索引编写
    _project.md
  6. 编写
    CLAUDE.md
    部分
  7. 询问用户是否要将文件系统中的副本归档到
    .doctrack/archive/

Migration: v2 → v3

迁移:v2 → v3

When
_project.md
exists with
doctrack_version: "2.x"
:
  1. Add
    concepts/
    ,
    decisions/
    ,
    interfaces/
    directories
  2. Move non-procedural guides to
    concepts/
    or deprecate
  3. Convert ASCII art to Mermaid in existing notes
  4. Update version stamp
  5. If vault is external, offer to move to local
    .doctrack/

_project.md
存在且
doctrack_version: "2.x"
时:
  1. 添加
    concepts/
    decisions/
    interfaces/
    目录
  2. 将非流程类指南移动到
    concepts/
    或标记为过时
  3. 将现有笔记中的ASCII图转换为Mermaid
  4. 更新版本标记
  5. 如果vault在外部,提供将其移动到本地
    .doctrack/
    的选项

Project initialization

项目初始化

When the user says "doctrack init" or asks to document a project.
当用户说"doctrack init"或要求记录项目文档时。

Pre-init

预初始化

Step 1: Install dependencies

步骤1:安装依赖

Check for obsidian skill: Look for
mcp__obsidian__*
tools in the available tools.
If MCP tools are NOT available:
  1. Check if
    .mcp.json
    exists in the project root. If it has an
    obsidian
    server entry, the MCP server is configured but Claude Code needs a restart.
  2. If no
    .mcp.json
    , check if the obsidian skill is installed by looking for
    .claude/skills/obsidian/
    or
    .agents/skills/obsidian/
    .
  3. If the obsidian skill is not installed, install it:
    bash
    npx skills add bitbonsai/mcpvault --yes
  4. Create or update
    .mcp.json
    in the project root:
    json
    {
      "mcpServers": {
        "obsidian": {
          "command": "npx",
          "args": ["@bitbonsai/mcpvault@latest", ".doctrack"]
        },
        "doctrack": {
          "command": "doctrack-mcp"
        }
      }
    }
    Always use relative paths
    .doctrack
    not absolute. Claude Code sets the working directory to the project root when spawning MCP servers.
    doctrack-mcp
    defaults to the current directory when
    DOCTRACK_ROOT
    is not set. This ensures the config works across clones, worktrees, and users.
    If
    .mcp.json
    already exists with other servers, merge the entries — don't overwrite existing config. The
    doctrack
    server is optional — only add it if
    doctrack-mcp
    is installed (
    which doctrack-mcp
    ). If not installed, skip it and note that the doctrack MCP tools won't be available.
  5. Also create the
    .doctrack/
    directory,
    .doctrack/.obsidian/
    , and
    .doctrack/.gitignore
    now — so the vault path in
    .mcp.json
    is valid when the MCP server starts.
  6. Set up doctrack MCP server. Check if
    doctrack-mcp
    is on PATH:
    bash
    which doctrack-mcp
    If not found, try to install it automatically:
    bash
    cargo install --git https://github.com/liamstar97/doctrack.git dt-mcp
    If
    cargo
    is not available either, tell the user: "Install Rust (https://rustup.rs) and run
    cargo install dt-mcp
    for code↔doc indexing tools, or skip it — the vault will still work without it." Then remove the
    doctrack
    entry from
    .mcp.json
    (only keep
    obsidian
    ).
    Once
    doctrack-mcp
    is available:
    • The
      doctrack
      entry in
      .mcp.json
      (step 4) will work as-is.
    • Install hooks: run
      doctrack-mcp --setup-hooks
      in the project directory. This adds SessionStart and PostToolUse hooks to
      .claude/settings.json
      for proactive code↔doc feedback.
  7. STOP and tell the user to restart. This is critical — you MUST clearly tell the user:
    "I've set up the doctrack dependencies:
    • Installed the obsidian skill (mcpvault)
    • Configured the MCP server(s) in
      .mcp.json
    • Created the
      .doctrack/
      vault directory
    • Installed Claude Code hooks (if doctrack-mcp is available)
    Please restart Claude Code (exit and relaunch), then say
    doctrack init
    again. The MCP server needs a restart to connect to the vault."
    After delivering this message, do not continue with init. Do not attempt to write vault notes, create features, or do any documentation work. The MCP connection will not be available until after the restart. End your response here.
If MCP tools ARE available → proceed to step 2.
检查obsidian技能:在可用工具中查找
mcp__obsidian__*
工具。
如果MCP工具不可用
  1. 检查项目根目录下是否存在
    .mcp.json
    。如果它包含
    obsidian
    服务器条目,则MCP服务器已配置但Claude Code需要重启。
  2. 如果没有
    .mcp.json
    ,通过查找
    .claude/skills/obsidian/
    .agents/skills/obsidian/
    来检查obsidian技能是否已安装。
  3. 如果obsidian技能未安装,安装它:
    bash
    npx skills add bitbonsai/mcpvault --yes
  4. 在项目根目录下创建或更新
    .mcp.json
    json
    {
      "mcpServers": {
        "obsidian": {
          "command": "npx",
          "args": ["@bitbonsai/mcpvault@latest", ".doctrack"]
        },
        "doctrack": {
          "command": "doctrack-mcp"
        }
      }
    }
    始终使用相对路径——
    .doctrack
    而非绝对路径。Claude Code在启动MCP服务器时会将工作目录设置为项目根目录。当未设置
    DOCTRACK_ROOT
    时,
    doctrack-mcp
    默认使用当前目录。这确保配置在不同克隆、工作树和用户环境中都能正常工作。
    如果
    .mcp.json
    已存在且包含其他服务器条目,合并条目——不要覆盖现有配置。
    doctrack
    服务器是可选的——仅当
    doctrack-mcp
    已安装时添加(通过
    which doctrack-mcp
    检查)。如果未安装,跳过它并记录doctrack MCP工具不可用。
  5. 同时创建
    .doctrack/
    目录、
    .doctrack/.obsidian/
    .doctrack/.gitignore
    ——这样当MCP服务器启动时,
    .mcp.json
    中的vault路径是有效的。
  6. 设置doctrack MCP服务器。检查
    doctrack-mcp
    是否在PATH中:
    bash
    which doctrack-mcp
    如果未找到,尝试自动安装:
    bash
    cargo install --git https://github.com/liamstar97/doctrack.git dt-mcp
    如果
    cargo
    也不可用,告知用户:"安装Rust(https://rustup.rs)并运行`cargo install dt-mcp
    以获取代码与文档的索引工具,或者跳过此步骤——vault在没有它的情况下仍可工作。" 然后从
    .mcp.json
    中移除
    doctrack
    条目(仅保留
    obsidian`)。
    一旦
    doctrack-mcp
    可用:
    • .mcp.json
      中的
      doctrack
      条目(步骤4)将按原样工作。
    • 安装钩子:在项目目录中运行
      doctrack-mcp --setup-hooks
      。这会在
      .claude/settings.json
      中添加SessionStart和PostToolUse钩子,以实现主动的代码与文档反馈。
  7. 停止并告知用户重启。这非常关键——你必须明确告知用户:
    "我已设置好doctrack的依赖:
    • 安装了obsidian技能(mcpvault)
    • .mcp.json
      中配置了MCP服务器
    • 创建了
      .doctrack/
      vault目录
    • 安装了Claude Code钩子(如果doctrack-mcp可用)
    请重启Claude Code(退出并重新启动),然后输入
    doctrack init
    继续。MCP服务器需要重启才能连接到vault。"
    发送此消息后,不要继续初始化。不要尝试写入vault笔记、创建功能或进行任何文档工作。在重启前,MCP连接不可用。在此处结束响应。
如果MCP工具可用 → 进入步骤2。

Step 2: Create local vault

步骤2:创建本地vault

  • Create
    .doctrack/
    directory on the filesystem
  • Create
    .doctrack/.obsidian/
    for Obsidian config
  • Write
    .doctrack/.gitignore
    :
    .obsidian/workspace.json
    .obsidian/workspace-mobile.json
    .obsidian/appearance.json
    .obsidian/hotkeys.json
    .obsidian/app.json
    .obsidian/graph.json
  • Verify MCP can reach the vault: try a simple
    get_vault_stats
    call. If it fails, the MCP server may be pointed at a different path — update
    .mcp.json
    and tell the user to restart.
  • Open the vault in Obsidian via the obsidian skill's CLI:
    obsidian open path="{absolute-path}/.doctrack"
    . If Obsidian CLI isn't available, tell the user: "Open
    .doctrack/
    as a vault in Obsidian to browse the knowledge graph."
  • 在文件系统中创建
    .doctrack/
    目录
  • 创建
    .doctrack/.obsidian/
    用于存储Obsidian配置
  • 编写
    .doctrack/.gitignore
    .obsidian/workspace.json
    .obsidian/workspace-mobile.json
    .obsidian/appearance.json
    .obsidian/hotkeys.json
    .obsidian/app.json
    .obsidian/graph.json
  • 验证MCP能否访问vault:尝试调用简单的
    get_vault_stats
    。如果失败,MCP服务器可能指向了其他路径——更新
    .mcp.json
    并告知用户重启。
  • 通过obsidian技能的CLI在Obsidian中打开vault:
    obsidian open path="{absolute-path}/.doctrack"
    。如果Obsidian CLI不可用,告知用户:"在Obsidian中打开
    .doctrack/
    作为vault以浏览知识图谱。"

Step 3: Detect project name

步骤3:检测项目名称

From
package.json
name
field, directory name, or ask the user.
package.json
name
字段、目录名称获取,或询问用户。

Step 4: Check for existing doctrack data

步骤4:检查现有doctrack数据

  • .claude_docs/
    on filesystem → v1, offer migration (see Version tracking)
  • _project.md
    in vault → already initialized, ask to re-init or abort
  • 文件系统中的
    .claude_docs/
    → v1版本,提供迁移选项(参见版本跟踪部分)
  • vault中的
    _project.md
    → 已初始化,询问用户是重新初始化还是终止

Step 5: Check for monorepo

步骤5:检查是否为单体仓库

Check for any of these indicators:
  • JS/TS:
    workspaces
    in
    package.json
    ,
    pnpm-workspace.yaml
    ,
    lerna.json
    ,
    turbo.json
    ,
    nx.json
  • Java/Kotlin:
    <modules>
    section in
    pom.xml
    (Maven multi-module),
    include
    in
    settings.gradle
    or
    settings.gradle.kts
    (Gradle multi-project)
  • Rust:
    [workspace]
    in root
    Cargo.toml
  • Go: Multiple
    go.mod
    files in subdirectories
  • Git:
    .gitmodules
    file (git submodules)
  • General:
    packages/
    ,
    apps/
    ,
    services/
    , or
    libs/
    directories containing multiple sub-projects with their own build configs
  • Multi-platform: Multiple independent sub-projects with their own
    .git
    directories under one parent
检查以下任何一项指标:
  • JS/TS
    package.json
    中的
    workspaces
    pnpm-workspace.yaml
    lerna.json
    turbo.json
    nx.json
  • Java/Kotlin
    pom.xml
    中的
    <modules>
    部分(Maven多模块)、
    settings.gradle
    settings.gradle.kts
    中的
    include
    (Gradle多项目)
  • Rust:根目录
    Cargo.toml
    中的
    [workspace]
  • Go:子目录中有多个
    go.mod
    文件
  • Git
    .gitmodules
    文件(git子模块)
  • 通用
    packages/
    apps/
    services/
    libs/
    目录包含多个子项目,且每个子项目有自己的构建配置
  • 多平台:一个父目录下有多个独立的子项目,每个子项目有自己的
    .git
    目录

Init strategy: depth-first, write-as-you-go, resumable

初始化策略:深度优先、边写边存、可恢复

Doctrack uses a depth-first approach with immediate writes and checkpoint tracking. This is critical for large projects where sessions may be interrupted by usage limits, timeouts, or restarts.
Core principles:
  • Process one module at a time in depth, not all modules broadly
  • Write each note to the vault immediately after creating it — don't batch writes
  • Checkpoint progress in
    _project.md
    after each module completes
  • On resume, detect what's already documented and continue where you left off
Doctrack采用深度优先的方法,结合立即写入检查点跟踪。这对于大型项目至关重要,因为会话可能会因使用限制、超时或重启而中断。
核心原则:
  • 一次深度处理一个模块,而非广泛处理所有模块
  • 创建每个笔记后立即写入vault——不要批量写入
  • 每个模块完成后在
    _project.md
    中记录检查点
  • 恢复时,检测已记录的内容并从中断处继续

Phase 1: Lightweight discovery

阶段1:轻量级发现

Read only build config and directory structure — do not read source files yet.
  1. Read build config
    pom.xml
    ,
    package.json
    ,
    build.gradle
    ,
    Cargo.toml
    , etc. Identify modules/packages and their dependencies.
  2. List modules — from build config or top-level directories. For each module, note: name, path, estimated size (file count via glob).
  3. Import existing docs — this step is important, don't skip it. Search the project for:
    • README.md
      at root and in each module
    • CLAUDE.md
      with project context
    • docs/
      ,
      documentation/
      ,
      wiki/
      directories
    • Architecture decision records (
      adr/
      ,
      decisions/
      )
    • API specs, design docs, runbooks,
      .md
      files in non-source directories
    For each found doc, write it to
    references/imported/{filename}.md
    in the vault with frontmatter including
    original_path
    . Tag with
    doctrack/type/reference
    . These are valuable source material — they often contain architectural context, decisions, and domain knowledge not visible in code.
    Ask user about archiving filesystem copies to
    .doctrack/archive/
    .
  4. Sort modules by dependency order — foundation/shared modules first. If unclear, smallest first.
  5. Write initial
    _project.md
    — module list with a
    Status
    column tracking init progress:
markdown
undefined
仅读取构建配置和目录结构——暂时不要读取源文件。
  1. 读取构建配置 ——
    pom.xml
    package.json
    build.gradle
    Cargo.toml
    等。识别模块/包及其依赖。
  2. 列出模块 —— 从构建配置或顶级目录中获取。对于每个模块,记录:名称、路径、估计大小(通过通配符统计文件数量)。
  3. 导入现有文档 —— 这一步很重要,不要跳过。在项目中搜索:
    • 根目录和每个模块中的
      README.md
    • 包含项目上下文的
      CLAUDE.md
    • docs/
      documentation/
      wiki/
      目录
    • 架构决策记录(
      adr/
      decisions/
    • API规范、设计文档、运行手册、非源目录中的
      .md
      文件
    对于每个找到的文档,将其写入vault中的
    references/imported/{filename}.md
    ,并在前置元数据中包含
    original_path
    。添加标签
    doctrack/type/reference
    。这些是有价值的源材料——它们通常包含架构上下文、决策和领域知识,这些在代码中是不可见的。
    询问用户是否要将文件系统中的副本归档到
    .doctrack/archive/
  4. 按依赖顺序排序模块 —— 先处理基础/共享模块。如果不确定,先处理最小的模块。
  5. 编写初始的
    _project.md
    —— 包含模块列表和跟踪初始化进度的
    Status
    列:
markdown
undefined

Init Progress

Init Progress

Current phase: phase-1
Current phase: phase-1

Modules

Modules

ModuleFilesStatusComponents
ci-model43pending
ci-common11pending
story-service300pending
ModuleFilesStatusComponents
ci-model43pending
ci-common11pending
story-service300pending

Phase 3 Checklist

Phase 3 Checklist

CategoryTargetCreatedStatus
Concepts6-100pending
Decisions5-80pending
Interfaces4-80pending
Referencesall docs0pending
READMEpending
CLAUDE.mdpending
Guidespending

This is the **checkpoint**. It tracks progress across ALL phases:

- **`Current phase`** — which phase the init is in (`phase-1`, `phase-2`, `phase-3`, `phase-4`, `complete`). Updated when transitioning between phases.
- **Modules table** — Phase 2 progress. Update each module to `done` with component count after completing it.
- **Phase 3 Checklist** — tracks cross-cutting note creation. Update `Created` count and `Status` after writing each category. This prevents Phase 3 from re-running on resume if it already completed.

On resume, read this checkpoint to determine:
1. Which phase to start from
2. Which modules still need documenting (Phase 2)
3. Which Phase 3 categories still need work
CategoryTargetCreatedStatus
Concepts6-100pending
Decisions5-80pending
Interfaces4-80pending
Referencesall docs0pending
READMEpending
CLAUDE.mdpending
Guidespending

这是**检查点**。它跟踪所有阶段的进度:

- **`Current phase`** —— 初始化所处的阶段(`phase-1`、`phase-2`、`phase-3`、`phase-4`、`complete`)。在阶段转换时更新。
- **Modules表格** —— 阶段2的进度。每个模块完成后,将其状态更新为`done`并填写组件数量。
- **Phase 3 Checklist** —— 跟踪跨模块笔记的创建。编写每个分类的笔记后,更新`Created`数量和`Status`。这可以防止阶段3在恢复时重复执行(如果已完成)。

恢复时,读取此检查点以确定:
1. 从哪个阶段开始
2. 哪些模块仍需要记录(阶段2)
3. 阶段3中哪些分类仍需要处理

Phase 2: Deep-dive modules (depth-first, write-as-you-go)

阶段2:深度处理模块(深度优先、边写边存)

Process modules one at a time (or 2-3 independent modules in parallel). For each module, follow this sequence — writing each note immediately, not batching:
Step A: Read source files for this module in small groups (5-10 files at a time for large modules). As you read each group, identify what component it belongs to.
Step B: Write the feature note immediately. Don't wait until you've read all files — write a draft feature note after reading enough to understand the architecture (first 10-15 files). You can patch it later with additional details. Getting the note into the vault early means it survives interruption.
Step C: Write each component note as you identify it. This is the critical change from batch writing: as soon as you understand a logical unit (a controller, a service, a model group), write its component note immediately. Then move to the next group of source files. This way, if the session ends mid-module, the components you've already written are preserved.
Component notes are not optional. Guidelines:
Module sizeExpected components
1-2 files0 (feature note is sufficient)
3-10 files2-5 components
10-30 files5-15 components
30-100 files15-30 components
100+ files30+ components
Step D: Tag each note immediately after writing it. Don't defer tagging to a batch step.
Step E: Checkpoint. After finishing a module (feature + all components), update
_project.md
via
patch_note
:
  • Set
    Current phase
    to
    phase-2
    (if not already)
  • Set this module's row in the Modules table to
    done
    with component count
  • Add file registry entries for this module (individual source files)
  • This is the checkpoint — if the session ends here, the next session knows this module is complete
Step F: Note cross-cutting observations as you go — shared patterns, architectural choices, contracts. Collect these for Phase 3 but don't write them yet.
Step G: Move to the next module.
Parallelization: Spawn subagents for 2-3 independent modules at a time — but each subagent must follow the write-as-you-go pattern internally. Don't spawn all modules in parallel.
Give each subagent this context:
You are documenting the "{module-name}" module for doctrack. Go DEEP.

Module path: {path}
Source files: {count} files
Module dependencies: {list of other modules this depends on}
Already-documented modules (for cross-referencing): {list with vault paths}

CRITICAL: Write each note IMMEDIATELY after creating it — do NOT batch writes.
The session may end at any time due to usage limits. Every note you write to
the vault before that happens is preserved. Every note you defer is lost.

Workflow:
1. Read source files in groups of 5-10
2. Write features/{module-name}.md as soon as you understand the architecture
3. Write components/{module-name}/{component}.md ONE AT A TIME as you identify each
4. Tag each note immediately after writing
5. Return: vault paths created + file registry entries (individual files)

A module with {count} files should produce roughly {count/5 to count/3} components.
Use internal-link class in Mermaid nodes. Use [[wikilinks]] in markdown content only.
Do NOT use classDef with hex colors (#e1f5fe etc.) — Obsidian creates spurious tags.
Vault paths must be clean note paths (e.g., features/auth.md, components/auth/token.md).
Never write notes with paths containing wildcards, code patterns, or Java package names.
一次处理一个模块(或同时处理2-3个独立模块)。对于每个模块,遵循以下流程——立即编写每个笔记,不要批量处理
步骤A:读取源文件 对于大型模块,分小组读取(每次5-10个文件)。读取每个小组时,识别它属于哪个组件。
步骤B:立即编写功能笔记。不要等到读取完所有文件——在读取足够多的文件以理解架构后(前10-15个文件),就编写功能笔记的草稿。之后可以补充更多细节。尽早将笔记写入vault意味着即使会话中断,它也能保留下来。
步骤C:识别到组件后立即编写每个组件笔记。这与批量编写的关键区别在于:一旦你理解了一个逻辑单元(控制器、服务、模型组),就立即编写其组件笔记。然后继续读取下一组源文件。这样,即使会话在处理模块中途结束,你已经编写的组件也会被保留。
组件笔记是必须的。参考指南:
模块大小预期组件数量
1-2个文件0(功能笔记已足够)
3-10个文件2-5个组件
10-30个文件5-15个组件
30-100个文件15-30个组件
100+个文件30+个组件
步骤D:编写每个笔记后立即添加标签。不要将标签操作推迟到批量步骤。
步骤E:记录检查点。完成一个模块(功能+所有组件)后,通过
patch_note
更新
_project.md
  • Current phase
    设置为
    phase-2
    (如果尚未设置)
  • 将该模块在Modules表格中的行设置为
    done
    并填写组件数量
  • 为该模块添加文件注册表条目(单个源文件)
  • 这是检查点——如果会话在此处结束,下一次会话会知道该模块已完成
步骤F:随时记录跨模块观察结果——共享模式、架构选择、契约。收集这些用于阶段3,但不要立即编写。
步骤G:处理下一个模块
并行处理:为2-3个独立模块生成子代理——但每个子代理必须在内部遵循边写边存的模式。不要同时处理所有模块。
为每个子代理提供以下上下文:
你正在为doctrack记录"{module-name}"模块。请深入处理。

模块路径:{path}
源文件:{count}个文件
模块依赖:{该模块依赖的其他模块列表}
已记录的模块(用于交叉引用):{带vault路径的列表}

关键要求:创建每个笔记后**立即**写入——不要批量写入。
由于使用限制,会话可能随时结束。你在结束前写入vault的每个笔记都会被保留。你推迟写入的每个笔记都会丢失。

工作流:
1. 分小组读取源文件(每次5-10个)
2. 一旦理解了架构,立即编写features/{module-name}.md
3. 识别到每个组件后,**逐个**编写components/{module-name}/{component}.md
4. 编写每个笔记后立即添加标签
5. 返回:创建的vault路径 + 文件注册表条目(单个文件)

一个包含{count}个文件的模块应生成大约{count/5到count/3}个组件。
在Mermaid节点中使用internal-link类。仅在Markdown内容中使用[[wikilinks]]。
不要使用带十六进制颜色的classDef(#e1f5fe等)——Obsidian会创建不必要的标签。
Vault路径必须是清晰的笔记路径(例如features/auth.md、components/auth/token.md)。
永远不要编写路径中包含通配符、代码模式或Java包名的笔记。

Phase 3: Build cross-cutting knowledge graph

阶段3:构建跨模块知识图谱

Update
Current phase
to
phase-3
in
_project.md
before starting.
After all modules are documented (or as many as completed before interruption), this phase is equally important as Phase 2 — it's what turns isolated feature docs into a connected knowledge graph. Don't rush or skip it.
Write each note immediately (same write-as-you-go principle as Phase 2). Checkpoint after each sub-phase by updating the Phase 3 Checklist in
_project.md
.
开始前,在
_project.md
中将
Current phase
更新为
phase-3
所有模块都已记录(或在中断前完成了尽可能多的模块)后,此阶段与阶段2同样重要——它将孤立的功能文档转换为互联的知识图谱。不要匆忙或跳过此阶段。
立即编写每个笔记(与阶段2相同的边写边存原则)。每个子阶段后记录检查点,更新
_project.md
中的Phase 3 Checklist。

3a. Concept notes

3a. 概念笔记

Create concept notes for every cross-cutting pattern that spans 2+ modules. Review the features you documented — what patterns appeared repeatedly?
Minimum guideline: A project with N modules should have roughly N/3 to N/2 concept notes. An 18-module project should produce 6-10 concepts.
Common concepts to look for:
  • Shared architectural patterns (event-driven messaging, circuit breaker, audit logging)
  • Domain models that cross module boundaries
  • Infrastructure patterns (service discovery, config management, security model)
  • Data flow patterns (ingestion pipeline, processing pipeline)
  • Operational patterns (monitoring, logging, deployment)
Checkpoint: After writing all concept notes, update the Phase 3 Checklist in
_project.md
: set Concepts row to
Created: {count}
,
Status: done
.
为每个跨2+个模块的通用模式创建概念笔记。回顾你已记录的功能——哪些模式反复出现?
最低指南:一个有N个模块的项目应大约有N/3到N/2个概念笔记。一个18模块的项目应生成6-10个概念。
常见的概念类型:
  • 共享架构模式(事件驱动消息、断路器、审计日志)
  • 跨模块边界的领域模型
  • 基础设施模式(服务发现、配置管理、安全模型)
  • 数据流模式(摄入管道、处理管道)
  • 操作模式(监控、日志、部署)
检查点:编写完所有概念笔记后,更新
_project.md
中的Phase 3 Checklist:将Concepts行设置为
Created: {count}
Status: done

3b. Decision notes

3b. 决策笔记

Create decision notes for every non-trivial architectural choice visible in the codebase. Look for:
  • Technology choices (why this database? why this messaging system? why this framework?)
  • Architectural patterns (why microservices? why event-driven? why this module structure?)
  • Design tradeoffs visible in code comments, README, or existing docs
  • Conventions that aren't obvious (why denormalized data? why this naming pattern?)
Minimum guideline: A project with N modules should have roughly N/3 decision notes. An 18-module project should produce 5-8 decisions. Each should include rejected alternatives.
Checkpoint: Update Decisions row in Phase 3 Checklist to
done
with count.
为代码库中每个非trivial的架构选择创建决策笔记。查找:
  • 技术选择(为什么使用这个数据库?为什么使用这个消息系统?为什么使用这个框架?)
  • 架构模式(为什么使用微服务?为什么使用事件驱动?为什么采用这种模块结构?)
  • 代码注释、README或现有文档中可见的设计权衡
  • 不明显的约定(为什么使用非规范化数据?为什么采用这种命名模式?)
最低指南:一个有N个模块的项目应大约有N/3个决策笔记。一个18模块的项目应生成5-8个决策。每个决策笔记应包含被否决的备选方案。
检查点:更新Phase 3 Checklist中的Decisions行为
done
并填写数量。

3c. Interface notes

3c. 接口笔记

Create interface notes for every contract between modules. Look for:
  • Shared DTOs/models passed between services
  • REST API contracts between services (Feign clients, HTTP endpoints)
  • Message schemas (Kafka topics, event formats)
  • Database document schemas shared across modules
  • Plugin/extension interfaces
Minimum guideline: A project with inter-service communication should have at least one interface per communication channel. An 18-module microservices project should produce 4-8 interface notes.
Checkpoint: Update Interfaces row in Phase 3 Checklist to
done
with count.
为每个模块之间的契约创建接口笔记。查找:
  • 服务之间传递的共享DTO/模型
  • 服务之间的REST API契约(Feign客户端、HTTP端点)
  • 消息模式(Kafka主题、事件格式)
  • 跨模块共享的数据库文档模式
  • 插件/扩展接口
最低指南:有服务间通信的项目应至少为每个通信通道创建一个接口笔记。一个18模块的微服务项目应生成4-8个接口笔记。
检查点:更新Phase 3 Checklist中的Interfaces行为
done
并填写数量。

3d. Import references

3d. 导入参考资料

Import any pre-existing documentation that wasn't captured in Phase 1:
  • README files from modules
  • Existing docs/, wiki/, or documentation directories
  • Architecture decision records (ADRs)
  • API specs, design docs, runbooks
  • CLAUDE.md files with project context
Write each to
references/imported/{filename}.md
in the vault. Tag with
doctrack/type/reference
.
Checkpoint: Update References row in Phase 3 Checklist to
done
with count.
导入阶段1中未捕获的任何既有文档:
  • 模块中的README文件
  • 现有的docs/、wiki/或documentation目录
  • 架构决策记录(ADRs)
  • API规范、设计文档、运行手册
  • 包含项目上下文的CLAUDE.md文件
将每个文档写入vault中的
references/imported/{filename}.md
。添加标签
doctrack/type/reference
检查点:更新Phase 3 Checklist中的References行为
done
并填写数量。

3e. Finalize project files and config

3e. 完成项目文件和配置

Write filesystem files and finalize the vault: 5. Write
README.md
on filesystem. 6. Write
CLAUDE.md
on filesystem (idempotent — read existing first, update the
# Doctrack
section in place or append if not present):
markdown
undefined
编写文件系统文件并完成vault: 5. 在文件系统中编写
README.md
。 6. 在文件系统中编写
CLAUDE.md
(幂等操作——先读取现有内容,更新或追加
# Doctrack
部分):
markdown
undefined

Doctrack

Doctrack

This project maintains a knowledge graph in
.doctrack/
(Obsidian vault).
此项目在
.doctrack/
(Obsidian vault)中维护知识图谱。

BEFORE writing any code

编写任何代码之前

You MUST read relevant documentation before planning or implementing changes:
  1. Read
    .doctrack/_project.md
    for project structure and module map
  2. Search the vault for features related to the code you'll touch:
    • Use
      mcp__obsidian__search_notes
      with the module/feature name
    • Read the matching feature note and its component notes
  3. Check
    concepts/
    for cross-cutting patterns that may affect your approach
  4. Check
    decisions/
    for past choices and rejected alternatives — do NOT re-propose approaches that were already considered and rejected
This context prevents duplicate work, respects architectural decisions, and ensures your changes align with existing patterns.
你必须先阅读相关文档,然后再规划或实现变更:
  1. 读取
    .doctrack/_project.md
    了解项目结构和模块映射
  2. 在vault中搜索与你要修改的代码相关的功能:
    • 使用
      mcp__obsidian__search_notes
      并传入模块/功能名称
    • 读取匹配的功能笔记及其组件笔记
  3. 检查
    concepts/
    中可能影响你实现方式的跨模块模式
  4. 检查
    decisions/
    中的过往选择和被否决的方案——不要重新提出 已被考虑并否决的方案
这些上下文可以避免重复工作、尊重架构决策,并确保你的变更与现有模式保持一致。

AFTER modifying code files

修改代码文件之后

You MUST update the knowledge graph to reflect your changes:
  1. Update the feature note if the feature's architecture, dependencies, or API changed
  2. Update or create component notes for any classes/modules you modified or added
  3. Create a decision note if you made a non-trivial design choice — include alternatives you considered and why you rejected them
  4. Update interfaces if contracts between modules changed
  5. Create a concept note if you introduced a new cross-cutting pattern
  6. Update
    _project.md
    file registry if you added new source files
Do NOT skip documentation updates. The knowledge graph is how future sessions understand this codebase without re-reading source files.
你必须更新知识图谱以反映你的变更:
  1. 如果功能的架构、依赖或API发生了变化,更新功能笔记
  2. 为你修改或添加的任何类/模块更新或创建组件笔记
  3. 如果你做出了非trivial的设计选择,创建决策笔记——包含 你考虑过的备选方案以及否决它们的原因
  4. 如果模块之间的契约发生了变化,更新接口笔记
  5. 如果你引入了新的跨模块模式,创建概念笔记
  6. 如果添加了新的源文件,更新
    _project.md
    中的文件注册表
不要跳过文档更新。知识图谱是未来会话无需重新读取源文件即可理解此代码库的方式。

Vault connection

Vault连接

  • Vault path:
    .doctrack/
  • MCP servers: configured in
    .mcp.json
    (obsidian server for vault I/O, doctrack server for code↔doc index)
  • If MCP tools are unavailable: read/write
    .doctrack/
    files directly from filesystem

7. **Write hooks** to `.claude/settings.json` (idempotent — read existing, merge, don't overwrite other settings):

Read the project's `.claude/settings.json` if it exists. Add or update hook entries. Preserve any existing hooks and settings.

```json
{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "test -f .doctrack/_project.md && echo 'Doctrack vault detected at .doctrack/. Read _project.md and relevant feature/component notes before starting work. Check decisions/ for past architectural choices.' || true",
            "statusMessage": "Checking for doctrack..."
          }
        ]
      }
    ]
  }
}
If
doctrack-mcp
is installed (check with
which doctrack-mcp
), also install hooks for proactive code↔doc feedback by running:
bash
doctrack-mcp --setup-hooks
This merges hooks into
.claude/settings.json
without overwriting existing settings:
  • SessionStart: shows vault coverage summary at the start of each session
  • PostToolUse: validates notes after writing them via obsidian MCP tools
If
.claude/settings.json
already has other hooks, the doctrack hooks are appended alongside them.
  1. Write procedural guides
    guides/development.md
    ,
    guides/deployment.md
    if applicable.
  2. Write specs
    specs/openapi.md
    if REST APIs exist.
  • Vault路径:
    .doctrack/
  • MCP服务器:在
    .mcp.json
    中配置(obsidian服务器用于vault I/O,doctrack服务器用于代码与文档索引)
  • 如果MCP工具不可用:直接从文件系统读取/写入
    .doctrack/
    文件

7. **编写钩子到`.claude/settings.json`**(幂等操作——读取现有内容,合并,不要覆盖其他设置):

读取项目的`.claude/settings.json`(如果存在)。添加或更新钩子条目。保留任何现有钩子和设置。

```json
{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "test -f .doctrack/_project.md && echo 'Doctrack vault detected at .doctrack/. Read _project.md and relevant feature/component notes before starting work. Check decisions/ for past architectural choices.' || true",
            "statusMessage": "Checking for doctrack..."
          }
        ]
      }
    ]
  }
}
如果
doctrack-mcp
已安装(通过
which doctrack-mcp
检查),还可以通过运行以下命令安装主动的代码与文档反馈钩子:
bash
doctrack-mcp --setup-hooks
这会将钩子合并到
.claude/settings.json
中而不覆盖现有设置:
  • SessionStart:在每个会话开始时显示vault覆盖率摘要
  • PostToolUse:通过obsidian MCP工具编写笔记后验证笔记
  1. 编写流程指南 —— 如
    guides/development.md
    guides/deployment.md
    (如果适用)。
  2. 编写规范 —— 如果存在REST API,编写
    specs/openapi.md

Phase 4: Verify completeness

阶段4:验证完整性

Update
Current phase
to
phase-4
in
_project.md
.
  1. Cross-reference pass — check wikilinks in Dependencies, Relationships, concept links, interface implementors. Fill gaps.
  2. File registry audit — compare source files against registry. Unmapped files → missed components.
  3. Component coverage check — flag modules where file count vs component count suggests gaps.
  4. Graph density check — report: total wikilinks, links per note, orphan notes (should be 0), cross-type links (links between different node types like feature→concept). A healthy vault has 3+ links per note and zero orphans.
  5. Tag audit — verify all notes have the required doctrack/ tags (type + status + audience). Flag any non-doctrack tags.
  6. Set
    Current phase
    to
    complete
    — remove the Init Progress section from
    _project.md
    or keep it as a record. The init is done.
_project.md
中将
Current phase
更新为
phase-4
  1. 交叉引用检查 —— 检查Dependencies、Relationships、概念链接、接口实现者中的wikilinks。填补空白。
  2. 文件注册表审计 —— 比较源文件与注册表。未映射的文件 → 遗漏的组件。
  3. 组件覆盖率检查 —— 标记文件数量与组件数量比例异常的模块(例如50个文件但0个组件),以便重新记录。
  4. 图谱密度检查 —— 报告:总wikilinks数量、每个笔记的链接数、孤立笔记(应为0)、跨类型链接(不同节点类型之间的链接,如功能→概念)。健康的vault每个笔记应有3+个链接,且没有孤立笔记。
  5. 标签审计 —— 验证所有笔记都包含必填的doctrack/标签(类型+状态+受众)。标记任何非doctrack标签。
  6. Current phase
    设置为
    complete
    —— 从
    _project.md
    中移除Init Progress部分,或保留作为记录。初始化完成。

Resuming an interrupted init

恢复中断的初始化

When session init detects an Init Progress section in
_project.md
, read the
Current phase
and checklist to determine where to resume:
If
Current phase
is
phase-1
: Phase 1 is lightweight — just re-run it.
If
Current phase
is
phase-2
:
  1. Tell the user: "Resuming doctrack init — {N} of {M} modules documented so far. Continuing with {next pending module}..."
  2. Process only modules with
    pending
    status.
  3. Check
    done
    modules for component coverage — flag any with suspiciously low counts (e.g., 50 files but 0 components) for re-documentation.
  4. After all modules complete, proceed to Phase 3.
If
Current phase
is
phase-3
:
  1. Tell the user: "Resuming doctrack init — modules are done, continuing with knowledge graph ({list pending categories})..."
  2. Read the Phase 3 Checklist. Only run sub-phases still marked
    pending
    (e.g., if Concepts is
    done
    but Decisions is
    pending
    , start from 3b).
  3. After Phase 3 completes, proceed to Phase 4.
If
Current phase
is
phase-4
: Tell the user "Resuming — running verification pass." Re-run verification.
If
Current phase
is
complete
: Init is already done. Tell the user: "This project is already initialized. To re-initialize from scratch, delete
.doctrack/
and run
doctrack init
again."
This means large projects can be initialized across multiple sessions — each session makes progress, checkpoints it, and the next session picks up exactly where it left off.
当会话初始化在
_project.md
中检测到Init Progress部分时,读取
Current phase
和检查点以确定从何处恢复:
如果
Current phase
phase-1
:阶段1是轻量级的——重新运行即可。
如果
Current phase
phase-2
  1. 告知用户:"恢复doctrack初始化 —— 已完成{M}个模块中的{N}个。继续处理{下一个待处理模块}..."
  2. 仅处理状态为
    pending
    的模块。
  3. 检查已完成模块的组件覆盖率——标记组件数量异常少的模块(例如50个文件但0个组件)以便重新记录。
  4. 所有模块完成后,进入阶段3。
如果
Current phase
phase-3
  1. 告知用户:"恢复doctrack初始化 —— 模块已完成,继续构建知识图谱({待处理分类列表})..."
  2. 读取Phase 3 Checklist。仅运行仍标记为
    pending
    的子阶段(例如,如果Concepts已
    done
    但Decisions为
    pending
    ,则从3b开始)。
  3. 阶段3完成后,进入阶段4。
如果
Current phase
phase-4
:告知用户"恢复初始化 —— 运行验证检查。" 重新运行验证。
如果
Current phase
complete
:初始化已完成。告知用户:"此项目已完成初始化。要从头开始重新初始化,请删除
.doctrack/
并运行
doctrack init
。"
这意味着大型项目可以跨多个会话完成初始化——每个会话都能取得进展、记录检查点,下一个会话可以从中断处继续。

Init for monorepos

单体仓库的初始化

Detection: Same indicators as Step 5 of Pre-init — JS workspaces, Maven
<modules>
, Gradle
include
, Cargo
[workspace]
,
.gitmodules
, multiple
go.mod
, or multi-project directory structures.
Workflow (same depth-first strategy, scoped to packages):
  1. Lightweight discovery — detect packages, list them, sort by dependency order
  2. Write root
    _project.md
    with Mermaid cross-package diagram and Init Progress table
  3. Deep-dive each package (Phase 2 within
    packages/{name}/
    ) — process 2-3 at a time, write-as-you-go
  4. After all packages: create monorepo-level concepts, decisions, interfaces
  5. Write root README and CLAUDE.md
  6. Cross-reference pass across packages
  7. Tag with
    doctrack/package/{name}

检测:与预初始化步骤5的指标相同——JS工作区、Maven
<modules>
、Gradle
include
、Cargo
[workspace]
.gitmodules
、多个
go.mod
,或多项目目录结构。
工作流(相同的深度优先策略,作用于包):
  1. 轻量级发现——检测包、列出包、按依赖顺序排序
  2. 编写根目录
    _project.md
    ,包含Mermaid跨包图和Init Progress表格
  3. 深度处理每个包(在
    packages/{name}/
    内执行阶段2)——同时处理2-3个包,边写边存
  4. 所有包处理完成后:创建单体仓库级别的概念、决策、接口
  5. 编写根目录README和CLAUDE.md
  6. 跨包交叉引用检查
  7. 添加标签
    doctrack/package/{name}

Working with teams

团队协作

All agents share the same vault via git. For concurrent access (multiple agents, worktrees):
  • Scope-based partitioning: Each agent only updates notes for features it modifies.
  • Append-only for project config: Use append mode for
    _project.md
    during concurrent work.
  • Advisory locking: Check
    editing_agent
    frontmatter before updating shared notes.
  • Post-task reconciliation: Consolidate appends, check for stale notes, clear locks, verify file registry.
For vault backup and git sync, use the obsidian skill's git sync capabilities.
所有代理通过git共享同一个vault。对于并发访问(多个代理、工作树):
  • 基于范围的分区:每个代理仅更新它修改的功能对应的笔记。
  • 项目配置的追加模式:并发工作时,对
    _project.md
    使用追加模式。
  • 建议性锁定:更新共享笔记前,检查
    editing_agent
    前置元数据。
  • 任务后协调:合并追加内容、检查过时笔记、清除锁定、验证文件注册表。
对于vault备份和git同步,使用obsidian技能的git同步功能。

Naming conventions

命名规范

  • Features: kebab-case (
    user-authentication.md
    )
  • Components: kebab-case (
    token-validator.md
    )
  • Concepts: descriptive kebab-case (
    health-data-model.md
    )
  • Decisions: verb-prefixed kebab-case (
    chose-firestore.md
    ,
    rejected-websockets.md
    )
  • Interfaces: kebab-case (
    health-data-schema.md
    )
  • 功能:短横线分隔(kebab-case),例如
    user-authentication.md
  • 组件:短横线分隔,例如
    token-validator.md
  • 概念:描述性短横线分隔,例如
    health-data-model.md
  • 决策:动词前缀短横线分隔,例如
    chose-firestore.md
    rejected-websockets.md
  • 接口:短横线分隔,例如
    health-data-schema.md