Local-first context cleaner for AI agents

ContextClean

Stop paying LLMs to read raw HTML, repeated logs, and secret-shaped noise. ContextClean turns noisy files, web exports, terminal output, and project folders into compact, reviewable, token-budgeted context packs with reports that explain the savings.

Animated terminal demo showing ContextClean cleaning a failed CI log, preserving the unique failure, and reducing 75,768 tokens to 3,200 tokens.

Measured launch fixtures

Exact token counts, checked into the repo

Fixture Before After Saved Reduction
HTML scrape 70,571 5,892 64,679 91.7%
CI failure log 75,768 3,200 72,568 95.8%
Provider CI mix 17,469 33 17,436 99.8%
Stack trace dump 28,189 1,850 26,339 93.4%

Fixture-backed excerpts

From noisy HTML and logs to model-ready context

Looping ContextClean terminal workflow showing log cleanup and token savings.

HTML Before

<script>window.analytics = true;</script>
<nav>Home Pricing Login Cookie preferences</nav>
<div id="cookie-banner">Accept all cookies</div>
<main>
  <h1>API Setup &amp; Troubleshooting</h1>
  <p>Read <a href="/docs/setup">setup guide</a>.</p>
  <table><tr><th>Mode</th><th>Keeps</th></tr></table>
</main>
<footer>Newsletter signup</footer>

HTML After

# API Setup & Troubleshooting

Read [setup guide](/docs/setup).

| Mode | Keeps |
| --- | --- |

Tokens saved: 266
Reduction: 71.7%

Log Before

added 481 packages
found 0 vulnerabilities
2026-07-04T10:00:01Z warn Connection timeout to database
2026-07-04T10:00:02Z warn Connection timeout to database
2026-07-04T10:00:03Z warn Connection timeout to database
FAIL packages/api/user.test.ts
Unique failure:
TypeError: Cannot read properties of undefined
    at loadUser (/app/src/user.ts:42:13)
    at main (/app/src/main.ts:8:1)
    at loadUser (/app/src/user.ts:42:13)
    at main (/app/src/main.ts:8:1)
Final error summary: request failed after retries

Log After

[Repeated 3 times from 2026-07-04T10:00:01Z to 2026-07-04T10:00:03Z] Connection timeout to database
FAIL packages/api/user.test.ts
Unique failure:
TypeError: Cannot read properties of undefined
    at loadUser (/app/src/user.ts:42:13)
    at main (/app/src/main.ts:8:1)
[Collapsed stack frames: 2 duplicate frames removed]
Final error summary: request failed after retries

Tokens saved: 43
Reduction: 28.9%

Cleaner + Crusher + Reporter

Built for the context AI agents actually need

HTML Cleaner

Remove scripts, styles, navs, footers, comments, cookie banners, modals, ads, and tracking blocks.

Preserve Structure

Keep headings, links, paragraphs, tables, lists, inline code, and fenced code blocks readable.

Log Crusher

Collapse repeated lines and duplicate stack frames while preserving failed tests, timestamps, and final errors.

Budget Packer

Use exact token counting, --max-tokens, and model presets for GPT, Claude, and Gemini-sized contexts.

Context Reports

Run ctxclean report to see input tokens, output tokens, compression ratio, biggest noise, and the command to use next.

Agent Integrations

Use ctxclean gha, ctxclean repo, ctxclean mcp, and ctxrun inside daily AI workflows.

Protect

Redact secret-like values by default, respect ignore files, skip generated paths, and require explicit sensitive-file opt-in.

Run locally

No API keys. No telemetry. No cloud dependency.

# Download binaries:
https://github.com/karurikwao/contextclean/releases/tag/v0.1.0

# Or install from Git with Rust 1.85+:
cargo install --git https://github.com/karurikwao/contextclean contextclean-cli

ctxclean gha build.log --max-tokens 3200 --format markdown
ctxclean repo . --fit gpt-4.1 --output context.md
ctxrun --max-tokens 8000 npm test

Trust model

Context stays on your machine.