# marsrael/git-memory architecture

> Architecture diagram of the GitHub repository marsrael/git-memory, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marsrael/git-memory
- Repository: https://github.com/marsrael/git-memory

## Overview

Git-Native Agent Memory provides a CLI-first way for coding agents to persist and retrieve structured memory in Git refs. The main workflow is an agent invoking the CLI, which validates and delegates note or global-state operations to the shared core; reads use the same core parser and can be inspected in the optional TUI. The core also supports event replay, compaction, and integrity verification. The README documents ref synchronization between clones. Source excerpts are partial, so the graph omits unshown internal call details and focuses on documented or directly evidenced relationships.

Main entry points: [`scripts/memory.py`](https://github.com/marsrael/git-memory/blob/master/scripts/memory.py) (Memory CLI), [`scripts/memory_tui.py`](https://github.com/marsrael/git-memory/blob/master/scripts/memory_tui.py) (Memory dashboard), [`scripts/memory_lib.py`](https://github.com/marsrael/git-memory/blob/master/scripts/memory_lib.py) (Episodic notes), [`skills/git-memory/SKILL.md`](https://github.com/marsrael/git-memory/blob/master/skills/git-memory/SKILL.md) (Usage rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Agent interface"]
  node_skill["Usage rules<br/>[SKILL.md]"]
  node_cli_app["Memory CLI<br/>[memory.py]"]
end

subgraph group_core["Memory core"]
  node_episodic["Episodic notes<br/>[memory_lib.py]"]
  node_global_events["Global event log<br/>[memory_lib.py]"]
  node_read_parse["Read and filter<br/>[memory_lib.py]"]
  node_verify["Integrity checks<br/>[memory_lib.py]"]
  node_compact["Log compaction<br/>[memory_lib.py]"]
  node_git_refs[("Git refs")]
end

subgraph group_browse["Inspection"]
  node_tui["Memory dashboard<br/>[memory_tui.py]"]
end

node_agent(("Coding agent"))
node_remote["Git remote"]

node_agent -->|"reads rules"| node_skill
node_agent -->|"uses commands"| node_cli_app
node_cli_app -->|"writes notes"| node_episodic
node_cli_app -->|"appends events"| node_global_events
node_cli_app -->|"reads memory"| node_read_parse
node_cli_app -->|"runs checks"| node_verify
node_cli_app -->|"compacts log"| node_compact
node_cli_app -->|"dispatches to"| node_tui
node_episodic -->|"stores notes"| node_git_refs
node_global_events -->|"stores events"| node_git_refs
node_read_parse -->|"reads refs"| node_git_refs
node_tui -->|"loads notes"| node_read_parse
node_tui -->|"loads state"| node_global_events
node_tui -->|"edits notes"| node_episodic
node_tui -->|"refreshes data"| node_git_refs
node_agent -->|"syncs refs"| node_remote
node_remote -->|"transfers refs"| node_git_refs

click node_skill "https://github.com/marsrael/git-memory/blob/master/skills/git-memory/SKILL.md"
click node_cli_app "https://github.com/marsrael/git-memory/blob/master/scripts/memory.py"
click node_episodic "https://github.com/marsrael/git-memory/blob/master/scripts/memory_lib.py"
click node_global_events "https://github.com/marsrael/git-memory/blob/master/scripts/memory_lib.py"
click node_read_parse "https://github.com/marsrael/git-memory/blob/master/scripts/memory_lib.py"
click node_verify "https://github.com/marsrael/git-memory/blob/master/scripts/memory_lib.py"
click node_compact "https://github.com/marsrael/git-memory/blob/master/scripts/memory_lib.py"
click node_tui "https://github.com/marsrael/git-memory/blob/master/scripts/memory_tui.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_skill,node_cli_app toneBlue
class node_episodic,node_global_events,node_read_parse,node_verify,node_compact,node_git_refs toneAmber
class node_tui toneMint
class node_agent,node_remote toneIndigo
```

## Components

### Agent interface

- [Usage rules](https://github.com/marsrael/git-memory/blob/master/skills/git-memory/SKILL.md): `skills/git-memory/SKILL.md`
- [Memory CLI](https://github.com/marsrael/git-memory/blob/master/scripts/memory.py): `scripts/memory.py`

### Memory core

- [Episodic notes](https://github.com/marsrael/git-memory/blob/master/scripts/memory_lib.py): `scripts/memory_lib.py`
- [Global event log](https://github.com/marsrael/git-memory/blob/master/scripts/memory_lib.py): `scripts/memory_lib.py`
- [Read and filter](https://github.com/marsrael/git-memory/blob/master/scripts/memory_lib.py): `scripts/memory_lib.py`
- [Integrity checks](https://github.com/marsrael/git-memory/blob/master/scripts/memory_lib.py): `scripts/memory_lib.py`
- [Log compaction](https://github.com/marsrael/git-memory/blob/master/scripts/memory_lib.py): `scripts/memory_lib.py`
- **Git refs**

### Inspection

- [Memory dashboard](https://github.com/marsrael/git-memory/blob/master/scripts/memory_tui.py): `scripts/memory_tui.py`

### Other components

- **Coding agent**
- **Git remote**

## Connections

- Coding agent → Usage rules: reads rules (evidence: `README.md`)
- Coding agent → Memory CLI: uses commands (evidence: `README.md`)
- Memory CLI → Episodic notes: writes notes (evidence: `scripts/memory.py`)
- Memory CLI → Global event log: appends events (evidence: `README.md`)
- Memory CLI → Read and filter: reads memory (evidence: `scripts/memory.py`)
- Memory CLI → Integrity checks: runs checks (evidence: `scripts/memory.py`)
- Memory CLI → Log compaction: compacts log (evidence: `README.md`)
- Memory CLI → Memory dashboard: dispatches to (evidence: `scripts/memory.py`)
- Episodic notes → Git refs: stores notes (evidence: `README.md`)
- Global event log → Git refs: stores events (evidence: `README.md`)
- Read and filter → Git refs: reads refs (evidence: `README.md`)
- Memory dashboard → Read and filter: loads notes (evidence: `scripts/memory_tui.py`)
- Memory dashboard → Global event log: loads state (evidence: `scripts/memory_tui.py`)
- Memory dashboard → Episodic notes: edits notes (evidence: `scripts/memory_tui.py`)
- Memory dashboard → Git refs: refreshes data (evidence: `scripts/memory_tui.py`)
- Coding agent → Git remote: syncs refs (evidence: `README.md`)
- Git remote → Git refs: transfers refs (evidence: `README.md`)
