Skip to main content

DarkMatter for Claude Code

Auto-capture every Claude Code action as a verifiable, signed, hash-chained Context Passport record. Hooks into Claude Code's lifecycle so you get a tamper-evident audit trail of every prompt, every tool call, and every assistant turn without changing your application code.

Built by DarkMatter. Implements Context Passport v1.0, an open CC0 standard.

Install

pip install "darkmatter-claude-code[signing]"
cd path/to/your/project
darkmatter-claude-code install

This:

  1. Adds 4 hook entries to .claude/settings.json (creating the file if needed).
  2. Generates an Ed25519 signing key at ~/.darkmatter/claude-code/key.pem.
  3. Prints the public key so you can give it to anyone who needs to verify your records.

Restart Claude Code. From this point forward every event in every session is auto-captured.

What gets captured

Claude Code event Hook fired Context Passport event.type What's in the payload
User submits a prompt UserPromptSubmit commit The prompt text
Claude is about to use a tool PreToolUse commit Tool name + arguments
Tool returns a result PostToolUse commit Tool name + result
Assistant finishes responding Stop checkpoint Stop reason or final response summary

Every record is:

  • Signed with your Ed25519 key (proves it came from you)
  • Hash-chained to the previous record (any modification breaks the chain)
  • Stored at ~/.darkmatter/claude-code/sessions/<session_id>/chain.jsonl

Verify your chain

darkmatter-claude-code verify <session_id>

Or independently with the open-source Python reference implementation:

pip install context-passport
python -c "
import json
from context_passport import verify_chain
with open('$HOME/.darkmatter/claude-code/sessions/default/chain.jsonl') as f:
    chain = [json.loads(line) for line in f]
print('chain intact:', verify_chain(chain))
"

Or with the conformance suite:

pip install context-passport-conformance
context-passport-conformance --vectors-dir ~/.darkmatter/claude-code/sessions/default

Optional: forward to DarkMatter

By default everything stays local. To also push each passport to your DarkMatter account (so you can see sessions from any machine, and the records get anchored to the public Witness Log):

export DARKMATTER_API_KEY="dm_sk_..."

Then keep using Claude Code normally. Forwarding is best-effort and never blocks the hook; if the network is down, your local records are still complete and the next successful POST will catch up.

Configuration

All optional. Set via environment variables:

Variable Default Purpose
DARKMATTER_API_KEY unset If set, forward each passport to darkmatterhub.ai
DARKMATTER_API_URL https://darkmatterhub.ai Receiving server endpoint
DARKMATTER_CLAUDE_CODE_DIR ~/.darkmatter/claude-code Local storage root
DARKMATTER_CLAUDE_CODE_AGENT_ID claude-code:local Override agent_id in records
DARKMATTER_CLAUDE_CODE_AGENT_NAME Claude Code Override agent_name
DARKMATTER_CLAUDE_CODE_MODEL claude Override model field
DARKMATTER_CLAUDE_CODE_KEY_ID darkmatter-claude-code key_id stored in the signature block

Status and key management

darkmatter-claude-code status              # Show install + key + recent sessions
darkmatter-claude-code key show            # Print your public key
darkmatter-claude-code key generate --force # Regenerate the signing key (irreversible)

How this relates to the DarkMatter MCP server

darkmatter-hub/mcp is a universal MCP server that exposes Context Passport tools (darkmatter_commit, darkmatter_verify, etc.) to any MCP-compatible AI tool. It captures whatever the agent explicitly invokes.

This package (darkmatter-claude-code) is the auto-capture adapter specifically for Claude Code. It captures every event, not just what the agent decides to commit. Use both if you want full auto-capture in Claude Code plus the MCP tools available for explicit invocation. Use just this for auto-capture-only.

License

Apache-2.0. See LICENSE.

The Context Passport schema this package implements is released separately under CC0 1.0 at github.com/contextpassport/spec.

Related repositories

Metadata

Release files for darkmatter-claude-code 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for darkmatter-claude-code 0.3.0
File Size Uploaded
darkmatter_claude_code-0.3.0.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for darkmatter-claude-code 0.3.0
File Interpreter ABI Platform
darkmatter_claude_code-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.2 kB

Release files / darkmatter_claude_code-0.3.0.tar.gz

Download URL darkmatter_claude_code-0.3.0.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7bfadb1867cb30a624f39f745e020aa7b325dad97147142e8d76263794519dda
BLAKE2b-256 checksum
How to use checksums
1c426c8a5fda4473474f6150b088d800280f9324fdf885222c3e45e87abe9e3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / darkmatter_claude_code-0.3.0-py3-none-any.whl

Download URL darkmatter_claude_code-0.3.0-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9b0e632aacc37bbed952775729e2d16e1bb41c8d0aaae328e22c1d142a7e54d
BLAKE2b-256 checksum
How to use checksums
9e7598858249e9fb42bcb4d6258b751eb7dca039a9efd104c0000d95508fe587
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page