agent-doc
Alpha Software — actively developed, APIs and frontmatter format may change between versions. Feedback welcome via GitHub issues.
Interactive document sessions with AI agents.
Edit a markdown document. Press a hotkey. The tool diffs your changes, sends them to an AI agent, and writes the response back into the document. The document is the UI.
Why
Terminal prompts are ephemeral. You type, the agent responds, the context scrolls away. Documents are persistent — you can reorganize, delete noise, annotate inline, and curate the conversation as a living artifact. The agent sees your edits as diffs, so every change carries intent.
Install
Quick Start
Document Format
agent_doc_session: 05304d74-90f1-46a1-8a79-55736341b193
agent: claude
Your question or instruction here.
(agent writes here)
Follow-up. You can also annotate inline:
Frontmatter fields
| Field | Required | Default | Description |
|---|---|---|---|
agent_doc_session |
no | (generated on first run) | Document UUID for tmux pane routing (legacy: session) |
agent_doc_format |
no | template |
Document format: append or template |
agent_doc_write |
no | crdt |
Write strategy: merge or crdt |
agent_doc_mode |
no | — | Deprecated. Use agent_doc_format + agent_doc_write instead |
resume |
no | (none) | Claude conversation ID for --resume |
agent |
no | claude |
Agent backend to use |
model |
no | (agent default) | Model override |
branch |
no | (none) | Git branch for session commits |
Two interaction modes
Append mode: Structured ## User / ## Assistant blocks.
Inline mode: Annotations anywhere — blockquotes, edits to previous
responses. The diff captures what changed; the agent addresses inline edits
alongside new ## User content.
Both work simultaneously because the run sends a diff, not a parsed structure.
Run Flow
┌──────────┐ hotkey ┌────────────┐ diff + prompt ┌───────┐
│ Editor │ ──────> │ agent-doc │ ──────────────> │ Agent │
│ │ │ │ <────────────── │ API │
│ reload │ <────── │ write+snap │ └───────┘
└──────────┘ │ git commit │
└────────────┘
- Read document, load snapshot (last-known state)
- Compute diff — if empty, exit (double-run guard)
- Send diff + full document to agent, resuming session
- Append response as
## Assistantblock - Save snapshot, git commit
Session continuity
- Empty
agent_doc_session:— forks from the most recent agent session in the directory (inherits context) agent_doc_session: <uuid>— resumes that specific session- Delete
agent_doc_session:value — next run starts fresh
History rewriting
Delete anything from the document. On next run, the diff shows deletions and the agent sees the cleaned-up doc as ground truth.
Components
Components are bounded, named regions in a document that can be updated independently:
Update a component:
|
Component config
Configure modes and hooks in .agent-doc/components.toml:
[]
= "append" # append | replace (default) | prepend
= true # auto-prefix with ISO timestamp
= 100 # trim old entries
[]
= "scripts/validate.sh" # transform content (stdin → stdout)
= "scripts/notify.sh" # fire-and-forget after write
Dashboard-as-document
A dashboard is a markdown document with agent-maintained components. External scripts update components via agent-doc patch, and the watch daemon can auto-trigger agent responses:
# Start watching for changes
# Update from CI scripts
See Components guide and Dashboard tutorial for full documentation.
Git Integration
Each run auto-commits the document for inline diff highlighting in your editor.
| Flag | Behavior |
|---|---|
-b |
Auto-create branch agent-doc/<filename> on first run |
| (none) | Commit to current branch |
--no-git |
Skip git entirely |
Cleanup: agent-doc clean <file> squashes all session commits into one.
Agent Backends
Agent-agnostic core. Only the "send prompt, get response" step varies.
# ~/.config/agent-doc/config.toml
[]
= "claude"
= ["-p", "--output-format", "json"]
= ".result"
= ".session_id"
[]
= "codex"
= ["--prompt"]
= ".output"
= ".id"
= "claude"
Override per-document via agent: in frontmatter, or per-invocation via --agent.
Tmux Session Routing
Route documents to persistent Claude sessions via tmux. Pane management is powered by tmux-router.
How it works:
- Each document gets an
agent_doc_sessionUUID in frontmatter (auto-generated if missing) - agent-doc maps UUIDs to file paths, then delegates to tmux-router for pane routing
routechecks if the pane is alive — if so, sends the command and focuses the pane- If the pane is dead or unregistered,
routelazy-claims to an active pane in theclaudetmux session, syncs the layout for all files in the same window, then sends the command - If no active pane is available, auto-starts a new Claude session in tmux
syncmirrors editor split layout in tmux using attach-first reconciliation
IPC-First Writes
Since v0.17.5, all write paths (run, stream, write) try IPC to the IDE plugin before falling back to direct disk writes. When an IDE plugin (JetBrains or VS Code) is active, agent-doc writes a JSON patch to .agent-doc/patches/ instead of modifying the file directly. The plugin applies the change via Document API, preserving cursor position, undo history, and avoiding "externally modified" dialogs. Falls back to atomic disk write if no plugin responds within 2 seconds.
Editor Integration
JetBrains
External Tool: Program=agent-doc, Args=run $FilePath$,
Working dir=$ProjectFileDir$, Output paths=$FilePath$. Assign keyboard shortcut.
VS Code
Task: "command": "agent-doc run ${file}". Bind to keybinding.
Vim/Neovim
nnoremap <leader>as :!agent-doc run %<CR>:e<CR>
CLI Reference
agent-doc run <file> [-b] [--agent <name>] [--model <model>] [--dry-run] [--no-git]
agent-doc init <file> [title] [--agent <name>]
agent-doc diff <file>
agent-doc reset <file>
agent-doc clean <file>
agent-doc route <file> # route to existing tmux pane or auto-start
agent-doc start <file> # start Claude session in current tmux pane
agent-doc claim <file> [--window W] [--pane P] # claim file for a tmux pane
agent-doc focus <file> [--pane P] # focus tmux pane for a session
agent-doc layout <files> --split h [--window W] # arrange panes (window-scoped)
agent-doc outline <file> [--json] # section structure + token counts
agent-doc resync # validate sessions, remove dead panes
agent-doc prompt <file> [--all] # detect permission prompts → JSON
agent-doc prompt --answer N <file> # answer prompt option N
agent-doc commit <file> # git add + commit with timestamp
agent-doc skill install # install Claude Code skill definition
agent-doc skill check # check if installed skill is up to date
agent-doc patch <file> <component> [content] # update component (stdin if no content)
agent-doc watch [--stop] [--status] # watch daemon (debounce + reactive mode for stream docs)
agent-doc audit-docs # audit instruction files for staleness
agent-doc upgrade # upgrade to latest version
agent-doc plugin install <editor> # install editor plugin (jetbrains|vscode)
agent-doc plugin update <editor> # update editor plugin to latest
agent-doc plugin list # list available editor plugins
Domain Ontology
agent-doc extends the existence kernel vocabulary (defined in ~/.claude/philosophy/src/) with domain-specific terms for interactive document sessions.
| Term | Derives From | Description |
|---|---|---|
| Session | project + story | A bounded interaction with temporal arc; the unit of agent-doc work |
| Document | entity + context | A markdown file that holds conversational state between user and agent |
| Pane | focus + scope | A tmux viewport — finite attention applied to a single document |
| Claim | scope + entity | Binding a document to a pane; scoping focus to a specific file |
| Route | context + resolution | Resolving which pane handles a document; context-aware dispatch |
| Sync | pattern + system | Aligning tmux pane layout to editor split state; maintaining coherence |
| Watch | consciousness + evolution | Detecting file changes and triggering agent responses; event-driven |
| Dashboard | system + focus | A document used as a live system view with agent-maintained sections |
| Component | scope + abstraction | Bounded, named, re-renderable region in a document (<!-- agent:name -->...<!-- /agent:name -->). Configurable mode (replace/append/prepend) and shell hooks. |
| Registry | system + perspective | Persistent mapping of documents to panes; the routing state |
| Snapshot | entity + story | Point-in-time capture of document content for diff computation |
| Project | system + scope | The bounded working context; identified by .agent-doc/ at its root. Contains documents, registry, snapshots, daemon. tmux-router is project-agnostic. |
| Overlay | context + resolution | Domain-specific terms extending the base kernel vocabulary |
License
MIT