Before
<script>window.analytics = true;</script>
<nav>Home Pricing Login Cookie preferences</nav>
<main>
<h1>ContextClean keeps the main article</h1>
<p>Unique failure: TypeError at src/app.ts:42.</p>
</main>
<footer>Newsletter signup</footer>
Local-first context cleaner for AI agents
ContextClean turns noisy files, web exports, terminal output, and project folders into compact, reviewable, token-budgeted context packs.
$ ctxclean dirty.html --mode standard --format json
input_tokens: 124
output_tokens: 37
tokens_saved: 87
reduction: 70.1%
removed:
- script/style blocks
- nav/footer boilerplate
- cookie and newsletter noise
preserved:
- main article
- TypeError at src/app.ts:42
Verified fixture result
<script>window.analytics = true;</script>
<nav>Home Pricing Login Cookie preferences</nav>
<main>
<h1>ContextClean keeps the main article</h1>
<p>Unique failure: TypeError at src/app.ts:42.</p>
</main>
<footer>Newsletter signup</footer>
ContextClean keeps the main article
Unique failure: TypeError at src/app.ts:42.
Tokens saved: 87
Reduction: 70.1%
Phase 1 foundation
Remove scripts, styles, navs, footers, comments, cookie banners, and repeated lines.
Fit output into an estimated token budget with explicit truncation metadata.
Emit JSON with input/output tokens, tokens saved, removed sections, warnings, and source.
Redact secret-like values by default and respect ignore files during directory scans.
Run locally
cargo install --path crates/contextclean-cli
ctxclean fixtures/dirty_html_small.html --format json
Trust model