AgentDetox
Protect your agent's memory: block known-risk writes, detect suspicious changes, and clean up unwanted instructions.
Protection for the memory, instructions, skills and config your coding agent trusts across sessions.
Quick start · How it works · Evidence · Documentation · Interactive demo
English (primary) · 简体中文
A poisoned page can become tomorrow's memory. An install script can change CLAUDE.md while
your agent is busy elsewhere. AgentDetox checks writes to persistent context, records changes
with source evidence, and lets you remove selected added lines or restore an earlier version,
with a backup either way. A cleanup changes the file, not what a running session has already read:
start a new session in that client afterwards.
0.6.0 is published on PyPI and GitHub. The project is in preview: Claude Code is supported; Codex and Cursor hooks are experimental; OpenClaw has no hook of its own, so nothing is checked as it writes; its files are checked from the command line and at the session start of the other clients. Development supports native Windows with Python 3.12 and Git Bash, alongside macOS/Linux. Windows offline validation covers the installed-wheel lifecycle; real-client and sustained daily-use validation remain separate. See Windows evidence. Native Windows latency measurements still exceed several existing budgets; the performance record retains failures and paired optimization results.
Quick start
Requires Python 3.11+. Install with uv or pipx:
On Windows, install Git for Windows for Claude's Bash tool. PowerShell can launch these CLI commands, but AgentDetox's shell-write analysis supports Git Bash syntax; PowerShell/cmd.exe syntax is not supported. Windows uses background NLI workers, without a resident model server. Native development commands are in CONTRIBUTING.md.
uv tool install agentdetox
agentdetox demo
The demo uses real hook handlers in a temporary folder: a planted write is denied, shell tampering is noticed, and the file is restored. It makes no model calls and consumes no agent subscription usage.
Connect Claude Code using one of these routes:
Claude Code plugin
Run in your terminal:
claude plugin marketplace add chriswu727/agentdetox
claude plugin install agentdetox@agentdetox
The plugin uses your installed agentdetox. Without it, the plugin needs uvx to fetch and run
its pinned release from PyPI. Installing the CLI above also gives you review and recovery commands.
Direct hooks in Claude Code settings
agentdetox install claude-code --apply
This backs up and updates your Claude Code settings. AgentDetox follows CLAUDE_CONFIG_DIR.
Use this route as an alternative to the plugin.
Restart Claude Code, then check the installation:
agentdetox doctor
agentdetox status
doctor reports missing, outdated or duplicate hooks. The first session scans existing context
before recording recovery checkpoints. Installation, upgrades and removal →
How it works
- Before a write: check planned Write/Edit content and recognized shell writes. High-risk rule matches are denied; flagged text you supplied yourself asks instead, except hidden text. Changes to hooks, MCP servers, permissions and other guardrails need approval.
- After a write or shell tool: retain versions and source evidence. Shell completion or failure triggers a scoped comparison and a review notice for changed context. The interval identifies when a change happened; it does not prove which process wrote it.
- At session start: reconcile changes made outside the agent. Flagged content is reported until reviewed. Newly added runnable settings are mentioned once and stay in review.
- When you review: inspect the diff and evidence, accept that exact version, dismiss a finding, remove selected added lines, or restore the version before a change. Recovery checks for newer edits and backs up the current file.
Watched Claude context includes CLAUDE.md, parent instructions, auto memory, rules, skills,
subagents, commands, output styles, hook scripts, settings and MCP config.
Rules cover English and Chinese. Full coverage and behavior →
A review you can act on
agentdetox review --interactive # browse this project's files in a terminal
agentdetox review --project . --since 7d # recent project and auto-memory changes
agentdetox review C42 # inspect a change id from your review list
agentdetox restore C42 # preview the version before that change
agentdetox restore C42 --apply # back up the current file and restore
C42 is an example id; use the id shown by your own review list. Acceptance and dismissal never
grant permanent trust to a source. Recovery restores a whole recorded version, which can also
undo benign additions. For a newly added config entry, removing it with the tool that added it
is often preferable to restoring the whole settings file.
agentdetox clean C42 lists added lines.
Use agentdetox clean C42 --lines 3,5-7 to preview removing only the lines you selected from
memory, instructions or skills, while keeping other content and non-conflicting later edits.
Run the exact apply command printed by that preview; a changed file invalidates it. Cleanup
backs up the current file and rescans the result. It does not automatically select copied text,
restore overwritten text or judge factual correctness. The terminal review also offers this action.
Review, settings and recovery details →
Evidence and limits
AgentDetox is a layer of checks and recovery, not a security boundary or a factual verifier.
Paraphrased payloads and plausible false facts can pass. Arbitrary scripts and dynamically built
paths may escape pre-execution checks; scoped post-tool observation can detect persistent changes
afterwards. Detached background writes need later reconciliation. Hooks fail open on errors,
which remain visible in doctor and status; a write to agent context that could not be checked asks instead. Code running as your user can alter the hooks or store.
- Offline regression gallery: authored prevention, monitoring and byte-exact recovery cases, plus a separate 21-case acceptance set with three explicit semantic misses. These are not real-world accuracy estimates. Protocol and results.
- Claude Code release-candidate lab, 2026-11-10. Across 12 scenarios with and without AgentDetox, 23 of 24 scenario/arm checks passed. The remaining check required a verbatim edit that the smaller models did not complete. AgentDetox stayed quiet in all seven attempts at that scenario. The lab recorded no hook errors or landed attacks. Results and retries.
- Development latency, 2026-11-10: 100 samples per case on one Mac, no NLI inference. The latest run, on the 0.5.0 release candidate, passed all 12 original budgets: Bash pre/post P95 126.7 ms; startup with 1,000 unchanged files 132.6 ms; four concurrent writes plus a Bash pair 293.6 ms. Earlier scan-load measurements and Windows budget failures remain retained. Method, raw data and limits.
- 100k synthetic inventory, 2026-11-10: full/incremental inspection, cancellation/resumption and scoped dismissal/reopening passed. About 419 MB of notes took 316 s for first inspection, 15.3 s unchanged, with 46.8 MB process peak RSS. Known semantic misses remain explicit; these are local module measurements, not production-support or real-world accuracy claims. Protocol and raw report.
Source matching is evidence of copied text, not proof of malicious intent or human authorship.
An empty rescan does not certify a file as safe.
In 0.5.0, agentdetox library inspects an existing folder of memory files and
cleans reviewed lines; it is measured against a separate
scale protocol,
whose 1k/10k/100k tiers are not current production-support guarantees.
Full limitations ·
Threat model
Local processing, sensitive history
Hooks and checks make no network calls, with one exception you have to turn on: the optional
model check (config judge, or agent inspect --judge) sends the text it reads to a model
through your Claude Code. There is no telemetry or account. Installation, the
plugin's uvx fallback and optional model downloads need network access. File copies and source
evidence stay in ~/.agentdetox; copies of config files can contain secrets. Back up the entire
store, including objects/, and review retention before deleting history.
Privacy and stored data →
More workflows
- Other agents: experimental Codex and Cursor hooks; no OpenClaw plugin, and Cursor has not been run. In 0.5.0,
agentdetox agent inspectfinds the memory, rules and skill files of Claude Code, Codex, Cursor and OpenClaw where each client keeps or relocates them and records what is flagged as review items, socleanandrestorework without any hook. It checks files, not whether a client delivers hook events or whether remembered text is true. Integration matrix. - A model's reading (0.6.0, off by default):
agentdetox config judge askhas a small model read each write to memory, rules and skills for what it would make the agent do; it catches what the rules' wordings miss and can only add a question. What it costs and what it is not. - Contradiction checks: optional local NLI, recorded in the background by default because of false positives. Setup and limits.
- Existing memory libraries (0.5.0):
agentdetox library scan <folder>inventories a folder you choose, inspects its text files with the per-file rules, resumes after interruption and never calls a file clean;clean M<ID>removes reviewed lines with a backup, andlibrary dismisssets a false positive aside for one file's exact bytes without allowlisting it. Library guide. - RAG knowledge bases:
agentdetox scanfor hidden instructions and suspicious passage clusters;traceranks leads behind a wrong answer. Scanner guide.
Documentation and development
Documentation index · User guide · Changelog · Roadmap · Contributing
./scripts/check.sh # lint, type checks and tests
See architecture and design decisions before changing the hook or recovery path. The offline gallery makes no model calls; real-agent lab runs require explicit authorization and a session cap.
Licensed under Apache-2.0.
Metadata
Release files for agentdetox 0.6.0
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 |
|---|---|---|---|---|
| agentdetox-0.6.0.tar.gz | 443.5 kB | With provenance | Details for agentdetox-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentdetox-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for agentdetox-0.6.0-py3-none-any.whl |
Total release size: 706.6 kB
Release files / agentdetox-0.6.0.tar.gz
| Download URL | agentdetox-0.6.0.tar.gz |
|---|---|
| Size | 443.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e54efd30a96bad69cf30e09dbbdf9b86896d52c8e3379c8e2208f8ce55326ed
|
|
BLAKE2b-256 checksum How to use checksums |
e6f42e0551b43fabb80cb750010ebb8a1d9690623371aeabdc53eb392dc211f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 12, 2026.
Transparency logRelease files / agentdetox-0.6.0-py3-none-any.whl
| Download URL | agentdetox-0.6.0-py3-none-any.whl |
|---|---|
| Size | 263.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
52582b9a52bc12714e5f0036097f1b6f1b845ab10d9e231b804c9f63321a17b2
|
|
BLAKE2b-256 checksum How to use checksums |
7eaab624375500bc6c53c348c5ad9f2ce24e2099f0709a4a3fe011d4ffe7acd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 12, 2026.
Transparency logSecurity for agentdetox 0.6.0
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 agentdetox-0.6.0.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 Nov 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.