> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lyzr.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Memory System

> Git-native agent memory: every write is a commit you can diff, revert, or audit.

Use standard git commands to diff what changed last session, revert a bad write, or audit the full history.

`memory/MEMORY.md` is the primary file. It's loaded automatically into every conversation.

## Directory Structure

```
memory/
├── MEMORY.md          # Primary memory (versioned)
├── mood.md            # Per-session mood log
├── photos/            # Camera captures
│   └── 2025-08-28-moment.jpg
├── journal/           # Session reflections
│   └── 2025-08-28.md
└── archive/           # Auto-archived old entries
    └── 2025-07-archive.md
```

## Memory Layers

```yaml theme={null}
# memory/memory.yaml
layers:
  - name: working
    path: memory/MEMORY.md
    max_lines: 1000
    format: markdown
  - name: technical
    path: memory/technical.md
    max_lines: 500
    format: markdown

archive_policy:
  max_entries: 500
  compress_after: 30d
```

When a layer exceeds `max_lines`, old entries are auto-archived to `memory/archive/<YYYY-MM>.md`.

## Other Memory Files

GitAgent also writes to a few other files automatically:

| Feature  | Path                       | Description                                                       |
| -------- | -------------------------- | ----------------------------------------------------------------- |
| Mood Log | `memory/mood.md`           | Session mood tracking (happy, frustrated, curious, excited, calm) |
| Photos   | `memory/photos/`           | Captured memorable moments with INDEX.md                          |
| Journal  | `memory/journal/<date>.md` | Auto-generated session reflections                                |
| Learning | `.gitagent/learning/`      | Task history and learned skills (JSON)                            |

## Memory Commands

```bash theme={null}
# View current memory in REPL
/memory

# Full git history of every memory write
git log --oneline memory/MEMORY.md

# Diff what changed last session
git diff HEAD~1 memory/MEMORY.md

# Undo a specific memory commit
git revert a3f2e91

# Read yesterday's mood log
git show HEAD:memory/mood.md

# Save something to memory via SDK
query({ prompt: "Remember that the API base URL is https://api.example.com", dir: "./my-agent" })
```

## Rolling Back Memory

```bash theme={null}
git revert HEAD                          # undo last memory write
git revert HEAD~3..HEAD                  # undo last 3 writes
git checkout a3f2e91 -- memory/MEMORY.md # restore to specific point
git commit -m "Restore memory to known good state"
```

<Note>
  Use `git revert` rather than `git reset --hard` — revert preserves the audit trail while reset destroys it.
</Note>

## Browsing the Archive

```bash theme={null}
ls memory/archive/
cat memory/archive/2025-07-archive.md
git log -p memory/ | grep "search term"
```

<CardGroup cols={2}>
  <Card title="Schedules & Cron" icon="clock" href="/open-source/gitagent/data-integrations/schedules">
    Automate agent runs on a cron schedule or as one-time tasks
  </Card>

  <Card title="Integrations" icon="plug" href="/open-source/gitagent/data-integrations/integrations">
    Connect GitAgent to Composio, Telegram, WhatsApp, and Twilio
  </Card>

  <Card title="Compliance & Audit" icon="git-branch" href="/open-source/gitagent/enterprise/compliance">
    Audit logging and human-in-the-loop approval for regulated workflows
  </Card>

  <Card title="GitAgent Overview" icon="sparkles" href="/open-source/gitagent/overview">
    Identity, memory, rules, and skills as plain files in a repo
  </Card>
</CardGroup>
