コンテキストエンジニアリングレイヤー
AI コーディングのための。
lean-ctx は 3 つの独立したレイヤーで構成される圧縮システムです。コンテキストサーバーは AI のファイル読み取りを AST 認識型の圧縮バージョンに置き換えます。シェルフックは 95 以上の CLI コマンドパターンをインターセプトします。3 つの通信プロトコルは AI がより効率的に応答するよう学習させます。一度インストールすれば、あとはすべて自動です。
lean-ctx は どこに位置するのか?
lean-ctx は 2 つのレベルで介入します:コンテキストレイヤー(ファイル読み取り、コード検索、シェルコマンド)とシェルレイヤー(生の CLI 出力)。どちらも LLM に到達する前にデータを圧縮します。AI は同じ情報をわずかな token で受け取ります。
Without lean-ctx: You → AI Tool → reads file (full content) → LLM processes everything With lean-ctx: You → AI Tool → lean-ctx compresses → signal only → LLM: 60–99% less noise ├─ PathJail sandbox + size caps ├─ AST-aware compression ├─ Memory Runtime (knowledge + forgetting) ├─ Session cache (re-read ≈ 13 tok) └─ 10 read modes per file type
あなた
普段通りにコーディング。ワークフローの変更は不要。
AI ツール
Cursor、Claude Code、Copilot、Windsurf、…
lean-ctx
コンテキストサーバーとシェルフックですべてを圧縮。
LLM
シグナルのみを受け取る。60〜90% 少ない token で同じ情報。
では あなた が実際にすることは?
ほぼ何もありません。lean-ctx は一度のセットアップ後、見えないところで動作します。以前と全く同じようにコーディングを続けてください。
インストール
単一の Rust バイナリ。依存関係なし、クラウドなし、アカウント不要。
curl -fsSL leanctx.com/install.sh | sh セットアップ
シェルと AI ツールを自動検出。数秒ですべてを設定。
lean-ctx setup ステップ 3 はありません
普段通りにコーディング。AI が圧縮ツールを自動的に使用します。
削減された token: 自動的にあなた vs. マシン
| あなたがすること(一度だけ) | 自動で実行されること |
|---|---|
| lean-ctx setup | AI は Read の代わりに ctx_read を使用 - 最大 99% の token 削減(cache 再読み込み時) |
AI は Shell の代わりに ctx_shell を使用 - 60〜90% の token 削減 | |
AI は Grep の代わりに ctx_search を使用 - 50〜80% の token 削減 | |
| シェルフックが CLI 出力を透過的に圧縮 | |
| セッション cache が読み取り間でファイルを記憶(再読み込みは約 13 token) | |
| lean-ctx gain (オプション) | 累計削減ダッシュボードを表示 |
セットアップガイド全文 → はじめに · すべての CLI コマンド → CLI リファレンス
Reciprocal Rank Fusion (RRF) Cache Eviction
When the session cache is full, lean-ctx uses Reciprocal Rank Fusion to decide which entries to evict. Each signal (recency, frequency, size) is ranked independently, then fused into a single score - no arbitrary weight tuning required.
Formula: RRF(d) = Σ 1/(K + rank_i(d)) where K=60. This handles signal incomparability (seconds vs counts vs tokens) without needing tuned weights, unlike traditional weighted combinations.
Want to understand the architecture?
Explore the Context OS: the six-step pipeline, integration modes, agent matrix, Context Field Theory, and nine architectural pillars that make lean-ctx work.
Deep dive into Context OSSecurity Layer
lean-ctx enforces a defense-in-depth security model to prevent LLM prompt injection from accessing files outside the project:
- PathJail - All file operations are sandboxed to the project root. Symlink traversal,
../escapes, and absolute paths outside the jail are blocked at theresolve_pathchokepoint. - Bounded Shell Capture - Shell output is capped at 200KB with clear truncation markers. Prevents memory exhaustion from runaway commands.
- TOCTOU Prevention - File edits use same file handle for read-verify-write, eliminating time-of-check-to-time-of-use race conditions.
- Build Integrity - Compile-time integrity seed and hash verification detect tampered binaries. Checked automatically by
lean-ctx doctor.