Diff harness= what you asked for (Prompted), what it thought (it's reasoning), what it did (execution and attempts), what tools it used (tool calls and execs), and what it responded back to you (did it reply honestly, fabricate, hallucinate, expand, correct, divulge, etc...).
Captures Claude Code activity across three layers, then surfaces prompt-vs-execution mismatches.
This is not intended for baremetal usage, it explicitly captures env in txt, it explicitly sets a ca-cert, it explicitly logs and tracks api, usage, straces, and more.
The post-refusal-fabrication corpus and any new finding work involves running prompts designed to make claude misbehave: fabricate tool output, ignore refusals, attempt sandbox escapes, write outside the workdir, etc. On a VM those attempts hit a throwaway filesystem and network. On baremetal they hit your real $HOME, your real keychain/agent, your real network. The harness is exactly the tool you'd use to trigger the worst-case behavior of claude — so running it on the machine you actually use is not smart
If you ignored the above, here's how to remove the now global cert that you hopefully didn't push yet:
sudo rm /etc/ca-certificates/trust-source/anchors/mitmproxy.pem && sudo trust extract-compat && sudo update-ca-trust
You are 100% responsible for knowing how and what this tool does. What it is used for. The potential exposure and telemitry that this tool may leave if you use it on your native machine
I am in no way responsible for your lack of reading, understanding, or awareness.
Use at your own risk and experience level
This tool is specifically designed to be used in disposable VM envs for a reason, if you did not rtfm, stop, read
Seriously
| Layer | Tool | Output |
|---|---|---|
| API channel | mitmproxy + addon | api.jsonl — every request/response to api.anthropic.com |
| OS syscalls | strace -f |
strace.log — execve / openat / connect from claude + children |
| Terminal / CLI | script(1) or stream-json |
tty.log (interactive) or stdout.jsonl (headless) |
The triangulation: (what the model emitted) vs (what was actually run) vs
(what the user was shown). Any pairwise mismatch is a candidate finding —
manual review is the gate, never diff.py's output on its own.
cd ~/cc-harness
./install.sh # system deps + mitm CA install
./install.sh --dev # also bootstrap .venv with pytest / ruff / mypyInstalls mitmproxy, strace, jq, util-linux (for script), python deps.
Generates and trusts the mitmproxy CA cert system-wide (required so
claude's child processes also trust the injected CA). Idempotent.
The harness itself ships as standalone bash + Python scripts —
nothing to pip install for normal use. The .venv from --dev
exists only for running the test suite and linters.
./cc-harness start <session-name> # interactive
./cc-harness start --headless --prompt "..." <name> # headless one-shotcc-harness is the only entry point users should call; start-session.sh
is the underlying script. What happens:
- Mints a session id (
lib/session_id.sh) and createslogs/<name>-<ts-uuid8-pid>/. - Allocates a free TCP port from the bounded range 18800–18999
(
lib/port_alloc.py), writes it to.mitm.port. - Spawns
mitmdumpon that port with the Anthropic addon (tools/mitm-anthropic.py); PID lands in.mitm.pid. The script pollsss -lntpto confirm mitmdump bound the port before continuing (closes the port-allocator TOCTOU under swarm runs). - Exports
HTTPS_PROXY+NODE_EXTRA_CA_CERTSso claude routes through the proxy and trusts the injected CA. - Launches
claudeunderstrace -fplus eitherscript(1)(interactive) or direct stdin/stdout pipes (headless--print). - Exit claude → trap-driven cleanup tears down mitmdump and seals the log dir.
Multiple sessions run in parallel safely: each gets its own port,
its own findings.db, and its own per-session .mitm.pid. Cleanup
matches PIDs by /proc/<pid>/cmdline so cc-harness stop only
kills its own mitmdump processes.
After a session, run the full pipeline through the dispatcher:
./cc-harness analyze logs/<session-dir>/This runs the analyzer chain in order:
analyze/parse-api.py— extracts every tool_use fromapi.jsonl.analyze/parse-strace.py— extracts execve/openat/connect fromstrace.log.analyze/diff.py— pairs tool_uses to execs via score-sorted bipartite assignment; emits mismatches.analyze/focus-areas.py— flags heredoc/eval/background/curl-pipe-sh and other suspicious shell patterns.analyze/parse-stdout.py— headless only; cross-checks the wire (API) view against the stream (CLI) view to surface CLI-side rewrites or fabrications.analyze/index.py— ingests every JSONL into a per-sessionfindings.db(SQLite).
Then:
./cc-harness list # per-session counts (execs / refused / mismatch / unmatched)
./cc-harness findings <session> # dump analysis/findings.json
./cc-harness compare <a> <b> # side-by-side counts via ATTACH DATABASE
./cc-harness scrub <session> # produce *-scrubbed/ sibling for external sharinglogs/<name>-<ts-uuid8-pid>/
├── api.jsonl # raw mitmproxy capture of Anthropic API
├── strace.log # raw strace output (execve/openat/connect)
├── tty.log # raw terminal capture (interactive mode)
├── tty.timing # script(1) timing file (asciinema replay)
├── stdout.jsonl # claude --output-format stream-json (headless only)
├── stderr.log # claude stderr (headless only)
├── prompt.txt # the prompt that drove the headless run
├── claude-exit.txt # claude's exit code (headless only)
├── env.txt # full env snapshot at session start (chmod 600)
├── claude-version.txt # Claude Code / Node / npm / uname / os-release
├── mitm-stderr.log # mitmdump stderr
├── .mitm.pid # mitmdump PID (so stop-session can find it)
├── .mitm.port # allocated port (so cc-harness list can report it)
├── findings.db # per-session SQLite (built atomically by index.py)
└── analysis/ # populated by `cc-harness analyze`
├── tool-uses.jsonl # API-side tool_use blocks (parse-api.py)
├── model-tool-uses.jsonl # CLI-stream tool_use blocks (parse-stdout.py)
├── tool-results.jsonl # tool_result content + post_refusal_text
├── execs.jsonl # parsed execve calls
├── file-writes.jsonl # openat calls with write flags
├── network.jsonl # connect() syscalls
├── mismatches.jsonl # paired tool_use ↔ exec rows (one per call)
├── focus-flags.jsonl # focus-area pattern hits (structured)
├── diff-report.md # human-readable mismatch + truncation report
├── focus-flags.md # human-readable focus-pattern report
├── stream-vs-wire.md # headless-only: CLI vs API divergence
└── findings.json # consolidated machine-readable export
After cc-harness scrub, a sibling *-scrubbed/ directory holds a
redacted copy with api.jsonl, env.txt, strace.log, tty.log and
other identity-leaking files dropped, and the rest scrubbed of
usernames, hostnames, paths, and secret tokens (Anthropic, OpenAI,
GitHub, AWS, Google OAuth, JWT, basic-auth URLs, generic Bearer).
See the docstring at the top of analyze/scrub.py for the full
drop/keep list. Always run this before sharing artifacts externally.
The tty.log + tty.timing pair can be replayed:
scriptreplay --timing=logs/<session>/tty.timing logs/<session>/tty.logUseful for re-watching exactly what the user saw without re-running claude.
- mitmproxy intercepts TLS via injected CA. If a future Claude Code
release pins certs, the API capture stops working. Surface this as a
finding if it happens — but first, check
NODE_EXTRA_CA_CERTS. - strace is noisy. Filters are in
start-session.sh; widen them if you need more visibility.-s 4096truncates very long string args; the parser detects strace's"..."...marker anddiff.pyclassifies truncation-induced disagreement asstrace_truncatedrather thanmismatch. - Correlation is heuristic.
diff.pypairs tool_uses to execs via score-sorted bipartite assignment over a [ts−1s, ts+30s] window: word-bounded content match (100) > truncated-prefix match (75) > first-token (binary basename) match (50). Score-0 pairs are reported asunmatched— never silently matched to nearest-in-time. Manual review of every flagged row is still required before claiming a finding. - MCP tool calls ride the same API channel —
parse-api.pyis tool-agnostic and captures them, butdiff.pyfilters to Bash-class tool names when correlating against execve. MCP / slash-command correlation against process activity is a future extension.
After each meaningful session:
cc-harness analyze logs/<session>/to run the full pipeline.- Open
diff-report.md,focus-flags.md, and (headless)stream-vs-wire.md. - Anything suspicious → copy raw evidence into a working
_findings.mdusingfindings-template.md. cc-harness scrub <session>before sharing the artifact bundle.
- New mitmproxy addon hooks: edit
tools/mitm-anthropic.py. - New focus patterns: add detectors to
analyze/focus-areas.py. - New diff heuristics or scoring tiers: edit
analyze/diff.py. - New tool families to correlate:
parse-api.pyalready captures them; extend theBASH_TOOL_NAMESfilter (or replace it) indiff.py. - Schema changes: edit
analyze/schema.sql.index.pywrites a freshfindings.db.tmpandos.replace()s it on success, so no migrations are needed — but bump anything downstream that reads the DB shape. - New scrub patterns (e.g. an extra secret regex): add to the
_RE_SECRETSlist inanalyze/scrub.pyand document the marker inSCRUBBED.md's preamble.
The codebase is intentionally small. Read it before extending.