コンテキストプロファイルを使用すると、探索、デバッグ、ホットフィックス、CI、コードレビューなど、さまざまなシナリオに合わせてlean-ctxのコンテンツ処理方法を設定できます。"Context as Code" - チームで共有できるバージョン管理された戦略と考えてください。
プロファイルとは?
プロファイルは、読み取りモード、圧縮設定、トークン予算、パイプラインレイヤー、自律動作を制御するTOMLファイルです。プロファイルは他のプロファイルから継承し、特定のフィールドを上書きできます。
組み込みプロファイル
lean-ctxには一般的なワークフロー向けに最適化された5つの組み込みプロファイルが付属しています:
exploration
コードベース理解のための幅広いコンテキスト。マップモード、200Kトークン予算、キャッシュ優先。
bugfix
自動モードでの集中デバッグ。簡潔な出力、1 00Kトークン予算、10コールごとのチェックポイント。
hotfix
緊急修正のための最小コンテキスト。シグネチャモード、超コンパクト出力、30Kトークン、$1コスト上限。
ci-debug
200回のシェル呼び出しによるCI/CDデバッグ。簡潔な出力、150Kトークン予算。
review
読み取り専用の幅広いコンテキストによるコードレビュー。マップモード、コンパクトCRP、150Kトークン予算。
プロファイルの有効化
LEAN_CTX_PROFILE 環境変数を設定:
export LEAN_CTX_PROFILE=hotfix またはCLIで:
lean-ctx profile set hotfix またはMCP経由でランタイム時に切り替え:
ctx_session action=profile value=hotfix カスタムプロファイルの作成
.lean-ctx/profiles/(プロジェクトローカル)または ~/.lean-ctx/profiles/(グローバル)にプロファイルTOMLファイルを作成:
# .lean-ctx/profiles/my-team.toml
[profile]
name = "my-team"
inherits = "exploration"
description = "Team defaults with lower budget"
[read]
default_mode = "map"
max_tokens_per_file = 40000
[budget]
max_context_tokens = 120000
max_cost_usd = 2.0 またはCLIでプロファイルを作成:
lean-ctx profile create my-team --from exploration プロファイルの継承
inherits フィールドを使用して、任意の他のプロファイルから継承できます。子の値は親の値を上書きし、未設定のフィールドは親から継承されます。
# .lean-ctx/profiles/strict-review.toml
[profile]
name = "strict-review"
inherits = "review"
[budget]
max_context_tokens = 80000
max_cost_usd = 1.0 プロファイルスキーマ
完全なプロファイルには以下のセクションがあります:
- [profile] - name, inherits, description
- [read] - default_mode, max_tokens_per_file, prefer_cache
- [compression] - crp_mode, output_density, entropy_threshold
- [budget] - max_context_tokens, max_shell_invocations, max_cost_usd
- [pipeline] - intent, relevance, compression, translation(ブールトグル)
- [autonomy] - auto_dedup, checkpoint_interval
CLIリファレンス
lean-ctx profile list- 利用可能なすべてのプロファイルを表示lean-ctx profile show <name>- プロファイルの詳細を表示lean-ctx profile diff <a> <b>- 2つのプロファイルを比較lean-ctx profile create <name>- 新しいプロファイルを作成lean-ctx profile set <name>- 有効化手順を表示
解決順序
プロファイルは以下の順序で解決されます:
LEAN_CTX_PROFILE環境変数- プロジェクトローカル
.lean-ctx/profiles/<name>.toml - グローバル
~/.lean-ctx/profiles/<name>.toml - 組み込みデフォルト