# AgentLog
CLI flight recorder for AI coding agents. Capture every file change, command, and diff as a replayable timeline.
## Installation
```bash
cargo install agentlog
```
Or download pre-built binaries from [GitHub Releases](https://github.com/dbarabashh/agentlog/releases).
## Quick Start
```bash
# Initialize in your project
cd your-project
agentlog init
# Run an AI agent with capture
agentlog run claude
# Review what changed
agentlog timeline
agentlog replay <session-id>
```
## Commands
### `agentlog init`
Initialize AgentLog in the current directory. Creates `.agentlog/` directory with SQLite database and config.
### `agentlog run <agent>`
Run an AI agent with full session capture. File changes are monitored in real-time.
```bash
agentlog run claude
agentlog run cursor
agentlog run ./my-script.sh
```
### `agentlog search`
Search and filter sessions by date, agent, or files touched. Perfect for finding context when debugging issues.
```bash
# Find sessions from last 2 weeks
agentlog search --since "2 weeks ago"
# Find Claude sessions that touched auth files
agentlog search --agent claude --file "auth/"
# Find sessions from specific date range
agentlog search --since "2024-03-01" --until "2024-03-15"
# Find sessions affecting specific file
agentlog search --file "src/components/Login.tsx"
```
### `agentlog timeline`
Display all captured sessions with duration, files changed, and line statistics.
### `agentlog replay <session-id>`
Replay a specific session step-by-step. Shows each file change with timestamps and diffs.
```bash
agentlog replay abc123de
```
### `agentlog blame <path>`
Show which AI session last modified each line of a file.
```bash
agentlog blame src/main.rs
```
### `agentlog status`
Check AgentLog status and health for the current project.
### `agentlog export`
Export events to JSONL format for sharing or backup.
```bash
agentlog export --format jsonl --output events.jsonl
```
### `agentlog watch`
Start background file watcher without wrapping an agent. Useful for monitoring manual edits.
### `agentlog policy`
Manage security policies to block or warn on sensitive file modifications.
```bash
agentlog policy list # Show all rules
agentlog policy check .env # Test if file violates policy
agentlog policy add --name "api-keys" --pattern "**/api-keys.*" --action block
agentlog policy remove api-keys
agentlog policy toggle false # Disable enforcement
```
## Workflow Example
**Scenario:** QA reports a bug in the auth feature from 2 weeks ago.
```bash
# 1. Find sessions from last 2 weeks that touched auth files
agentlog search --since "2 weeks ago" --file "auth/"
# 2. Found session abc123de - view full details
agentlog replay abc123de
# 3. Export context for sharing with team
agentlog export --output auth_bug_context.jsonl
```
## Policy Enforcement
AgentLog includes built-in policies to protect sensitive files:
| `.env*` | Block |
| `auth/**/*` | Block |
| `*.key`, `*.pem` | Block |
| `*.tfstate*` | Block |
| `migrations/**/*` | Require confirmation |
## Storage
Events are stored locally in `.agentlog/events.db` as a SQLite database:
- **Fast queries:** Indexed for O(log n) lookups
- **Scalable:** Handles millions of events efficiently
- **Local only:** No cloud, no external dependencies
- **Exportable:** Export to JSONL anytime with `agentlog export`
- **Git-friendly:** Add `.agentlog/` to `.gitignore`
### Direct SQL Access
Advanced users can query the database directly:
```bash
sqlite3 .agentlog/events.db "SELECT * FROM events WHERE event_type = 'file_change' LIMIT 10"
```
## Requirements
- Rust 1.93+
- Linux, macOS, or Windows
## License
MIT