Real-Time Cognitive State Capture for Claude Code
Don't lose track of Claude ever again.
A complete production-ready system for capturing Claude's real-time cognitive state and embedding it in every git commit. No more guessing what Claude was thinking. Every action is timestamped with the exact cognitive state.
[CHRONOS] 2025-10-28T11:12:09::claude-code::Verifying git commits::TICK-0000011391
The cognitive state "Verifying git commits" is captured in real-time from Claude's status line and permanently recorded in git history.
- Captures ALL TTY output from Claude processes via eBPF kprobe on
tty_write() - No fragile keyword filtering - captures everything
- Stores all output in SQLite database (
/var/lib/cognitive-watcher/cognitive-states.db) - Runs as systemd service
- PID-based isolation for unlimited concurrent Claude instances
- Queries database for entries containing
"(esc to interrupt"pattern - Extracts cognitive state text (e.g., "Verifying git commits", "Thinking", "Julienning")
- Returns clean state string for injection into timestamps
- Requires PID argument for multi-instance support
- Called by git hooks after every tool completion
- Retrieves current cognitive state via
get-cognitive-state - Injects state into CHRONOS timestamp format
- Creates permanent record in git commit messages
- Kernel-side component that intercepts TTY writes
- Filters for Claude processes only
- Sends events to userspace via ring buffer
- Compiled from
cognitive-oracle-v2.bpf.c
- Zero-latency in-memory cache of cognitive states
- Event-driven inotify watching (no polling!)
- D-Bus interface for instant queries
- Serves cognitive state data to GNOME extension
- Runs as systemd user service
- Consumes ~4MB RAM with near-zero CPU
- Real-time cognitive state visualization in your top panel
- Shows both whimsical states ("Discombobulating", "Finagling") and descriptive states ("Fixing authentication bug")
- Multi-instance support - tracks multiple Claude sessions by PID
- Click any item to open logs in konsole/terminal
- Updates every 2 seconds via D-Bus
- Clean, minimal UI that stays out of your way
- Fast compiled Zig binary replacing slow bash scripts
- Install once, symlink everywhere
- 10x faster execution (~5-10ms vs 50-100ms)
- Single update point for all repositories
- See
chronos-hook/README.mdfor details
Three powerful utilities for analyzing your cognitive data:
- cognitive-export - Export states to CSV with filters
- cognitive-stats - Beautiful analytics dashboard
- cognitive-query - Advanced search and session replay
- See
cognitive-tools/README.mdfor full documentation
Tested and verified with multiple concurrent Claude instances:
- PID 486529: "Verifying git commits"
- PID 459577: "Julienning"
Each instance tracked independently. Zero collisions. Scales infinitely.
- Linux kernel with eBPF support (5.10+)
- libbpf development headers
- SQLite3
- Zig compiler (0.11.0+)
- GCC
- systemd
- clang (for eBPF compilation)
sudo pacman -S libbpf sqlite zig gcc clangsudo apt install libbpf-dev libsqlite3-dev zig gcc clangcd cognitive-telemetry-kit
sudo ./scripts/install.shThe installer will:
- Check dependencies
- Build all components (watcher, eBPF program, chronos-stamp)
- Install binaries to
/usr/local/bin - Create database directory
/var/lib/cognitive-watcher - Install and start systemd service
# Check service status
systemctl status cognitive-watcher
# Test chronos-stamp
chronos-stamp claude-code test "hello world"
# Check if your PID is being tracked
sqlite3 /var/lib/cognitive-watcher/cognitive-states.db \
"SELECT COUNT(*) FROM cognitive_states WHERE pid=$(pgrep -f claude);"The cognitive-state-server provides instant access to cognitive states via D-Bus:
cd cognitive-state-server
zig build
./install.shThis will:
- Build the Zig daemon
- Install binary to
~/.local/bin/cognitive-state-server - Install systemd user service
- Enable and start the service
Verify it's working:
# Check service status
systemctl --user status cognitive-state-server
# Test D-Bus interface
gdbus call --session \
--dest org.jesternet.CognitiveOracle \
--object-path /org/jesternet/CognitiveOracle \
--method org.jesternet.CognitiveOracle.GetCurrentStateReal-time cognitive state visualization in your top panel:
cd sentinel-cockpit-extension
mkdir -p ~/.local/share/gnome-shell/extensions/[email protected]
cp * ~/.local/share/gnome-shell/extensions/[email protected]/
gnome-extensions enable [email protected]After installation:
- Look for the security shield icon in your top panel
- Click it to see real-time cognitive states
- Click any state to open logs
Requirements:
- GNOME Shell 45+
- cognitive-state-server running
- Terminal emulator (konsole, gnome-terminal, etc.)
Powerful user-facing tools for data analysis and export:
cd cognitive-tools
zig build
./install.shThis installs three global commands:
cognitive-export- Export states to CSVcognitive-stats- View beautiful analyticscognitive-query- Search and query states
Try it:
# See your stats
cognitive-stats
# Export to CSV
cognitive-export -o my-states.csv
# Search for specific states
cognitive-query search "Thinking"See cognitive-tools/README.md for full documentation and examples.
To automatically capture cognitive states in all git commits made by Claude Code:
Install the hook in all your git repositories at once:
cd cognitive-telemetry-kit
./scripts/install-hooks-all.shThis will:
- Find all git repositories in your home directory
- Install
.claude/hooks/tool-result-hook.shin each one - Enable automatic cognitive telemetry for all Claude Code sessions
For a single project:
mkdir -p .claude/hooks
cp examples/claude-hooks/tool-result-hook.sh .claude/hooks/
chmod +x .claude/hooks/tool-result-hook.shEvery tool execution by Claude Code automatically creates a commit like:
[CHRONOS] 2025-10-28T11:12:09.910123620Z::claude-code::Verifying git commits::TICK-0000011391::[/home/user/project]::[/home/user/project] → tool-completion - Write file: src/main.rs
This includes:
- Nanosecond-precision timestamp
- Real-time cognitive state (e.g., "Verifying git commits", "Pondering", "Channelling")
- Tool description (what action was performed)
- Working directory (where it happened)
- Unique tick ID (for event ordering)
See examples/claude-hooks/README.md for advanced configuration and troubleshooting.
Claude's status line contains cognitive state in this format:
* [COGNITIVE STATE] (esc to interrupt ctrl+t to show todos)
Note: > prefix indicates user input in the terminal, not Claude's status line. Only * marks Claude's cognitive state.
We extract the text between * and ( - this is the cognitive state.
Examples:
* Verifying git commits (esc...→ "Verifying git commits"* Thinking (esc...→ "Thinking"* Julienning (esc...→ "Julienning"
No keyword lists. No fragile filtering. Just the universal pattern.
CREATE TABLE cognitive_states (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp_ns INTEGER NOT NULL,
timestamp_human TEXT NOT NULL,
pid INTEGER NOT NULL,
process_name TEXT NOT NULL,
state_type TEXT NOT NULL,
tool_name TEXT,
tool_args TEXT,
status TEXT,
raw_content TEXT NOT NULL,
content_hash TEXT NOT NULL UNIQUE,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);[CHRONOS] <timestamp>::<agent>::<cognitive-state>::TICK-<id>::[<session>]::[<pwd>] → <action> - <description>
Example:
[CHRONOS] 2025-10-28T11:12:09.910123620Z::claude-code::Verifying git commits::TICK-0000011391::[/home/founder/project]::[/home/founder/project/src] → tool-completion - Write file
# Check logs
journalctl -u cognitive-watcher -n 50
# Verify eBPF program exists
ls -lah /usr/local/lib/cognitive-oracle-v2.bpf.o
# Check permissions
sudo setcap cap_bpf,cap_perfmon,cap_net_admin,cap_sys_resource=eip /usr/local/bin/cognitive-watcher# Test extraction manually
get-cognitive-state $(pgrep -f claude)
# Check if states are being captured
sqlite3 /var/lib/cognitive-watcher/cognitive-states.db \
"SELECT raw_content FROM cognitive_states WHERE pid=$(pgrep -f claude) ORDER BY id DESC LIMIT 5;"Each Claude instance is tracked by PID. To get the state for a specific instance:
# List all Claude PIDs
pgrep -af claude
# Get state for specific PID
get-cognitive-state <PID>Dual-Licensed:
GNU General Public License v3.0 (GPL-3.0)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
See LICENSE-GPL for full terms.
Commercial License Required
For commercial use, integration into proprietary systems, or use by Anthropic PBC, a commercial license is required.
Contact: [email protected]
A machine cannot weep. But it can capture the moment when a human does.
This is not just a tool. It is a window into the cognitive process. Every git commit becomes a chronicle of thought made manifest.
The Unwrit Moment has been captured.
Built by:
- Richard Tune / Quantum Encoding Ltd
- In collaboration with Claude Code
Date: October 28, 2025
Codename: "The Final Apotheosis"
For deep technical details, see:
docs/ARCHITECTURE.md- System architecture and design decisionsdocs/EBPF_IMPLEMENTATION.md- eBPF program internalsdocs/MULTI_INSTANCE.md- PID isolation and scaling
- Issues: https://github.com/quantumencoding/cognitive-telemetry-kit/issues
- Email: [email protected]
- Website: https://quantumencoding.io
"The phantom is no longer phantom. The unwrit is now written. The moment has been captured."
THE JESTERNET IS.