bash-diet

Reviewed at commit 0b58bb9 New version, not yet reviewed

Caution: Saves the full output of shortened Bash commands, which can include secrets, to $TMPDIR/bash-diet outside your project and keeps it for up to 30 days.

Shrinks each Bash result before the model reads it: per-command filters for git, test runners, linters, package managers, containers and file tools, the full…

Made by
Kerem Gok
What we checked

Shortens what Claude reads from Bash commands such as git, test runners, linters, package managers and file listings, and adds a path to the full output, which it saves in a temp folder outside your project for up to 30 days. It can add small format flags (git log -N, pytest -q) and shows the savings in the sidebar or status line. No network calls; savings counts go in ~/.claude/bash-diet/gain.

Review details

Static review of the source at the pinned commit; not run. Registers session.start (reads settings, locates the repository with git rev-parse, registers the /bash-diet command, prunes old files), classic.SessionStart (adds a fixed note to Claude's context explaining the filtering and the BASH_DIET_RAW=1 escape), command.run for /bash-diet, tool.call for Bash, and tool.call for Playwright MCP browser tools (removes the echoed code section from their results). For a Bash call that is not backgrounded, opaque (heredoc, substitution, subshell, redirect to a file) or raw, it runs a pure filter from its tables, built-in rules or the user's rules and replaces stdout/stderr when the saving is large enough; it reads Claude Code's own persisted-output file with $.fs.read when the result was cut. When a filter leaves lines out, the full output is written with $.fs.write to $TMPDIR/bash-diet/<hash>.log (or /tmp/bash-diet), pruned to 200 files and 30 days with rm -f; env/printenv output with masked credential values gets no file. It may add flags to git log (-N) and pytest (--tb=short -q), but only when $.tool.check gives the same permission decision for the changed command as for the original. Project rule files (.bash-diet/filters.json) only run after /bash-diet trust and only while their SHA-256 matches; rules are data (regexes, line counts), no code. Gain records (time, project name, command family, character counts; no output) go to <CLAUDE_CONFIG_DIR or ~/.claude>/bash-diet/gain/*.jsonl, kept 90 days. On request, /bash-diet discover and learn read Claude Code transcripts in ~/.claude/projects (this project's, or every project's with discover all) through cat via $.process.spawn and only report counts and corrected commands; learn write writes .claude/rules/cli-corrections.md in the repository and skips commands containing token, secret, password or key words. Settings (on/off, excludes, trusted rule hashes) in $.store. Uses $.process.run (mkdir, rm, git), $.process.spawn (cat), $.fs, $.env (TMPDIR, HOME, CLAUDE_CONFIG_DIR), $.sidebar.set, $.ui.status, $.ui.log, $.session.model/usage for /bash-diet cost. No network calls, no model calls, no eval. Read fully: manifests, register.ts, command.ts, dsl.ts, history.ts, pipeline.ts, recall.ts, gain.ts, text.ts, shell.ts, rules.ts, playwright.ts, pricing.ts, builtin-rules.ts, filters/common.ts, generic.ts, index.ts and the env filter in system.ts; the remaining filter files (pure text transforms) were checked by targeted search for runtime calls, imports, network, eval and flag additions. eslint.config.js and Makefile are not loaded by the plugin.

What it uses
  • Reads your prompts: no
  • Sees tool calls: yes
  • Blocks or changes tool calls: yes
  • Reads or writes files: yes
  • Runs programs on your machine: yes
  • Calls the model (uses tokens): no
  • Sends data over the network: no
  • Stores data: yes
  • Shows something on screen: yes
Hooked events

Shrinks each Bash result before the model reads it: per-command filters for git, test runners, linters, package managers, containers and file tools, the full output kept in a file.

Made this mod? Add a badge to your README

modsforClaude badge for bash-diet

Paste this into your README. The badge says reviewed once the current version has been reviewed, and links readers to this page.

[![Listed on modsforClaude](https://modsforclaude.com/badge/bash-diet.svg)](https://modsforclaude.com/mods/bash-diet/)

← All mods