Shell Hook

95以上のコマンドパターン。
透過的な圧縮。

Shell HookはAIが見る前にCLI出力をインターセプトします。Gitの差分、npmのインストール、cargoのビルド、Dockerのログ - すべてが本質的な情報に圧縮されます。設定不要、覚えるエイリアスなし。

34+ コマンドカテゴリ 95+ 特定パターン 60–90% 出力削減率
フロー

動作の 仕組み。

Shell Hookはコマンドを透過的にラップします。AIには圧縮された出力が表示され、あなたの操作には何も変わりません。

1

コマンド

AIがgit statusを実行

2

フック

lean-ctxが出力をインターセプト

3

圧縮

パターンマッチによる削減

4

結果

AIがコンパクトな出力を取得

34以上のカテゴリ

すでに使っている すべてのツール。

lean-ctxは主要な開発者ツールすべての出力パターンを認識し、それぞれを専用のルールで圧縮します。

バージョン管理

git status git diff git log git branch git stash git remote

JavaScript / Node

npm install npm run npm test yarn pnpm tsc

Rust

cargo build cargo test cargo clippy cargo check cargo run

コンテナ&オーケストレーション

docker ps docker build docker logs kubectl get kubectl describe

Python

pip install pytest python -m poetry uv

システム&ユーティリティ

ls / find ps / top curl make env cat / head
ビフォー&アフター

その 違いを見る。

Shell Hookなし ~580 tokens
git status
On branch feature/auth
Your branch is ahead of 'origin/feature/auth'
by 3 commits.
  (use "git push" to publish your local
   commits)

Changes to be committed:
  (use "git restore --staged <file>..."
   to unstage)
        new file:   src/session.ts
        modified:   src/login.ts
        modified:   src/api.ts

Changes not staged for commit:
  (use "git add <file>..." to update
   what will be committed)
  (use "git restore <file>..." to
   discard changes in working directory)
        modified:   src/session.ts

Untracked files:
  (use "git add <file>..." to include
   in what will be committed)
        src/session.test.ts
Shell Hook使用時 ~75 tokens
git status (compressed)
feature/auth ↑3
staged: +session.ts ~login.ts ~api.ts
unstaged: ~session.ts
untracked: session.test.ts
[534 tok saved (87%)]
その他の例

すべてのコマンドが 圧縮される。

npm install - 未圧縮 ~420 tokens
npm install
npm warn deprecated inflight@1.0.6:
  This module is not supported...
npm warn deprecated glob@7.2.3:
  Glob versions prior to v9...
npm warn deprecated rimraf@3.0.2:
  Rimraf versions prior to v4...

added 847 packages, and audited
848 packages in 12s

127 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm install - 圧縮後 ~35 tokens
npm install (compressed)
 847 packages 12s
 3 deprecated (inflight, glob, rimraf)
0 vulnerabilities
[385 tok saved (92%)]
cargo build - 未圧縮 ~310 tokens
cargo build
   Compiling proc-macro2 v1.0.86
   Compiling unicode-ident v1.0.12
   Compiling syn v2.0.72
   Compiling serde_derive v1.0.204
   Compiling serde v1.0.204
   Compiling tokio v1.39.2
   Compiling lean-ctx v2.1.0
    Finished `dev` profile [unoptimized
    + debuginfo] target(s) in 24.3s
cargo build - 圧縮後 ~30 tokens
cargo build (compressed)
 build dev 24.3s
7 crates compiled
[280 tok saved (90%)]

独立して動作

Shell Hookはコンテキストサーバーとは独立して動作します。まだ設定されていないAIツールも、圧縮されたシェル出力の恩恵を受けます。フックはシェルレベルでインターセプトするため、コマンドを実行するすべてのツールが削減効果を得ます。

Cursor Claude Code GitHub Copilot Aider Any shell-based AI
カバレッジ

パターンカバレッジを 一目で確認。

34+
コマンドカテゴリ
95+
特定パターン
87%
平均git圧縮率
0
設定は不要

Docker & Container Environments

In containers, non-interactive shells skip ~/.bashrc. Set BASH_ENV to point at lean-ctx's dedicated env.sh file, which has no interactive-mode guard. For Claude Code, also set CLAUDE_ENV_FILE.

# In your Dockerfile:
ENV BASH_ENV="/root/.lean-ctx/env.sh"
ENV CLAUDE_ENV_FILE="/root/.lean-ctx/env.sh"

lean-ctx includes self-healing: if the env.sh file is removed (e.g., by a container rebuild), lean-ctx init --global re-creates it automatically.

完全な出力が必要ですか? rawモードを使用。

非圧縮出力が必要な場合は、1つのフラグで圧縮をバイパスできます。サイレントなデータ損失はありません - 切り詰めは常に透過的です。

# CLI flag - skip compression for one command
lean-ctx -c --raw kubectl get pods -o yaml

# Shell function - quick bypass
lean-ctx-raw gh pr view 42

# Kill-switch - disable ALL compression
LEAN_CTX_DISABLED=1 lean-ctx -c git log

# MCP parameter - for AI agents
ctx_shell(command="cat config.json", raw=true)

すべてのコマンドで 節約を開始。

1つのセットアップコマンドでShell Hookが有効化。以降のすべてのAIコマンドが自動的に圧縮されます。