MCPcopy Index your code
hub / github.com/atomicdotdev/atomic

github.com/atomicdotdev/atomic @v0.8.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.8.0 ↗ · + Follow
15,315 symbols 51,810 edges 594 files 4,268 documented · 28% updated todayv0.8.1 · 2026-07-07★ 6122 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Atomic

A mathematically sound distributed version control system — built for the age of AI.

Why Atomic?

Git was designed for humans writing code in text editors. It tracks lines in files. That worked for 20 years.

Now AI agents write most of the code. They work in sessions and turns, use multiple models, cost money per token, and produce changes that need to be audited, attributed, and explained. Git doesn't know about any of this — you're bolting on external tools to answer basic questions like "which model wrote this?" or "how much did this session cost?"

Atomic is version control that understands AI-assisted development from the ground up.

Atomic vs Git for Agentic Workflows

Git Atomic
Change model Line-based diffs Patch theory — composable operations on a DAG
AI attribution None — commits say "Co-authored-by" in prose Every change records model, provider, session, tokens, and cost
Provenance Not tracked Causal decision graph: goal → exploration → commitment → verification
Attestation Not tracked Session-level audit nodes with cost, token breakdown, and change coverage
Turn recording Manual commits or wrapper scripts Automatic — each agent turn is a change with full metadata
Agent isolation Branches diverge and need merging Views are filtered perspectives of the same graph — isolated agent work, zero-orphan cleanup
Conflict granularity Whole lines Token-level — two agents editing different tokens on the same line don't conflict
Identity Name + email string Ed25519 cryptographic identity with agent delegation scopes
Merge correctness Heuristic 3-way merge Mathematical — commutative when changes are independent, precise when they're not
Rename tracking Heuristic similarity matching Structural — inodes survive renames across the entire history

How It Works

Automatic Turn Recording

Enable agent hooks once. Every turn is recorded automatically.

# Enable for your agent (auto-detects Claude Code, Gemini CLI, OpenCode)
atomic agent enable

# That's it. Every agent turn now produces an Atomic change with:
#   - Model and provider identity
#   - Session and turn number
#   - Token usage and cost
#   - Cryptographic signature
#   - Provenance graph (why the agent made each decision)

Provenance Graphs

Every agent session builds a causal decision DAG. Not just what changed, but why:

Goal: "Fix the authentication bug"
  ├── Exploration: read src/auth.rs
  ├── Exploration: grep "verify_token"
  ├── Commitment: edit src/auth.rs (fix token validation)
  ├── Verification: bash "cargo test"
  └── PatchProposal: Change XMJZ3IPF (2 files)

These graphs are content-addressed, stored alongside changes, and pushed to remotes. Your team can review not just the code, but the agent's reasoning.

Attestations

When a session ends, Atomic creates an attestation — a graph-level audit node covering the session:

$ 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.12 · 3 changes covered · 20.5k tokens

Views, Not Branches

Agents work on isolated views of the same underlying graph. No branch divergence, no merge commits, no orphaned history.

# Agent session creates an isolated view automatically
# View: agent-ses_3781fc7a6ffet5c6r1ILy1BEbv (Draft, parent: dev)

# When done, insert changes into the parent view
atomic insert @~1 --to dev

# Delete the agent view — cascade-deletes its edges, zero orphans
atomic view delete agent-ses_3781fc7a6ffet5c6r1ILy1BEbv

Workspace Shelving

When you switch views, Atomic automatically isolates build artifacts per view — each view gets its own node_modules/, target/, etc. But tool configs like .opencode/, .vscode/, and .idea/ are project-wide and should persist across all views.

Atomic handles this with [workspace] expose:

# .atomic/config.toml
[workspace]
expose = [".opencode", ".vscode", ".idea", ".claude", ".gemini"]
  • .atomicignore = "don't track" (same as .gitignore). By default, all ignored files are shelved per-view on switch.
  • [workspace] expose = "persist across views". These paths are never shelved — they stay on disk through every view switch.
File .atomicignore expose On view switch
.opencode/, .vscode/ Left alone — persists across views
node_modules/, target/ Shelved per view (O(1) rename)
src/main.rs Tracked — materialized from the graph

atomic init seeds a default expose list with common tool configs. Build artifacts in .atomicignore are shelved automatically — no per-language configuration needed.

You can also set expose globally in ~/.atomic/config.toml so it applies to every repository on your machine:

# ~/.atomic/config.toml
[workspace]
expose = [".opencode", ".vscode", ".idea", ".claude", ".gemini"]

Global and repo-local patterns are merged — a repo can add project-specific entries without repeating the global ones.

Token-Level Diff

Atomic's CRDT semantic layer (Trunk → Branch → Leaf) tracks changes at the token level. Two agents editing different words on the same line produce independent patches that merge cleanly — Git would flag this as a conflict.

Vault — Shared Project Brain

Every repository has a vault — a versioned knowledge store that persists what your team and your agents learn across sessions. Goals, decisions, architecture context, and working memory all live in .vault/ as structured markdown with cryptographic provenance.

# Initialize the vault in your repo
atomic vault init

# Start a goal (a focused work session — human or agent)
atomic vault goal start --intent PIMO-3 --title "Fix token validation"

# Agents and humans accumulate tool results, decisions, and context
# When done, stop the goal — optionally promote it for team review
atomic vault goal stop --promote

# Add persistent project knowledge (conventions, architecture, etc.)
atomic vault memory add "Auth tokens use Ed25519 signatures, never HMAC"

# Track planned work items
atomic vault intent add --title "Migrate to async runtime" --priority high

The vault stores five kinds of content:

Entry Type What It Captures
Goals Work sessions — each tracks a developer/agent, linked intent, model, status, and tool results
Intents Planned work items with priority, status, assignee, and labels
Memory Persistent knowledge — architecture decisions, conventions, reference material
Skills Reusable capability definitions for agents
Scratch Temporary notes and working state

Everything is content-addressed and version-controlled. When an agent starts a session, it reads the vault for context. When it finishes, its learnings go back into the vault for the next session — human or machine.

Knowledge Graph — Code Intelligence at Scale

Atomic builds a knowledge graph from your entire codebase — source code content, file structure, tree-sitter entities (functions, classes, types), module hierarchy, change history, and their relationships. Search it, traverse it, visualize it, or let an LLM explore it with tools.

# Search the knowledge graph — unified structural + content search
atomic query search "replication"

# Search source code content (powered by syntext trigram index)
atomic query code "replication" -t cpp -g src/mongo/db/repl/

# List tree-sitter entities in a file (functions, classes, types)
atomic query entities src/mongo/db/repl/replication_coordinator_impl.cpp

# Explore relationships around a node (1-2 hops)
atomic query neighbors "module:src/mongo/db/repl"

# Visualize the graph — opens interactive D3 force-directed layout
atomic query graph "replication" -k 20 --depth 2

The KG contains seven node types connected by typed edges:

module:src/mongo/db/repl          ← directory-level grouping
  ├─ PART_OF ← file:replication_coordinator.h    ← tracked files
  │              ├─ DEFINES → entity:ReplicationCoordinator (class, L42-890)
  │              └─ INCLUDES → file:replication_process.h
  ├─ PART_OF ← file:bgsync.cpp
  │              └─ MODIFIES ← change:R4YQUAS2 ("fix replication lag")
  │                              ├─ AUTHORED_BY → identity:alice
  │                              └─ DEPENDS_ON → change:XMJZ3IPF
  └─ PART_OF → module:src/mongo/db  (parent module)

Search is powered by two indexes that work together: - KG FTS — searches node labels, summaries, and metadata (structural search) - syntext — trigram-indexed content search across all source files, ~20x faster than grep

Results are ranked: src/ files above tests, modules above flat files, content match counts as a signal. A bounded min-heap ensures the top N results surface from thousands of matches without sorting the full set.

For agents (Claude Code, Gemini, etc.), the CLI commands ARE the tools. An agent calls atomic query search, atomic query neighbors, atomic query entities, and its own read_file — the same path a human follows. No grep, no find, no LLM-calling-LLM overhead.

For humans on the terminal, ask provides an agentic loop with tool use:

# LLM explores the KG with tools and answers your question
atomic query ask "who fixed the auth bug?"

The ask command gives the LLM six tools (kg_search, kg_neighbors, read_file, list_entities, code_search, vault_read) and lets it decide what to look up. Provider-agnostic — works with Anthropic or OpenAI. Set ANTHROPIC_API_KEY or OPENAI_API_KEY to enable.

No API key required for search, code, entities, neighbors, graph, or enrich.

Quick Start

# Initialize a new repository
atomic init

# Add files and record a change
atomic add src/
atomic record -m "Initial commit"

# Enable AI agent hooks
atomic agent enable

# Create a view
atomic view create feature-x

# Push to a remote
atomic push origin

Key Concepts

Patch Theory

Changes are composable, commutative operations on a directed graph:

  • Merging A then B gives the same result as merging B then A (when no conflicts)
  • Every change has a well-defined inverse
  • Conflicts are represented as data, not failures

The Repository Graph

Files are directed acyclic graphs (DAGs) where vertices hold content chunks, edges define ordering, and changes are transformations that add or remove vertices and edges. This is not a commit graph — it's the actual file structure.

Dual-Layer Architecture

Every change stores two parallel representations:

  • Graph layer — Content-addressed nodes and edges for mathematically sound merging
  • Semantic layer — Files (Trunk), Lines (Branch), Tokens (Leaf) for human-readable diffs and token-level blame

CLI Reference

Core Commands

Command Description
atomic init Initialize a new repository
atomic add <paths> Add files to tracking
atomic remove <paths> Remove files from tracking
atomic move <src> <dst> Move or rename tracked files
atomic status Show working copy status
atomic diff Show differences in working copy
atomic record -m "msg" Record changes to the repository
atomic revise Modify a change in-place
atomic log Show change history
atomic change [hash] Show details for a specific change

Query Commands

Command Description
atomic query search <query> Search the knowledge graph (structural + content)
atomic query code <pattern> Search source code content (trigram-indexed, -t for file type, -g for path filter)
atomic query entities <path> List tree-sitter entities in a file (functions, classes, types with line ranges)
atomic query neighbors <id> Explore the graph around a node (DEFINES, MODIFIES, PART_OF, INCLUDES edges)
atomic query graph <query> Visualize the knowledge graph as interactive HTML (D3 force-directed, -k seeds, --depth, --kinds)
atomic query ask <question> Natural-language Q&A with agentic tool loop (requires API key)
atomic query enrich Build/rebuild KG from VCS data + content index (modules, entities, includes)
atomic query index Build/update the content search index (--rebuild for full, --stats for info)
atomic query reindex Rebuild the KG index from vault entries

View Commands

Command Description
atomic view create <name> Create a new view (--draft for isolated, --parent to set parent)
atomic view switch <name> Switch to a view
atomic view list List all views (--verbose for scope and parent)
atomic view delete <name> Delete a view
atomic split <name> Create a new view from the current one
atomic stash Temporarily save uncommitted changes

Remote Commands

Command Description
atomic push [remote] Push changes to a remote
atomic pull [remote] Pull changes from a remote
atomic clone <url> Clone a remote repository
atomic remote add <name> <url> Add a named remote
atomic remote remove <name> Remove a named remote
atomic remote set-url <name> <url> Change a remote's URL
atomic remote default <name> Set the default remote

Tag Commands

Command Description
atomic tag create <name> Create a named state snapshot
atomic tag list List all tags
atomic tag show <name> Show tag details
atomic tag delete <name> Delete a tag

Extension points exported contracts — how you extend this code

Command (Interface)
Trait that all CLI commands must implement. This trait provides a uniform interface for executing commands, enabling co [135 …
atomic-cli/src/commands/mod.rs
AgentHook (Interface)
Trait for agent hook adapters. Each AI coding agent (Claude Code, Gemini CLI, Codex, OpenCode) implements this trait to [13 …
atomic-agent/src/hooks/mod.rs
GraphTxnT (Interface)
Read-only graph operations This is the base trait that provides read access to the repository graph. All other transact [10 …
atomic-core/src/pristine/traits/graph.rs
LanguageParser (Interface)
Trait for language-specific AST entity extraction. Each language parser implements this trait, providing entity extract [7 …
atomic-semantic/src/parsers/mod.rs
ToolExecutor (Interface)
Synchronous tool executor. Implementations provide tool definitions and execute tool calls against concrete backends (re [2 …
atomic-repository/src/ai/tools.rs
ToolCall (Interface)
(no doc)
packages/opencode-atomic-hooks/src/index.ts
EnvLookup (Interface)
Environment lookup, injected so tests don't have to mutate the real process environment. [2 implementers]
atomic-cli/src/commands/update.rs
SessionState (Interface)
Trait for types that can have common actions applied to them. This is implemented by `AgentSession` to allow the state [2 …
atomic-agent/src/turn/phase.rs

Core symbols most depended-on inside this repo

unwrap
called by 5067
atomic-core/src/types/position.rs
clone
called by 1088
atomic-core/src/change/store.rs
push
called by 1014
atomic-core/src/diff/ops.rs
get
called by 952
packages/opencode-atomic-hooks/src/session.ts
write
called by 434
atomic-agent/src/hooks/manifest.rs
path
called by 396
atomic-repository/src/status.rs
iter
called by 315
atomic-core/src/diff/ops.rs
path
called by 292
atomic-core/src/output/mod.rs

Shape

Function 8,806
Method 5,378
Class 877
Enum 185
Interface 69

Languages

Rust99%
TypeScript1%

Modules by API surface

atomic-cli/src/commands/diff/tests.rs124 symbols
atomic-cli/src/commands/log/tests.rs107 symbols
atomic-cli/src/commands/git/parallel.rs107 symbols
atomic-agent/src/provenance/classify.rs104 symbols
atomic-core/src/crdt/apply/context.rs102 symbols
atomic-core/src/record/detect.rs100 symbols
atomic-core/src/crdt/apply/conflict.rs95 symbols
atomic-core/src/output/memory.rs94 symbols
atomic-repository/src/status.rs93 symbols
atomic-agent/src/record/tests.rs93 symbols
atomic-repository/src/archive.rs91 symbols
atomic-core/src/change/attestation.rs90 symbols

Datastores touched

appDatabase · 1 repos
atomic_storageDatabase · 1 repos
mydbDatabase · 1 repos

For agents

$ claude mcp add atomic \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact