Interactive document sessions with AI agents
Project description
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
cargo install --path .
Quick Start
agent-doc init session.md "Topic Name" # scaffold a session doc
agent-doc run session.md # diff, send, append response
agent-doc diff session.md # preview what would be sent
agent-doc reset session.md # clear session + snapshot
agent-doc clean session.md # squash session git history
agent-doc route session.md # route to tmux pane (or auto-start)
agent-doc start session.md # start Claude in current tmux pane
agent-doc claim session.md [--window W] # claim file for a tmux pane
agent-doc focus session.md # focus tmux pane for a session
agent-doc layout a.md b.md --split h [--window W] # arrange panes (window-scoped)
agent-doc outline session.md # section structure + token counts
agent-doc outline session.md --json # JSON output for tooling
agent-doc patch dashboard.md status "new content" # update a component
agent-doc watch # auto-submit on file change
agent-doc resync # validate sessions, remove dead panes
agent-doc commit session.md # git add + commit with timestamp
agent-doc prompt session.md # detect permission prompts → JSON
agent-doc skill install # install Claude Code skill definition
agent-doc skill check # check if skill is up to date
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
Document Format
---
agent_doc_session: 05304d74-90f1-46a1-8a79-55736341b193
agent: claude
---
# Session: Topic Name
## User
Your question or instruction here.
## Assistant
(agent writes here)
## User
Follow-up. You can also annotate inline:
> What about edge cases?
Frontmatter fields
| Field | Required | Default | Description |
|---|---|---|---|
agent_doc_session |
no | (generated on first run) | Document UUID for tmux pane routing (legacy: session) |
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:
<!-- agent:status -->
| Service | State |
|---------|---------|
| api | healthy |
<!-- /agent:status -->
Update a component:
agent-doc patch dashboard.md status "| api | healthy |"
echo "deploy complete" | agent-doc patch dashboard.md log
Component config
Configure modes and hooks in .agent-doc/components.toml:
[log]
mode = "append" # append | replace (default) | prepend
timestamp = true # auto-prefix with ISO timestamp
max_entries = 100 # trim old entries
[status]
pre_patch = "scripts/validate.sh" # transform content (stdin → stdout)
post_patch = "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
agent-doc watch
# Update from CI scripts
agent-doc patch monitor.md builds "$(./format-builds.sh)"
agent-doc patch monitor.md log "Build #${BUILD_ID}: ${STATUS}"
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
[agents.claude]
command = "claude"
args = ["-p", "--output-format", "json"]
result_path = ".result"
session_path = ".session_id"
[agents.codex]
command = "codex"
args = ["--prompt"]
result_path = ".output"
session_path = ".id"
default_agent = "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.
agent-doc route plan.md # send to existing pane, or auto-start one
agent-doc sync --col a.md,b.md --col c.md --focus a.md # 2D layout sync
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; if dead, auto-starts a new onesyncmirrors editor split layout in tmux using attach-first reconciliation
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 + loop prevention)
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
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_doc-0.11.2.tar.gz.
File metadata
- Download URL: agent_doc-0.11.2.tar.gz
- Upload date:
- Size: 281.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbc59cb27faf0f3a1393d80c3e676ee57684186c6d12cfac63362fb3ab3d642e
|
|
| MD5 |
6a800a42222e8b7e0733de57b3c9e851
|
|
| BLAKE2b-256 |
c4845db46990eb889db1ea7d7e8ae058b12b17c4b93357b679b12d5ea77067db
|
File details
Details for the file agent_doc-0.11.2-py3-none-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: agent_doc-0.11.2-py3-none-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 2.7 MB
- Tags: Python 3, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4440dbcf770ec674e7fbd85a4cda9b2ca20f291ff4d0ef3b4062edb9fd24770
|
|
| MD5 |
e8f3ae8495a4eba3a9b2d1f37545f8c0
|
|
| BLAKE2b-256 |
8ca2465ccfff046a5fec533a28ebb6b54d799a1f291b03cfa5e5ed44f7020326
|