View your AI agent's shell commands from Linux audit logs
Tracks everything the AI runs so you can review, search, and audit its activity.
Works with any AI agent — OpenClaw, Claude Code, Codex, Cursor, Roo, and more.
- 📋 Command History — View, search, and filter all commands your AI has run
- 🔍 Pattern Search — Quick search through recent commands
- 👀 Live Watch — Monitor commands in real-time as they execute
- 🎯 Smart Filters — Hide noise like cloud metadata probes, shell conditionals, nvm paths
- ⚙️ Flexible Config — Environment variables, config file, or CLI flags
- 🧪 Tested — Unit tests and E2E Docker tests included
# 1. Copy config and customize
mkdir -p ~/.config/cmdlog
cp config.sample ~/.config/cmdlog/cmdlog.conf
cp filters.sample ~/.config/cmdlog/filters.conf
# 2. Edit ~/.config/cmdlog/cmdlog.conf and set your AUDIT_KEY
# 3. Add custom filter patterns to ~/.config/cmdlog/filters.conf (optional)
# 2. View recent commands
cmdlog
# 3. Search for specific commands
cmdlog --search git push
# 4. Watch live as commands execute
cmdlog --live| Command | Description | Example |
|---|---|---|
cmdlog |
Last 1000 commands | cmdlog |
cmdlog [N] |
Last N commands | cmdlog 50 |
cmdlog --all |
All today's commands | cmdlog --all |
cmdlog --recent [N] |
Last N (default 200) | cmdlog --recent 50 |
cmdlog --search <pattern> |
Search commands | cmdlog --search "git push" |
cmdlog --live |
Real-time watch | cmdlog --live |
cmdlog --raw [N] |
Raw audit entries | cmdlog --raw |
cmdlog --show-filters |
View active filters | cmdlog --show-filters |
cmdlog --config |
Show config paths | cmdlog --config |
auditd must be running with a rule tracking your agent's user.
ps aux | grep -E "(openclaw|claude|codex)" | grep -v grep# Replace 'clawdbot' with your agent's username
sudo auditctl -a always,exit -F arch=b64 -S execve -F uid=$(id -u clawdbot) -k clawdbot_execTo persist across reboots, add to /etc/audit/rules.d/cmdlog.rules:
# /etc/audit/rules.d/cmdlog.rules
-a always,exit -F arch=b64 -S execve -F uid=1000 -k clawdbot_exec# Clone anywhere
git clone https://github.com/ambushalgorithm/cmdlog.git
# Add to PATH
export PATH="$PATH:/path/to/cmdlog"
# Or symlink to /usr/local/bin
ln -s /path/to/cmdlog/cmdlog /usr/local/bin/cmdlog
# Optional: Source aliases for shorter commands
source /path/to/cmdlog/aliases.sh
# Adds: cmdlog-recent, cmdlog-today, cmdlog-search, cmdlog-live, cmdlog-rawFirst-run will prompt you to copy config.sample to ~/.config/cmdlog/cmdlog.conf.
Config file: ~/.config/cmdlog/cmdlog.conf
User filters: ~/.config/cmdlog/filters.conf
cmdlog uses two filter files:
- Built-in filters (
filters.confin script directory) - comes with cmdlog - User filters (
~/.config/cmdlog/filters.conf) - your custom patterns
Patterns are regex, one per line. Lines starting with # are ignored.
# ~/.config/cmdlog/cmdlog.conf
AUDIT_KEY="clawdbot_exec" # Must match your auditd -k flag
DEFAULT_LIMIT=1000 # Default number of commands to show
TZ="America/New_York" # Timezone for timestamps| Variable | Purpose | Default |
|---|---|---|
CMDLOG_AUDIT_KEY |
Override audit key | From config |
CMDLOG_CONFIG_FILE |
Override config path | ~/.config/cmdlog/cmdlog.conf |
CMDLOG_FILTERS_FILE |
Override filters path | ~/.config/cmdlog/filters.conf |
CMDLOG_DEFAULT_LIMIT |
Default limit | 1000 |
CMDLOG_TZ |
Timezone | System default |
CMDLOG_POLL_INTERVAL |
Live poll interval (sec) | 2 |
-k, --key <key> Override audit key
-c, --config <file> Override config file
-f, --filters <file> Override filters filePriority: CLI flags → env vars → config file → defaults
Hide commands you don't want to see:
# ~/.config/cmdlog/filters.conf
# Add your patterns (one per line)
# Hide internal scripts
my-internal-script
# Hide cloud metadata probes
wget.*169\.254\.169\.254
curl.*metadata\.google\.internal
# Hide shell conditionals
^if\s+
^then$
^fi$
^exit\s+[0-9]+
# Hide nvm/node paths
\.nvm/versions
\.node_versionsFilters are merged from:
filters.confin script directory (defaults)~/.config/cmdlog/filters.conf(your custom)
View active filters:
cmdlog --show-filters# Unit tests
bats tests/unit/
# E2E tests (Docker)
docker build -t cmdlog-e2e -f tests/e2e/Dockerfile .
docker run --rm cmdlog-e2e- Linux with
auditdinstalled and running sudoaccess to read audit logsauditctlto configure rules
- Fork the repo
- Create a feature branch
- Add tests for new functionality
- Run tests:
bats tests/unit/and Docker E2E tests - Submit a PR
MIT