Skip to content

skibidiskib/ai-squeeze

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ai-squeeze

Built by Claude Code License: MIT TypeScript

This project was entirely designed, written, and published by Claude Code (Anthropic's AI coding assistant).

Compress verbose CLI output for AI coding assistants. Turns 500-line build errors into 15 lines. Saves 90%+ tokens on noisy output.

The Problem

Every time your AI coding assistant runs a command, the full output goes into its context window. A single npx tsc --noEmit can dump 500+ lines of errors. A jest --verbose run prints every passing test. An npm install spews 200 lines of progress nobody reads.

That output eats tokens. Tokens cost money. Worse, the noise pushes useful context out of the window.

ai-squeeze compresses that output before it reaches the AI. It auto-detects the output type and applies smart, type-specific compression.

Quick Start

npx ai-squeeze "npm run build 2>&1"

Or pipe:

npx tsc --noEmit 2>&1 | npx ai-squeeze

Before / After

TypeScript Errors

Before (523 lines):

src/app/admin/users/page.tsx(12,5): error TS2322: Type 'string' is not assignable to type 'number'.
src/app/admin/users/page.tsx(15,10): error TS2304: Cannot find name 'UserProfile'.
src/lib/auth.ts(3,1): error TS2322: Type 'string' is not assignable to type 'number'.
src/lib/auth.ts(8,14): error TS7006: Parameter 'req' implicitly has an 'any' type.
... (519 more lines)

After (15 lines):

TypeScript: 523 errors in 84 files

By error code:
  TS2322: 201 occurrences
  TS2304: 156 occurrences
  TS7006: 98 occurrences
  TS2345: 45 occurrences
  TS2339: 23 occurrences

First errors:
  src/app/admin/users/page.tsx:12 TS2322: Type 'string' is not assignable to type 'number'
  src/app/admin/users/page.tsx:15 TS2304: Cannot find name 'UserProfile'
  src/lib/auth.ts:3 TS2322: Type 'string' is not assignable to type 'number'

-- squeezed [typescript-errors]: 523 -> 15 lines | ~12,800 tokens saved (95%) --

Test Results

Before (347 lines):

PASS src/utils/date.test.ts
  date formatting
    ✓ formats ISO to display (3ms)
    ✓ handles null dates (1ms)
    ✓ applies timezone offset (2ms)
... (200 more passing tests)
FAIL src/api/users.test.ts
  user API
    ✕ returns 404 for missing user (5ms)
      Expected: 404
      Received: 500
... (more output)

After (12 lines):

Test Suites: 23 passed, 1 failed, 24 total
Tests:       198 passed, 2 failed, 200 total
Time:        12.3s

FAILURES:
  FAIL src/api/users.test.ts
    user API
      ✕ returns 404 for missing user (5ms)
        Expected: 404
        Received: 500

-- squeezed [test-results]: 347 -> 12 lines | ~8,200 tokens saved (93%) --

Stack Traces

Before (48 lines):

TypeError: Cannot read properties of undefined (reading 'id')
    at getUserProfile (/src/api/users.ts:45:23)
    at handler (/src/app/api/users/route.ts:12:18)
    at Object.apply (/node_modules/next/dist/server/web/adapter.js:123:16)
    at /node_modules/next/dist/server/base-server.js:456:22
    ... (43 more node_modules frames)

After (6 lines):

TypeError: Cannot read properties of undefined (reading 'id')
    at getUserProfile (/src/api/users.ts:45:23)
    at handler (/src/app/api/users/route.ts:12:18)
    ... 43 library/internal frames

-- squeezed [stack-trace]: 48 -> 4 lines | ~1,100 tokens saved (90%) --

npm Install

Before (189 lines):

npm warn deprecated inflight@1.0.6: ...
npm warn deprecated @humanwhocodes/config-array@0.11.14: ...
npm warn deprecated rimraf@3.0.2: ...
... (progress bars, resolution details, etc.)
added 1847 packages in 42s
234 packages are looking for funding
  run `npm fund` for details
3 moderate severity vulnerabilities

After (4 lines):

added 1847 packages in 42s
3 deprecation warning(s)
234 packages are looking for funding
3 moderate severity vulnerabilities

-- squeezed [npm-install]: 189 -> 4 lines | ~4,600 tokens saved (97%) --

Detected Output Types

Type Pattern Strategy
typescript-errors error TS\d+ Group by error code, show first 5 unique
eslint-errors X problems (Y errors, Z warnings) Group by rule, show samples
test-results PASS/FAIL, Tests: Summary + failures only
npm-install added X packages Summary + warning counts
stack-trace Error: + at frames User frames only, collapse libs
git-log Commit hash lines Head 10 + tail 5
json-blob Valid JSON > 500 chars Schema + first 2 items
generic Everything else Dedup + head/tail

CLI Options

squeeze <command>                Run command, compress output
<command> | squeeze              Pipe mode
squeeze --threshold 30 <cmd>    Min lines before compression (default: 20)
squeeze --type typescript <cmd>  Force detection type
squeeze --stats-only <cmd>      Show only stats, not output
squeeze --help                  Show help

Integration with AI Assistants

Claude Code

Add to your CLAUDE.md:

## Output Compression
For commands that may produce verbose output (builds, tests, logs), use squeeze:
- `squeeze "npx tsc --noEmit 2>&1"` instead of running tsc directly
- `squeeze "npx jest --verbose 2>&1"` for test runs
- `git log --oneline -100 | squeeze` for long git history

Cursor / Copilot / Codex

Add squeeze to your AI assistant's rules file. Any tool that reads CLI output benefits from compressed input.

How It Works

  1. Output under 20 lines passes through unchanged
  2. ANSI escape codes are stripped
  3. Pattern matching detects the output type
  4. Type-specific compressor extracts signal, drops noise
  5. Stats line shows savings

No AI models are used. All compression is deterministic pattern matching. Fast, free, predictable.

Pairs With

  • ai-codex -- pre-build codebase index (saves exploration tokens)
  • RTK -- bash output compression at the shell level

ai-codex saves tokens at session start. ai-squeeze saves tokens during the session. Use both.

License

MIT. Free forever.

About

Compress verbose CLI output for AI coding assistants. Saves 90%+ tokens on build errors, test results, and logs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors