hooklens
See what your coding agent actually did.
Every tool call, shell command, file change, MCP call, and token, from Claude Code, Codex, and Cursor. As a trace of every turn, on your machine.
Why hooklens
Coding agents run commands, edit files, and call tools faster than you can read the transcript. hooklens records what happened through the agents' own hooks, so you can answer questions like:
- Which files did the agent change, and which did it only read?
- What shell commands ran, and which ones failed?
- Which MCP servers and tools did it use?
- Where did the time go, and how many tokens did the session cost?
It is a single Python package with no dependencies. Data stays in a local SQLite file, and the UI is a local web page. Nothing leaves your machine.
Features
- Trace of each turn: the prompt, then every tool call on a time axis, with duration and status. Idle gaps are compressed, and active time is counted apart from idle time.
- Details of each call: the input, the error, a response excerpt, and the files it touched.
- Tools and files: time by activity, calls and p95 duration for each tool, every file changed or read, and the commands that ran.
- Event log with search, a category filter, and an errors-only filter.
- Tokens and model from the agent's transcript.
- Live view that updates while the agent works.
- One view for three agents. Claude Code, Codex, and Cursor events are normalized to one schema.
- Policy webhook (optional). Your policy engine can allow, deny, or ask before a tool call or a prompt, with 1 request format for all 3 agents. Every decision is stored and shown in the trace.
Supported agents
| Agent | Tool calls | Prompts and turns | Tokens | Hooks file |
|---|---|---|---|---|
| Claude Code | ✅ | ✅ | ✅ | ~/.claude/settings.json |
| Codex | ✅ | ✅ | ✅ | ~/.codex/hooks.json |
| Cursor | ✅ | ✅ | — | ~/.cursor/hooks.json |
Quick start
uv tool install hooklens # or: pipx install hooklens
hooklens install # add hooks to every agent it finds
Start a new agent session (hooks load when a session starts), use the agent, then run:
hooklens show # opens http://127.0.0.1:7878
To install one agent at a time, use hooklens claude install, hooklens codex install, or
hooklens cursor install.
Usage
| Command | What it does |
|---|---|
hooklens show [session] |
Open the UI for all sessions, or one session |
hooklens <agent> show |
Open the UI for one agent (claude, codex, cursor) |
hooklens sessions |
List recent sessions in the terminal |
hooklens doctor |
Check the hooks, the database, and recent events |
hooklens clear |
Delete all recorded data (the hooks stay) |
hooklens uninstall |
Remove the hooks (your other hooks and settings stay) |
hooklens uninstall --purge |
Remove the hooks, the data, the config backups, and the policy |
hooklens policy set <url> |
Ask a policy webhook before tool calls and prompts (details) |
hooklens policy test |
Send a test tool call to the webhook and show the decision |
Commands that delete data ask first. Add --dry-run to see what would be removed, or --yes to
skip the question.
More screenshots
Tools and files: where the time went, each tool's calls and durations, and the files that changed.
How it works
agent ──hook event (JSON)──> hooklens hook ──> SQLite (raw events)
│
hooklens show ──> normalize ──> sessions, events, files ──> local UI
- Capture. The agent runs
hooklens <agent> hookon each event. The hook stores the raw event and exits in about 30 ms. Without a policy webhook, it never blocks or changes what the agent does. - Normalize. When you open the UI, hooklens maps each agent's events to one schema, pairs tool starts with their results, and reads token usage from the agent's transcript.
- View. A small server on
127.0.0.1serves the UI and a JSON API.
Without a policy, hooklens never changes what the agent does. Read design/architecture.md for the details and design/sequence.md for the full call flow.
Policy webhook
A policy engine can allow, deny, or ask before an agent runs a tool or sends a prompt. hooklens sends 1 JSON request with the same fields for every agent, and gives each agent the decision in the form that it expects.
python examples/policy_server.py # a small example engine on 127.0.0.1:8787
hooklens policy set http://127.0.0.1:8787/check # --fail-closed, --timeout, --header 'Authorization: Bearer ${TOKEN}'
hooklens policy test --command "rm -rf ~" # Decision: deny (5 ms)
The engine answers {"decision": "allow" | "deny" | "ask", "reason": "..."}. allow means "no
objection", so the agent's own permission rules still apply. Denied calls show as "Blocked" in the
trace. Read design/policy.md for the request format and for how each agent
handles each decision.
Privacy and safety
- All data is in
~/.hooklens/hooklens.db. Nothing is sent over the network, unless you set a policy webhook: then each checked tool call or prompt goes to that URL. - Each string is trimmed to 4096 characters before it is stored, so full file contents and long
outputs are not kept. Set
HOOKLENS_MAX_FIELDto change the limit (0keeps everything). - Cursor sends your account email with each event. hooklens removes it before storage.
- hooklens backs up an agent config file before it changes it, and only ever edits its own entries.
hooklens uninstall --purgeremoves everything hooklens created, and nothing else.
Configuration
| Variable | Default | Purpose |
|---|---|---|
HOOKLENS_HOME |
~/.hooklens |
Where the database and error log live |
HOOKLENS_MAX_FIELD |
4096 |
Max characters stored per string (0 = no limit) |
HOOKLENS_CLAUDE_SETTINGS |
~/.claude/settings.json |
Claude Code settings file |
CODEX_HOME |
~/.codex |
Codex config folder |
HOOKLENS_CURSOR_HOME |
~/.cursor |
Cursor config folder |
Roadmap
See the milestones: the first PyPI release, importing past sessions, cost estimates, OpenTelemetry and SIEM export, and a local daemon for faster policy checks.
Contributing
Contributions are welcome. Read CONTRIBUTING.md to get started.
make setup # create .venv with the dev dependencies (needs uv)
make check # lint, format check, and tests: the same checks as CI
Releasing (maintainers)
- Set
__version__insrc/hooklens/__init__.py(the only place with the version), and merge tomain. - Publish a GitHub release with a SemVer tag:
v1.2.3, orv1.2.3-alpha.1,-beta.1,-rc.1. - Approve the
pypideployment. The release workflow checks the tag, runs the tests, builds the package, and publishes it to PyPI.
License
Apache License 2.0. Copyright 2026 Kunal.
Metadata
Release files for hooklens 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hooklens-0.1.4.tar.gz | 337.3 kB | With provenance | Details for hooklens-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hooklens-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for hooklens-0.1.4-py3-none-any.whl |
Total release size: 392.8 kB
Release files / hooklens-0.1.4.tar.gz
| Download URL | hooklens-0.1.4.tar.gz |
|---|---|
| Size | 337.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4df52150b6b758da681786ec783bdda8777ecd99330fd8e403346f604a5ad25b
|
|
BLAKE2b-256 checksum How to use checksums |
5e52d1eb1fe05735978e80b345904e4153df24a2d748d831aff5f53a702f2189
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logRelease files / hooklens-0.1.4-py3-none-any.whl
| Download URL | hooklens-0.1.4-py3-none-any.whl |
|---|---|
| Size | 55.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd62c11a51f669e103f7e7206f00866036f61de8971c06529471a3376c0c7df3
|
|
BLAKE2b-256 checksum How to use checksums |
2a512327778328c92cba06ae0b278adce989aa3b208cfb1b3488d7f2c9b6b43d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logSecurity for hooklens 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for hooklens-0.1.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.