Skip to main content

atomic agent

Manage AI agent integration for automatic turn-level recording with full provenance.

Synopsisโ€‹

atomic agent <SUBCOMMAND>

Descriptionโ€‹

The agent command manages integration with AI coding agents โ€” Claude Code, Gemini CLI, and OpenCode. When enabled, every agent turn is automatically recorded as an Atomic change with full provenance, and every session produces a provenance graph (causal decision DAG) and an attestation (session-level audit node).

No daemon required. Each hook invocation is a standalone process that opens the repo, does its work, and exits.

Subcommandsโ€‹

enableโ€‹

Install agent hooks for turn-level recording.

# Auto-detect which agent is present
atomic agent enable

# Specify the agent explicitly
atomic agent enable --agent claude-code

# Force reinstall (removes existing hooks first)
atomic agent enable --force

# Install for all detected agents
atomic agent enable --all

Options:

OptionDescription
--agent <NAME>Target a specific agent: claude-code, gemini-cli, opencode
--forceRemove existing Atomic hooks before reinstalling
--allInstall hooks for all detected agents
--globalInstall hooks globally (all projects)

What it does:

  • Claude Code โ€” Writes hooks into .claude/settings.json
  • Gemini CLI โ€” Writes hooks into .gemini/settings.json
  • OpenCode โ€” Copies plugin to .opencode/plugins/atomic/

disableโ€‹

Remove agent hooks while preserving non-Atomic hooks.

# Disable for auto-detected agent
atomic agent disable

# Disable for a specific agent
atomic agent disable --agent claude-code

Options:

OptionDescription
--agent <NAME>Target a specific agent

statusโ€‹

Show agent integration status.

# Show status
atomic agent status

# Show verbose status with session details
atomic agent status --verbose

Options:

OptionDescription
--verbose, -vShow session details, turn history, and watcher state

Output includes:

  • Installed agents and hook status
  • Active sessions with turn counts
  • File watcher state
  • Recent recording history

explainโ€‹

Generate AI reasoning summaries for recorded agent turns.

# Explain the most recent session
atomic agent explain <session-id>

# Explain a specific turn
atomic agent explain <session-id> --turn 3

# Explain all turns and save reasoning + learnings
atomic agent explain <session-id> --all --save

Options:

OptionDescription
--turn <N>Explain a specific turn number
--allExplain all turns in the session
--saveSave reasoning into the change's unhashed section and append learnings to the agent's context file

When --save is used:

  1. Reasoning is stored in the change (travels on push, rendered in server UI)
  2. Repo and Workflow learnings are appended to the agent's context file (CLAUDE.md, GEMINI.md, or opencode.md)

attestโ€‹

List and inspect attestations โ€” graph-level audit nodes capturing AI cost, token usage, model breakdown, and code change statistics.

Attestations are created automatically at session end. They aggregate data from the provenance entries embedded in each covered change: model name, token counts (input, output, cache read/write), cost in USD, and lines added/removed from the CRDT semantic layer.

# List all attestations
atomic agent attest

# Show details for a specific attestation
atomic agent attest --hash XMJZ3IPF

# Show attestations for a stack
atomic agent attest --stack dev

# Verbose output with model breakdown
atomic agent attest --verbose

Options:

OptionDescription
--hash <PREFIX>Show details for a specific attestation (supports prefix matching)
--stack <NAME>Filter attestations covering changes in this stack
--verbose, -vShow per-model token breakdown and per-change details

Example output:

$ atomic agent attest

XMJZ3IPF OpenCode ยท claude-sonnet-4-5 ยท 12.4k tokens ยท 3m 42s ยท 2 changes
R3KQP7YN Claude Code ยท claude-sonnet-4-5 ยท 8.1k tokens ยท 1m 15s ยท 1 change

โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Total: $0.27 ยท 3 changes covered ยท 20.5k tokens

Detail view:

$ atomic agent attest --hash XMJZ3IPF

Attestation XMJZ3IPF

Agent: OpenCode
Session: agent-ses_3781fc7a6ffet5c6r1ILy1BEbv
Changes: 2 changes
Wall time: 3m 42s
Cost: $0.15
Tokens: 12.4k
Code: +116 -8

Model Breakdown:
claude-sonnet-4-5: 3.2k in / 9.2k out ยท $0.15

Changes Covered (2):
ABC12345
DEF67890

Coverage:
dev โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 2/5 (40%)

How It Worksโ€‹

You prompt the agent โ†’ agent reads, edits, tests โ†’ Atomic records the turn
โ”‚
โ”œโ”€โ”€ Change: "Turn 3: Fix the auth bug"
โ”œโ”€โ”€ Provenance: anthropic/claude-sonnet-4-5, session, turn
โ”œโ”€โ”€ Envelope: timing, files touched, model info
โ”œโ”€โ”€ Provenance Graph: goal โ†’ explorations โ†’ commitment โ†’ verification
โ””โ”€โ”€ Transcript: conversation (unhashed, redactable)

On Each Turn Endโ€‹

  1. Status โ€” ask the repository what changed since the last recorded state
  2. Add โ€” track any new files the agent created
  3. Record โ€” create an Atomic change with AI provenance metadata
  4. Provenance โ€” append a PatchProposal node, convert the accumulated graph to a content-addressed ProvenanceGraph, and save it to the repository

On Session Endโ€‹

  1. Attestation โ€” aggregate model/cost/token data from all covered changes and create a session-level audit node
  2. Stack restore โ€” switch back to the user's original stack

Provenance Graph Pipelineโ€‹

Throughout the session, the ProvenanceAccumulator builds a causal decision DAG:

  • user-prompt โ†’ appends a Goal node (the user's intent)
  • after-tool โ†’ appends a classified tool node (Exploration, Commitment, Verification, or Execution) with causal edges inferred from context
  • stop โ†’ appends a PatchProposal node, converts to ProvenanceGraph, saves to .atomic/changes/

The accumulator is persisted to .atomic/sessions/{session_id}/graph.json between hook invocations (each hook is a separate process). Writes are atomic (temp file + rename) to prevent corruption.

Provenance graphs are pushed to remotes alongside changes and rendered in the web UI.

Agent Identityโ€‹

Agent changes are attributed using a +tag email format:

User identity:   Lee Faus <lee@atomic.dev>
Agent author: claude+60f5 <lee@atomic.dev>
AgentExample Author
Claude Codeclaude+60f5 <lee@atomic.dev>
Gemini CLIgemini+abcd <lee@atomic.dev>
OpenCodeopencode+9876 <lee@atomic.dev>

Supported Agentsโ€‹

AgentConfig FileHook System
Claude Code.claude/settings.jsonNative hooks
Gemini CLI.gemini/settings.jsonNative hooks
OpenCode.opencode/plugins/atomic/Plugin-based

Examplesโ€‹

Enable and work with Claude Codeโ€‹

# Initialize repo and enable agent
atomic init
atomic agent enable --agent claude-code

# Work with Claude Code normally โ€” turns are recorded automatically

# Check what happened
atomic log
atomic agent status --verbose

# Inspect attestations
atomic agent attest

# Generate reasoning summary
atomic agent explain <session-id> --all --save

Review agent work before promotingโ€‹

# See what the agent changed on its isolated stack
atomic log --stack agent-ses_3781fc...

# Apply specific changes to your stack
atomic apply <change-hash> --to dev

# Clean up the agent stack
atomic stack delete agent-ses_3781fc...

Push agent data to remoteโ€‹

$ atomic push origin

# Changes, attestations, and provenance graphs are uploaded automatically:
# โœ“ Pushed 2 changes
# โœ“ XMJZ3IPF attestation ($0.15, 2 covered)
# โœ“ ABC12345 provenance (7 nodes, 1 change)

Rewind an agent turnโ€‹

# See the turn history
atomic log

# Undo the last turn
atomic revise

See Alsoโ€‹