Skip to main content
Back to Vibe Coder Toolkit
Core

Subprocess Filter

Compress noisy output before your agent reads it

npx promptreports-cli filter -- <cmd>

Wraps any shell command. Captures stdout/stderr, strips ANSI, collapses repeated lines, elides long stack traces, and truncates uniform blocks. Errors pass through. Exit code preserved.

Your agent reads every byte your test suite, build, or linter prints — at input-token prices. Most of it is noise: 400 passing test lines, 80 identical stack frames, ANSI color codes. This command spawns your subprocess, captures both streams, and compresses before your agent ever sees it. Errors and warnings always pass through untouched. The tail is always preserved (configurable). The exit code is the subprocess exit code. Works with any CLI: jest, playwright, docker, webpack, cargo, anything.

Prerequisites

  • Node.js >= 18

Flags & Options

FlagDescriptionDefault
--keep-last NLines to preserve at tail20
--max-repeat NThreshold before collapsing duplicates2
--truncate-after NLines before uniform-block truncation50
--jsonEmit reduction stats as JSON to stderr
--quietSuppress the reduction summary

Examples

Filter Jest output

npx promptreports-cli filter -- npm test

Collapse passing tests, preserve failures, truncate stack traces.

Filter Playwright

npx promptreports-cli filter -- playwright test

Handles the long list-reporter output agents choke on.

Filter Docker build

npx promptreports-cli filter -- docker build .

Docker emits hundreds of step-progress lines. Crush them.

More tail context

npx promptreports-cli filter --keep-last 50 -- npm run ci

Keep 50 lines of tail for CI debugging.

Pipe stats elsewhere

npx promptreports-cli filter --json -- npm test 2>stats.json

Capture reduction metrics without polluting the output.

Output

Compressed subprocess output followed by a reduction summary (lines in → out, percent saved). Exit code passes through so CI still breaks correctly on failure.

  filter: running npm test

  PASS  src/utils/parse.test.ts
  PASS  src/utils/format.test.ts
  PASS  src/commands/summary.test.ts
    [... 47 similar lines elided ...]

  FAIL  src/commands/push.test.ts
    ● should dedupe turns
      expect(received).toEqual(expected)
      at Object.<anonymous> (src/commands/push.test.ts:42:21)
      [... 18 stack frames elided ...]
      at processTicksAndRejections (node:internal/process)

  Test Suites: 1 failed, 49 passed, 50 total
  Tests:       1 failed, 423 passed, 424 total

  filter: 1,847 lines in → 142 out (92.3% reduction)  exit 1

What it reads and writes

Reads

  • Subprocess stdout/stderr (streamed, never written to disk)

Writes

Nothing (read-only)

Free vs Pro usage

Free tier

  • Wrap any CLI command your agent invokes to cut token burn
  • Get back the tail of a long build without the middle
  • Keep stack traces actionable by preserving first/last frames

Pro tier

Upgrade
  • Push reduction stats to a team dashboard to quantify savings
  • Enforce filter-wrapping via agent hooks/presets
  • A/B compare pre- and post-filter token spend in dashboards

Pro tips

  • If your agent hits the 200K context wall on a single command, wrap it in filter
  • Pass --keep-last 100 for CI debugging when you need more tail context
  • Failing tests always pass through — never worry about missing the real error
Free to try

Install the whole toolkit.

One command unlocks all 23 tools.