---
title: Documents
description: Document types, frontmatter, workspaces, commits, and history.
---

# Documents

A GitKB document has a stable identity, a slug, YAML frontmatter, and a Markdown body. The slug is its readable address, such as `tasks/auth-flow`. Renaming a slug preserves document identity and records a change in history.

## Types and frontmatter

Use types to distinguish intent: tasks describe work, specs describe behavior, incidents describe failures, and notes hold general knowledge. The built-in types are `task`, `spec`, `note`, `decision`, `skill`, `reference` and `incident`, and custom types work too. Context documents, which hold project state, are any documents under the `context/` slug folder by convention; view documents hold saved queries.

```yaml
---
slug: tasks/auth-flow
title: Implement authentication
type: task
status: active
priority: high
tags: [auth, api]
parent: tasks/auth-epic
blocked_by: [tasks/session-store]
implements: [specs/auth]
---

## Acceptance criteria

- [ ] Sign-in creates a session.
- [ ] Expired sessions are rejected.
```

`git-kb create` supplies identity and version metadata. Give it a type and title, and either choose a slug or let GitKB derive one. Status is a string, so your project can choose values such as `draft`, `backlog`, `active`, `blocked`, and `completed`; these are conventions rather than an enforced transition sequence.

Common fields include `priority`, `tags`, `assignee`, `agent_id`, `worktree`, `parent`, `blocked_by`, `depends_on`, `implements`, `references`, and `external_refs`. `assignee` identifies the assigned person or agent; `agent_id` is a separate agent/session binding. Graph-derived fields such as `blocks` should be understood through the [knowledge graph](/docs/core-concepts/knowledge-graph/).

## The editing lifecycle

```mermaid
flowchart TD
    Create["create: pending document"] --> Edit["Edit workspace Markdown"]
    Checkout["checkout: editable copy"] --> Edit
    Edit --> Review["status and diff"]
    Review --> Commit["commit: record history"]
    Commit --> Push["push: publish selected work"]
    Pull["pull: acquire documents"] --> Checkout
    Commit --> Checkout
```

Create a document in the current workspace:

```bash
git-kb create task --slug tasks/auth-flow --title "Implement authentication" --json
git-kb workspace path tasks/auth-flow --json
```

Edit the returned file, then commit it:

```bash
git-kb status --json
git-kb diff
git-kb commit -m "Define authentication work" tasks/auth-flow
```

For an existing document, start with `git-kb checkout tasks/auth-flow`. Workspace paths are `.kb/workspaces/<name>/...`; use `git-kb workspace path` rather than assuming the name, especially in linked Git worktrees.

Metadata updates use the same workflow:

```bash
git-kb set tasks/auth-flow status=completed priority=high
git-kb diff
git-kb commit -m "Complete authentication work" tasks/auth-flow
```

`set` leaves a pending workspace edit. With several agents or several changed documents, always pass the slugs you changed to `commit`.

## Canonical storage and history

Committed documents, commits, document tips and stashes live in GitKB's local store under `.kb/`. Workspace files are pending edits. Query indexes are derived from the store and can be rebuilt.

Each document change records its version and previous document commit. SHA-256 hashes connect the new document bytes to the prior version's hash. Commit IDs are SHA-256 content hashes. The ancestry belongs to each document, so a commit touching several documents can link to a different predecessor for each one.

Inspect a document and its history with:

```bash
git-kb show tasks/auth-flow --json
git-kb log tasks/auth-flow --json
```

## Querying

```bash
git-kb list --type task --status active --tags auth --json
git-kb list --assigned-to agent-1 --json
git-kb list --unassigned --unblocked --json
git-kb search "authentication session" --json
git-kb search "authentication session" --all-terms --json
```

Keyword search ranks matches in titles, content, and tags. `--all-terms` requires every query term. Use JSON in scripts to retain complete slugs, IDs, and stable fields.

With semantic search initialized and indexed, semantic search can find related documents by meaning:

```bash
git-kb semantic search "session expiration" --json
```

Embeddings are generated and searched locally; they are not synced. See [configuration](/docs/reference/configuration/) for model settings.

## Assignment

```bash
git-kb assign tasks/auth-flow agent-1 --json
git-kb commit -m "Assign authentication work" tasks/auth-flow
```

Assignment updates `assignee` and rejects a conflicting owner unless `--force` is supplied. It is local to the KB's current state; sync carries committed changes to other peers. Use `git-kb unassign tasks/auth-flow` to clear the binding, then commit that edit.

## Saved views

A `view` document stores a query. Save board flags, then run the view against current data:

```bash
git-kb board --group-by priority --type task --save views/task-priorities
git-kb view views/task-priorities --json
```

## Next steps

- [Knowledge Graph](/docs/core-concepts/knowledge-graph/) — Relationships, containment, and code references
- [Team Collaboration](/docs/guides/team-collaboration/) — Sparse sync and remote recovery
- [Code Intelligence](/docs/core-concepts/code-intelligence/) — Connect documents to source code
