Knowledge Graph

GitKB extracts relationships from Markdown and frontmatter into a queryable graph. Committing a document updates its canonical content and derived relationships. The daemon can also preview relationships from valid workspace edits before commit.

Relationships

RelationshipHow to write itDirection
references[[specs/auth]] in the body, or references: [specs/auth]This document → target
parent_ofparent: tasks/auth-epicParent → this document
implementsimplements: [specs/auth]This document → spec
blocksblocked_by: [tasks/session-store]Blocker → this document
depends_ondepends_on: [tasks/session-store]This document → dependency
references_code[[code:src/auth.rs::login]]Document → code reference
references_commit[[commit:core@abc1234]]Document → source Git commit reference

blocks is derived from the graph. Write blocked_by on the blocked document to create a blocking edge. A sentence saying that a task “resolves” an incident creates a references edge when it contains a wikilink; the wording does not create a separate resolves relationship.

For example:

markdown
This task implements [[specs/auth]].
See [[code:src/auth.rs::login]] for the entrypoint.
The source change is recorded in [[commit:core@abc1234]].

The repository name in a commit reference corresponds to the configured repository registry. Code references support file and symbol targets; use complete IDs from code-intelligence JSON when resolving an ambiguous symbol.

Querying

shell
# Both directions, two levels deep
git-kb graph tasks/auth-flow --direction both --depth 2 --json

# Who points to this document?
git-kb graph specs/auth --direction in --json

# What does this document point to?
git-kb graph tasks/auth-flow --direction out --json

# Restrict edge types or combine roots
git-kb graph tasks/auth-flow --rel-type depends_on --json
git-kb graph tasks/auth-flow specs/auth --json

Supported graph formats are tree, json, dot, mermaid-gantt, and plan. Use JSON for scripts and agents. --critical-path identifies the longest dependency chain; --format plan returns a dependency-ordered execution plan.

Containers and ordering

Container membership is separate from semantic relationships. Use link, unlink, and reorder for ordered collections of documents:

shell
git-kb link tasks/auth-flow --to specs/auth

Review pending changes and commit the affected document. See CLI Reference for code links, commit links, and ordering options.

Previewing changes

shell
git-kb status --json
git-kb diff

status reports pending workspace state and graph changes; diff shows the content and metadata edits behind them. Invalid workspace documents can produce validation events instead of a graph projection. Correct the frontmatter or Markdown and review again before committing.

External references and apps

The external_refs frontmatter field records references to external systems. Enabled local apps can add descriptors that derive external references from document data. These are query projections; app installation and configuration are local to the machine.

shell
git-kb app list --json
git-kb external-refs --help

Next steps