Skip to content

Log Crushing And ctxrun

karurikwao edited this page Jul 5, 2026 · 1 revision

Log Crushing And ctxrun

ContextClean includes a log crusher for CI logs, terminal output, and stack traces.

Goals

The log cleaner should make logs smaller without losing the reason the command failed.

It preserves:

  • unique error lines
  • failed test names
  • final error summaries
  • important stack frames
  • timestamps around repeated failures
  • command context in ctxrun

It removes or collapses:

  • repeated identical lines
  • duplicate stack frames
  • install summaries
  • package-manager noise
  • safe build chatter
  • provider-specific CI progress lines

GitHub Actions Logs

Use:

ctxclean gha failed-log.txt --max-tokens 8000 --format markdown

The gha alias defaults to aggressive mode and is tuned for CI failure logs.

Provider Noise Rules

Current provider-specific rules include:

  • GitHub Actions grouping and runner boilerplate
  • npm install/fetch/deprecated noise
  • pnpm progress lines
  • cargo compile/check/download noise
  • pytest collection/progress noise
  • Docker Buildx progress lines
  • Playwright run/pass noise

The intent is not to delete all build output. The intent is to remove lines that are usually not the failure.

Repeated Lines

Repeated lines are collapsed into markers such as:

[Repeated 1284 times] Connection timeout to database

Timestamped repeats preserve the first and last timestamps when possible.

Stack Frames

Duplicate stack frames are collapsed while distinct locations are preserved.

Example:

[Collapsed stack frames: 93 duplicate frames removed]

ctxrun

Use ctxrun when you want a command wrapper:

ctxrun --max-tokens 8000 npm test
ctxrun --format markdown cargo test

Behavior:

  • success: output passes through
  • failure: output is cleaned
  • exit code: preserved
  • timeout: exits 124

Useful options:

ctxrun --capture-limit-bytes 4194304 --timeout-seconds 120 npm test

--capture-limit-bytes limits failed-output capture memory per stream. It does not silently truncate successful output.

Clone this wiki locally