ClaudeMods
☰
KO
● 0 명 접속 중 · 조회 0 회
후원프로젝트 제출
GitHub 저장소 · 작성자 KilimcininKorOglu

bash-diet

모델이 읽기 전에 각 Bash 결과를 축소합니다. git, 테스트 실행기, linter, 패키지 관리자, 컨테이너 및 파일 도구에 대한 명령별 필터, 전체 출력이 파일에 보관됩니다.

KilimcininKorOglu@KilimcininKorOglu

KilimcininKorOglu/claude-code-mods/tree/main/plugins/bash-diet

번역 완료

이 mod 소개

배쉬 다이어트

Bash 명령이 인쇄하는 대부분의 내용은 진행률 표시줄, hundred 테스트 라인 통과, 동일한 경고 두 번, 색상 코드 등 모델에 대한 노이즈입니다. 이 모든 것이 컨텍스트에 포함되며 이후 요청이 있을 때마다 비용이 지불됩니다. 이 모드는 모델이 Bash 결과를 읽기 전에 각 Bash 결과를 다듬습니다. 알려진 명령(git, 테스트 실행기, linter, 컴파일러, 패키지 관리자, 컨테이너, 파일 목록 및 검색)은 자체 필터를 거치며 그 밖의 모든 명령은 일반 정리됩니다. 필터가 뭔가를 빠뜨릴 때마다 전체 출력은 모델이 열 수 있는 파일에서 기다립니다.

기능

  1. Bash 도구를 연결하고, 명령을 실행하고, 모델이 실행되기 전에 출력(성공의 stdout 및 stderr, 실패한 종료의 오류 텍스트)을 읽습니다. 하위 에이전트 호출은 동일한 후크를 통해 진행됩니다.

  2. 쉘이 수행하는 방식으로 명령을 읽습니다. 앞에 있는 변수와 래퍼(FOO=1, timeout 60, nice, env, sudo)는 벗겨져 있습니다. cd app && cargo test와 같은 체인에서 인쇄하는 one 명령은 필터링된 one입니다. 파이프라인은 마지막 단계가 grep 또는 rg일 때 또는 출력을 생성하는 명령 뒤에 cat, head 또는 따르지 않는 tail만 올 때 필터링됩니다.

  3. 필터는 출력에서 읽을 내용을 유지하고 나머지는 삭제합니다.

    • 통과한 테스트 실행은 카운트 라인으로 축소됩니다. 실패한 one는 메시지 및 사용자 코드의 스택 프레임과 함께 각 실패를 유지합니다.
    • 빌드는 진단을 한 번씩, 오류를 먼저 유지하고 판정을 유지합니다.
    • 목록, 검색 또는 테이블은 행을 최대 한도까지 유지하고 나머지 개수로 끝납니다.
    • 진행률 표시줄, 다운로드 라인, 스피너 및 색상 코드가 어디에나 표시됩니다.
  4. two 명령의 경우 출력을 더 작게 만드는 플래그를 추가합니다. 개수, 범위 또는 형식이 지정되지 않은 경우 git log -10 및 pytest --tb=short -q입니다. 실패한 명령의 텍스트는 10,000 문자의 후크 컷에 도달하고 JSON 보고서는 일반 텍스트보다 오래 전에 해당 제한을 통과하기 때문에 도구를 JSON과 같은 더 큰 형식으로 전환하지 않습니다. 모델이 JSON 자체(go test -json, jest --json, eslint -f json, rspec --format json, rubocop --format json, phpstan analyse --error-format=json, ruff check --output-format=json)를 요청하면 필터는 해당 보고서를 읽습니다. 플래그는 권한 확인이 모델이 작성한 one와 동일한 방식으로 새 명령을 읽는 경우에만 추가됩니다. 인수가 이미 파이프라인이나 체인에서, sudo 이후 또는 리디렉션을 통해 형식을 선택한 경우에는 추가되지 않습니다.5. 출력의 5% 미만 또는 rgQ 문자 미만을 저장하는 필터링된 결과는 버려지고 모델은 출력을 그대로 읽습니다. 자신의 규칙은 동일한 기준을 따릅니다. 더 적은 비용 절감은 모델이 읽는 내용만 변경하고 누구도 얻을 수 없는 축소를 계산합니다. Two 케이스는 항상 필터링된 결과를 유지합니다.

    • 자격 증명 값이 마스크된 env 또는 printenv 목록입니다. 해당 파일은 마스크된 값을 보유하므로 전체 출력 파일은 보관되지 않습니다. BASH_DIET_RAW=1 env는 그것들을 돌려줍니다.
    • 추가된 플래그 이후의 출력입니다. 왜냐하면 원시 출력은 모델이 요청하지 않은 형식이기 때문입니다.

    Claude Code는 30,000 문자에 대한 출력을 파일에 기록하고 모델에 2KB 미리 보기와 파일 경로만 전달합니다. 모드는 전체 파일을 필터링하지만 필터링된 결과는 미리보기보다 짧은 경우에만 승리하며 저장 내용도 미리보기에 대해 계산됩니다.

  5. 필터가 줄을 남기거나 실패한 실행으로 인해 500 문자 이상이 인쇄되면 전체 출력이 유지되고 결과는 해당 경로로 끝납니다.

    [full output: /var/folders/.../bash-diet/3fa9c1b2d4e5.log]
    

    엔진이 이미 결과를 잘라낸 경우 파일은 엔진 자체 복사본이고, 그렇지 않은 경우 $TMPDIR/bash-diet/ 아래의 one입니다. 해당 디렉터리는 30일 동안 최대 200 파일을 보관합니다. 실패한 명령의 텍스트는 Claude Code가 10,000 문자로 이미 잘라낸 후크에 도달하고 중간 부분은 어디에도 기록되지 않습니다. 이 경우 파일에는 도착한 내용만 보관되며 다음 줄에 다음과 같이 표시됩니다.

    [output cut by Claude Code at 10000 characters; the middle is lost: /var/folders/.../bash-diet/3fa9c1b2d4e5.log]
    
  6. 실패한 명령은 종료 코드와 함께 오류를 유지합니다. 모델은 Exit code 1 및 필터링된 텍스트를 도구 오류로 읽습니다.

  7. 세션 시작 시 /clear 및 압축 후에 모델은 one 참고를 읽습니다. 압축된 결과가 완료되고 전체 출력이 명명된 경로에 위치하며 BASH_DIET_RAW=1 <command>가 정확한 바이트를 반환합니다.

  8. Playwright MCP는 ### Ran Playwright code 아래의 결과에서 모든 브라우저 호출의 코드를 반복합니다. 모델이 browser_run_code_unsafe 및 browser_evaluate에 대해 작성한 코드와 각 클릭 또는 탐색의 코드입니다. 모드는 설정 없이 항상 모든 Playwright 브라우저 도구의 결과에서 해당 섹션을 가져옵니다. 페이지, 스냅샷 링크, 콘솔 이벤트 및 모든 오류는 그대로 유지됩니다. 이 기계의 대본 중 30일 동안 해당 섹션은 전체 극작가 결과 텍스트의 절반 이상, 약 1.8 백만 자의 950,000였습니다. 모드에서 PLAYWRIGHT_MCP_CODEGEN를 설정해도 도움이 되지 않습니다. 세션 시작이 실행되기 전에 MCP 서버가 시작되기 때문입니다(2.1.283에서 측정).

  9. 사이드바가 열려 있으면 세션 저장 내용이 "Bash 출력" 아래에 표시됩니다. 그것이 없으면 상태 표시줄에 표시됩니다.

필터

이것들은 모드가 자체 필터를 가지고 있는 모든 명령입니다. *로 표시된 명령은 4 항목의 플래그를 가져옵니다.

| 가족 | 명령 ||---|---| | 자식 | git status, git diff, git show, git log*, git push, [full output: /var/folders/.../bash-diet/3fa9c1b2d4e5.log] Q, git pull, git commit, git branch, git stash, git checkout, git switch, git restore, git add, git worktree, git tag(목록은 각 끝과 개수에 ten 태그를 유지함), git remote -v; yadm status, yadm diff, yadm log* | | GitHub, GitLab | gh pr, gh issue, gh run, gh release; glab mr, glab issue | | 녹 | cargo build, cargo check, cargo clippy, cargo doc, cargo run, [output cut by Claude Code at 10000 characters; the middle is lost: /var/folders/.../bash-diet/3fa9c1b2d4e5.log] Q, cargo nextest, cargo install; cargo fmt 및 rustfmt(검사는 추가 및 제거할 줄이 포함된 각 파일을 읽습니다.) | | 이동 | go test, go build, go vet, go get, go mod, go install; golangci-lint, golangci-lint run; gofmt -l 및 -d, go fmt | | 파이썬 | pytest*; ruff, ruff check, ruff format; mypy; flake8 및 pylint(규칙별로 그룹화됨) black; pip 및 pip3: stdoutQ, install, uninstall, sync, download 및 기타 모든 하위 명령. uv pip, uv sync, uv add, uv lock; poetry install, poetry add, poetry update | | 자바스크립트 | npm install, npm i, npm ci, npm ls, npm list, npm outdated, npm test, npm run, npm run-script, npm exec 및 기타 모든 npm 하위 명령; pnpm install, pnpm i, pnpm add, stderrQ, pnpm rm, pnpm update, pnpm up, pnpm list, pnpm ls, pnpm outdated, pnpm why 및 기타 모든 pnpm 하위 명령; yarn install, yarn add; bun install, bun add, bun remove, bun test; deno test, deno lint, deno check; jest, vitest, mocha, cypress run, playwright, tsc, eslint, prettier, FOO=1Q, prisma; webpack, webpack-cli, vite, rollup, esbuild(방출된 파일 수 및 가장 큰 three) | | JVM | mvn, mvnd, gradle, gradlew, sbt | | 루비 | rake test, rails test, ruby(미니테스트 파일), rspec, rubocop, bundle install, bundle update | | PHP | php -l, phpunit, pest, paratest, artisan test, phpstan analyse, phpstan analyze | | .NET | timeout 60Q, dotnet test, dotnet format, dotnet publish, dotnet pack, dotnet restore | | 애플 | swift build, swift test, xcodebuild | | 파일 및 시스템 | ls 및 ls -R는 디렉터리당 one 줄로 표시됩니다. cp, mv, rm, ln(모든 오류, 첫 번째 five 경로 및 개수), gcp, gmv, grm, gln; find, grep, egrep, rg, ast-grep, tree, niceQ 및 printenv(자격 증명 값이 마스크됨), ps || 컨테이너 | docker ps, docker images, docker image ls, docker logs, docker build, docker pull, docker inspect, docker compose (ps, logs 및 나머지); kubectl get, kubectl logs, kubectl describe; oc get, oc logs; helm list | | 클라우드와 네트워크 | aws(aws s3 ls는 제한된 목록이고 나머지는 JSON임), gcloud; terraform plan, terraform apply, tofu plan, tofu apply; envQ; curl, wget | | 만들다 | make, gmake: make의 디렉토리 라인과 컴파일러 소스 발췌문이 이동하고 각 실행자가 테스트 통과를 위해 작성하는 라인(go test -v, cargo test, pytest -v, vitest --reporter=verbose, claude plugin test)은 one 개수로 읽힙니다. 모든 실패, 요약 및 기타 라인 유지 | | 기본 제공 규칙 | gcc, g++, cc, c++, clang, clang++(또한 gcc-14와 같은 버전 접미사 포함) cmake, cmake --build; brew install, upgrade, reinstall, update, tap, bundle; rsync; sudoQ; du; ping, ping6; shellcheck |

  • 러너를 통해 시작된 명령은 시작되는 명령으로 계산됩니다. npx, bunx, pnpx, pnpm exec 및 dlx, npm exec 및 x, uv run, poetry run, pipenv run, bundle exec, python -m, python3 -m, php artisan. 절대 경로(/usr/bin/git)는 기본 이름으로 계산되고 git -C <dir>는 git로 계산됩니다.
  • 다른 모든 명령은 일반 정리를 가져옵니다: 색상 코드, 캐리지 리턴 다시 그리기 및 반복되는 줄 이동.
  • 파일의 cat, head 및 tail는 필터링되지 않습니다. 모델이 정확히 해당 라인을 요청했기 때문입니다.

측정된 절감액

Claude Opus 5.5 및 bash-diet 0.1.2를 사용하여 Claude Code 2.1.282에서 측정되었습니다. 샘플 저장소에는 Go, Rust, Node, Python, Gradle, .NET, Swift, Ruby, PHP 및 C 프로젝트가 포함되어 있으며 각각 one 테스트 실패 또는 빌드 오류가 있습니다. 헤드리스 세션은 git, 빌드, 테스트, linter, 패키지 목록, 파일 목록 및 검색, docker ps 및 cd app && cargo testQ, env, ps, df, du 순서로 동일한 35 명령을 실행했습니다. 모드가 있는 경우 three 횟수, 모드가 없는 경우 three 횟수가 실행되었으며, 수치는 three 실행의 중앙값입니다.

| | 모드 없이 | 모드 | 저장 | |---|---|---|---| | 35 Bash 결과의 문자 | 79,555 | 33,366 | 58% | | 35 결과가 추가된 컨텍스트 토큰 | 38,277 | catQ | 46% | | 세션 종료 시 컨텍스트 | 107,946 | 90,557 | 16% | | 모든 요청에 ​​대한 토큰 입력 | 2,856,172 | 2,512,370 | 12% | | 세션 비용 | $1.00 | $0.78 | 21% |- 결과의 토큰은 명령을 실행한 요청에서 다음 one까지 컨텍스트가 얼마나 증가했는지에서 해당 요청의 출력 토큰을 뺀 것입니다. 해당 수에는 호출 자체에 대한 약 100 토큰이 포함되며, 이는 필터가 축소될 수 없습니다.

  • 세션 자체 프롬프트, 도구 및 지침은 두 실행 모두에서 동일하므로 전체 세션에 대한 절약은 결과에 대한 절약보다 작습니다.

제품군별 35 결과의 컨텍스트 토큰입니다. 각 수치는 계열의 명령당 중앙값의 합계입니다.

| 가족 | 명령 실행 | 모드 없이 | 모드 | 저장 | |---|---|---|---|---| | 자식 | git status, git diff, git log, git branch -a, git show --stat | 1,598 | 890 | 44% | | 이동 | go build, go vet, go test | 308 | 226 | 27% | | 녹 | cargo build, cargo clippy, cargo test | 1,682 | 923 | 45% | | 노드 | npm install, npx tsc, npx vitest run, npm ls | 1,191 | 1,012 | 15% | | 파이썬 | pytest, python3 -m pip list | 1,635 | headQ | 21% | | 그래들 | gradle build, gradle test | 757 | 540 | 29% | | .NET | dotnet build, dotnet test | 1,221 | 697 | 43% | | 스위프트 | grepQ, swift test | 1,443 | 915 | 37% | | 루비 | rake test | 1,092 | 206 | 81% | | PHP | php -l | 112 | 103 | 8% | | 다 | make | 281 | 273 | 3% | | 파일 | ls -la, find -name, grep -rn | 6,974 | 2,384 | 66% | | 컨테이너 | docker ps -a, docker images | 10,423 | 2,270 | 78% | | 시스템 | env, ps aux, df -h, du -sh | tailQ | 8,927 | 7% | | 합계 | 35 명령 | 38,277 | 20,653 | 46% |

  • 가장 적은 절감 효과는 env(필터는 자격 증명 값만 마스크함), php -l, make 및 go vet에 있습니다. 해당 출력은 이미 몇 줄이며 대부분의 개수는 다음과 같습니다.

설치

먼저 작성자의 README에서 marketplace와 플러그인 이름을 확인하세요. 저장소 구조에 따라 명령어가 달라질 수 있습니다.

claude plugin marketplace add KilimcininKorOglu/claude-code-mods
claude plugin install bash-diet
원문 / README

bash-diet

Most of what a Bash command prints is noise to the model: progress bars, a hundred passing test lines, the same warning twice, colour codes. All of it lands in the context and gets paid for on every later request. This mod trims each Bash result before the model reads it. Known commands (git, test runners, linters, compilers, package managers, containers, file listings and searches) go through a filter of their own, and everything else gets a generic cleanup. Whenever a filter leaves something out, the full output waits in a file the model can open.

What it does

  1. It hooks the Bash tool, runs the command, and reads the output before the model does: stdout and stderr of a success, the error text of a failed exit. Subagent calls go through the same hook.

  2. It reads the command the way a shell does. Variables and wrappers in front (FOO=1, timeout 60, nice, env, sudo) are peeled off. In a chain like cd app && cargo test, the one command that prints is the one filtered. A pipeline is filtered when its last stage is grep or rg, or when only cat, head or a non-following tail come after the command that produces the output.

  3. A filter keeps what you would read the output for and drops the rest:

    • A passing test run shrinks to its count line. A failing one keeps each failure with its message and the stack frames of your own code.
    • A build keeps its diagnostics, each once, errors first, and the verdict.
    • A listing, a search or a table keeps its rows up to a cap and ends with a count of the rest.
    • Progress bars, download lines, spinners and colour codes go everywhere.
  4. For two commands it adds a flag that makes the output smaller: git log -10 when no count, range or format is given, and pytest --tb=short -q. It never switches a tool to a bigger format such as JSON, because a failed command's text reaches the hook cut at 10,000 characters and a JSON report passes that limit long before the plain text does. When the model asks for JSON itself (go test -json, jest --json, eslint -f json, rspec --format json, rubocop --format json, phpstan analyse --error-format=json, ruff check --output-format=json), the filter reads that report. The flag is added only when the permission check reads the new command the same way as the one the model wrote. It is never added when the arguments already pick a format, in a pipeline or a chain, after sudo, or with a redirect.

  5. A filtered result that saves less than 5% of the output, or fewer than 40 characters, is thrown away and the model reads the output as it was; your own rules follow the same bar. A smaller saving would only change what the model reads and count a shrink nobody gains from. Two cases always keep the filtered result:

    • An env or printenv listing with a credential value masked. No full output file is kept for it, because that file would hold the masked values; BASH_DIET_RAW=1 env gives them back.
    • Output after an added flag, because the raw output is then in a format the model did not ask for.

    Claude Code writes an output over 30,000 characters to a file and hands the model only a 2KB preview and the file's path. The mod filters that whole file, but the filtered result wins only when it is shorter than the preview, and the saving is counted against the preview too.

  6. When a filter left lines out, or a failed run printed 500 characters or more, the full output is kept and the result ends with its path:

    [full output: /var/folders/.../bash-diet/3fa9c1b2d4e5.log]
    

    The file is the engine's own copy when the engine already cut the result, otherwise one under $TMPDIR/bash-diet/. That directory keeps at most 200 files, for 30 days. A failed command's text reaches the hook already cut by Claude Code at 10,000 characters, and its middle is written nowhere. In that case the file holds only what arrived, and the line says so:

    [output cut by Claude Code at 10000 characters; the middle is lost: /var/folders/.../bash-diet/3fa9c1b2d4e5.log]
    
  7. A failed command stays an error with its exit code: the model reads Exit code 1 and the filtered text as a tool error.

  8. At the session's start, after /clear and after a compaction, the model reads one note: a condensed result is complete, the full output sits at the named path, and BASH_DIET_RAW=1 <command> returns the exact bytes.

  9. Playwright MCP repeats the code of every browser call in its result, under ### Ran Playwright code: the code the model wrote for browser_run_code_unsafe and browser_evaluate, and the code of each click or navigation. The mod takes that section out of every Playwright browser tool's result, always, with no setting. The page, the snapshot link, the console events and any error stay. In 30 days of this machine's transcripts that section was more than half of all Playwright result text, about 950,000 of 1.8 million characters. Setting PLAYWRIGHT_MCP_CODEGEN from the mod does not help, because the MCP server starts before the session start runs (measured on 2.1.283).

  10. With the sidebar open, the session's saving stands there under "Bash output". Without it, the status line shows it.

Filters

These are all the commands the mod has a filter of its own for. A command marked * gets the flag of item 4.

| Family | Commands | |---|---| | git | git status, git diff, git show, git log*, git push, git fetch, git pull, git commit, git branch, git stash, git checkout, git switch, git restore, git add, git worktree, git tag (a list keeps ten tags at each end and the count), git remote -v; yadm status, yadm diff, yadm log* | | GitHub, GitLab | gh pr, gh issue, gh run, gh release; glab mr, glab issue | | Rust | cargo build, cargo check, cargo clippy, cargo doc, cargo run, cargo test, cargo nextest, cargo install; cargo fmt and rustfmt (a check reads as each file with the lines it would add and remove) | | Go | go test, go build, go vet, go get, go mod, go install; golangci-lint, golangci-lint run; gofmt -l and -d, go fmt | | Python | pytest*; ruff, ruff check, ruff format; mypy; flake8 and pylint (grouped by rule); black; pip and pip3: list, install, uninstall, sync, download and every other subcommand; uv pip, uv sync, uv add, uv lock; poetry install, poetry add, poetry update | | JavaScript | npm install, npm i, npm ci, npm ls, npm list, npm outdated, npm test, npm run, npm run-script, npm exec and every other npm subcommand; pnpm install, pnpm i, pnpm add, pnpm remove, pnpm rm, pnpm update, pnpm up, pnpm list, pnpm ls, pnpm outdated, pnpm why and every other pnpm subcommand; yarn install, yarn add; bun install, bun add, bun remove, bun test; deno test, deno lint, deno check; jest, vitest, mocha, cypress run, playwright, tsc, eslint, prettier, next build, prisma; webpack, webpack-cli, vite, rollup, esbuild (the emitted files as their count and the largest three) | | JVM | mvn, mvnd, gradle, gradlew, sbt | | Ruby | rake test, rails test, ruby (a minitest file), rspec, rubocop, bundle install, bundle update | | PHP | php -l, phpunit, pest, paratest, artisan test, phpstan analyse, phpstan analyze | | .NET | dotnet build, dotnet test, dotnet format, dotnet publish, dotnet pack, dotnet restore | | Apple | swift build, swift test, xcodebuild | | Files and system | ls, and ls -R as one line per directory; cp, mv, rm, ln with -v (every error, the first five paths and the count), also as gcp, gmv, grm, gln; find, grep, egrep, rg, ast-grep, tree, env and printenv (credential values masked), ps | | Containers | docker ps, docker images, docker image ls, docker logs, docker build, docker pull, docker inspect, docker compose (ps, logs and the rest); kubectl get, kubectl logs, kubectl describe; oc get, oc logs; helm list | | Clouds and network | aws (aws s3 ls as a capped list, the rest as JSON), gcloud; terraform plan, terraform apply, tofu plan, tofu apply; pulumi; curl, wget | | make | make, gmake: make's directory lines and the compiler source excerpts go, and the line each runner writes for a passing test (go test -v, cargo test, pytest -v, vitest --reporter=verbose, claude plugin test) reads as one count; every failure, summary and other line stays | | Built-in rules | gcc, g++, cc, c++, clang, clang++ (also with a version suffix such as gcc-14); cmake, cmake --build; brew install, upgrade, reinstall, update, tap, bundle; rsync; df; du; ping, ping6; shellcheck |

  • A command started through a runner counts as the command it starts: npx, bunx, pnpx, pnpm exec and dlx, npm exec and x, uv run, poetry run, pipenv run, bundle exec, python -m, python3 -m, php artisan. An absolute path (/usr/bin/git) counts as its base name, and git -C <dir> as git.
  • Every other command gets the generic cleanup: colour codes, carriage-return redraws and repeated lines go.
  • cat, head and tail of a file are never filtered, because the model asked for exactly those lines.

Measured saving

Measured on Claude Code 2.1.282 with Claude Opus 5.5 and bash-diet 0.1.2. The sample repository holds Go, Rust, Node, Python, Gradle, .NET, Swift, Ruby, PHP and C projects, each with one failing test or build error. A headless session ran the same 35 commands in order: git, builds, tests, linters, package lists, file listings and searches, docker ps and images, env, ps, df, du. It ran three times with the mod and three times without it, and the figures are the medians of the three runs.

| | Without the mod | With the mod | Saving | |---|---|---|---| | Characters of the 35 Bash results | 79,555 | 33,366 | 58% | | Context tokens the 35 results added | 38,277 | 20,653 | 46% | | Context at the session's end | 107,946 | 90,557 | 16% | | Input tokens over all requests | 2,856,172 | 2,512,370 | 12% | | Session cost | $1.00 | $0.78 | 21% |

  • A result's tokens are how much the context grew from the request that ran the command to the next one, minus that request's output tokens. That count includes about 100 tokens for the call itself, which no filter can shrink.
  • The session's own prompt, tools and instructions are the same in both runs, so the saving over the whole session is smaller than the saving on the results.

The context tokens of the 35 results, by family. Each figure is the sum of the family's per-command medians.

| Family | Commands run | Without the mod | With the mod | Saving | |---|---|---|---|---| | git | git status, git diff, git log, git branch -a, git show --stat | 1,598 | 890 | 44% | | Go | go build, go vet, go test | 308 | 226 | 27% | | Rust | cargo build, cargo clippy, cargo test | 1,682 | 923 | 45% | | Node | npm install, npx tsc, npx vitest run, npm ls | 1,191 | 1,012 | 15% | | Python | pytest, python3 -m pip list | 1,635 | 1,287 | 21% | | Gradle | gradle build, gradle test | 757 | 540 | 29% | | .NET | dotnet build, dotnet test | 1,221 | 697 | 43% | | Swift | swift build, swift test | 1,443 | 915 | 37% | | Ruby | rake test | 1,092 | 206 | 81% | | PHP | php -l | 112 | 103 | 8% | | C | make | 281 | 273 | 3% | | Files | ls -la, find -name, grep -rn | 6,974 | 2,384 | 66% | | Containers | docker ps -a, docker images | 10,423 | 2,270 | 78% | | System | env, ps aux, df -h, du -sh | 9,560 | 8,927 | 7% | | Total | 35 commands | 38,277 | 20,653 | 46% |

  • The smallest savings are on env (the filter only masks credential values), php -l, make and go vet: their output is already a few lines, and most of their count is the call's own 100 tokens.

The filters added after that session were measured with one run each in a scratch project, in characters of the result:

| Command | Without the mod | With the mod | Saving | |---|---|---|---| | flake8 | 2,091 | 775 | 63% | | pylint | 2,898 | 1,049 | 64% | | gofmt -d | 328 | 56 | 83% | | black --check --diff | 1,104 | 286 | 74% | | webpack | 779 | 117 | 85% | | vite build (a parse error) | 1,562 | 291 | 81% | | esbuild (a parse error) | 1,044 | 109 | 90% | | rollup (a parse error) | 1,554 | 178 | 89% | | mocha | 897 | 455 | 49% | | cypress run | 5,517 | 327 | 94% | | make check of this mod (lint, typecheck, validate, 129 tests) | 15,131 | 1,684 | 89% | | make test running go test -v | 563 | 307 | 45% | | make test running pytest -v | 1,382 | 928 | 33% |

Your own rules

A command no filter knows can get a rule of yours. Rules live in two files:

  • ~/.claude/bash-diet/filters.json, for every project. It runs as it is.
  • <repository>/.bash-diet/filters.json, for one project. It runs only after /bash-diet trust, and it stops again when its content changes, because a file that came with a cloned repository could hide output from the model.

Your rule comes before the mod's own filter for the same command. The steps run in this order, and each one is optional:

{
  "filters": {
    "deploy": {
      "description": "the deploy script: only the steps and the result",
      "match_command": "^\\./scripts/deploy\\.sh( |$)",
      "strip_ansi": true,
      "replace": [{ "pattern": "\\d+ms", "replacement": "Nms" }],
      "match_output": [{ "pattern": "nothing to deploy", "message": "deploy: nothing to do", "unless": "(?i)error" }],
      "keep_lines_matching": ["^(step|error|done)"],
      "truncate_lines_at": 200,
      "head_lines": 20,
      "tail_lines": 10,
      "max_lines": 40,
      "on_empty": "deploy: done"
    }
  }
}
  • match_command is a JavaScript regex over the command's words, after variables and wrappers. A leading (?i) ignores case.
  • strip_lines_matching drops the lines it matches, keep_lines_matching keeps only those. A rule takes one of the two.
  • match_output answers with message alone when the whole output matches pattern and does not match unless.
  • head_lines and tail_lines keep both ends with a count between them. max_lines then caps the lines.

A file with a mistake still keeps its good rules, and one transcript line names every mistake. /bash-diet filters lists both files, their rules and the built-in rules.

Command

/bash-diet                               on or off, the excludes, and this session's saving
/bash-diet on | off                      on by default
/bash-diet exclude <prefix | ^regex>     that command runs unfiltered; excludes lists them, include takes one back
/bash-diet filters                       the rule files, their rules, the built-in rules
/bash-diet trust | untrust               lets this repository's .bash-diet/filters.json run, or stops it
/bash-diet gain                          the saving of the last 90 days, the families that saved most
/bash-diet gain project | daily | graph | history
/bash-diet cost                          this session's spend, and what the tokens kept out would have cost
/bash-diet discover [days] [all]         the output the model read in earlier sessions, by filter, and the commands no filter reads
/bash-diet learn [days] [write]          commands that failed on a CLI mistake and the form that worked after them
  • gain reads the records in ~/.claude/bash-diet/gain/, one file per session and day, kept for 90 days. Each report gives the measured characters before and after. The token figure is an estimate at four characters per token; history and graph give characters only.
  • cost prices the tokens kept out of the context at the model's list prices of September 2026: once at the cache write rate, and again at the cache read rate for each later request.
  • discover and learn read this project's transcripts of the last 30 days by default. discover all reads every project's; it answers at once, and its report follows as a transcript line.
  • learn counts only a single command that failed on an unknown flag, a missing command, a missing argument or a syntax error, followed within three calls by a similar command that worked. learn write writes the pairs to .claude/rules/cli-corrections.md in the repository, which the model reads in later sessions. A command that may carry a credential is never written.

Install

claude plugin marketplace add KilimcininKorOglu/claude-code-mods
claude plugin install bash-diet@kilimcininkoroglu-mods

Function hooks are early access. Claude Code 2.1.288 and later load them by default, so there is nothing to switch on.

After installing

  1. Restart Claude Code.
  2. If you use another tool that rewrites Bash commands for the same purpose, turn it off, so each output is filtered once.
  3. To keep a project's own rules, write .bash-diet/filters.json and run /bash-diet trust in that project.

What it can reach

Validated with claude plugin validate on Claude Code 2.1.283:

❯ ./register.ts hooks: session.start, classic.SessionStart, command.run{command=bash-diet}, tool.call{tool=Bash}, tool.call{tool=?}
❯ ./register.ts calls: $.clock.now (via gainCommand, pruneGain, pruneRecall, recordGain, transcriptsOf), $.command.register, $.env.get (via locate, recallDir), $.fs.exists (via gainFiles, refreshFile, transcriptDirs), $.fs.list (via gainFiles, pruneRecall, transcriptDirs, transcriptsOf), $.fs.read (via gainCommand, refreshFile, seedGain, wholeText), $.fs.stat (via pruneRecall, refreshFile, transcriptsOf), $.fs.write (via keepFull, recordGain, writeLearned), $.process.run (via locate, pruneGain, pruneRecall, recallDir, recordGain, writeLearned), $.process.spawn (via callsIn), $.session.id, $.session.model (via costCommand), $.session.root (via locate), $.session.usage (via costCommand), $.sidebar.set (via showGain), $.store.get (via readSettings), $.store.set (via setEnabled, setExcludes, setTrusted), $.tool.check (via withPlanFlags), $.ui.log (via activeRules, discoverAll, refreshFile, report), $.ui.status (via showGain)

Reach L2: it writes files and runs processes.

1. Reads:    each Bash command and its output; the result of each Playwright MCP browser tool; the two filters.json files; this session's model, spend and id; the transcripts under ~/.claude/projects for discover and learn
2. Runs:     the model's own Bash command, with a flag that shortens its output added when the permission check allows it; git rev-parse, mkdir, rm (of its own files only) and cat (of transcripts)
3. Sends:    the filtered result to the model in place of the output, and each Playwright result without its code echo; nothing leaves the machine
4. Persists: full outputs in $TMPDIR/bash-diet (200 files, 30 days); saving records in ~/.claude/bash-diet/gain (90 days); .claude/rules/cli-corrections.md on learn write; in $.store, on/off, the excludes and the trusted rule file hashes
5. Hostile input: a command's output only passes through regexes and JSON.parse, and is never run; a project rule file runs only after /bash-diet trust and only while its SHA-256 matches; env values of credential-like names are masked

Limits

  • A filter reads the output's known shape. A tool that changes its output format can make a filter keep less than it should; the full output file and BASH_DIET_RAW=1 are your way back.
  • The middle of a failed command's output over 10,000 characters is dropped by Claude Code before the mod ever sees it. The mod cannot bring it back; it only tells you it was cut.
  • A backgrounded command (run_in_background) is not filtered, because its result is a task id.
  • A command inside $(...), a heredoc or a process substitution, or one whose output is redirected to a file, is not filtered.
  • A chain of several printing commands gets only the generic cleanup (colour codes, carriage-return redraws, repeated lines).
  • output-flood 0.3.0 and later measure the filtered result, whichever order the two mods load in. An older output-flood loaded after bash-diet measures the output before the filter, and its note names a size the model never read.

Development

make install     # eslint, typescript-eslint, typescript
make lint        # complexity limit 10, the build fails above it
make typecheck   # needs .claude/types/ from /plugin-types
make validate
make test        # claude plugin test

비슷한 프로젝트