環境変数

CLAUDE_CODE_AUTO_COMPACT_WINDOW

オートコンパクトのウィンドウ、つまりコンパクションが実行される前にコンテキストがどれだけ満たされるかを、100000から1000000トークンの範囲で設定する。200k のような接尾辞付きの値は v2.1.304 以降が必要である。ウィンドウを設定する他の方法より優先させる方法や、ステータスラインの used_percentage への影響については、Set the auto-compact window を参照。

使い方・用途

  • スクリプトやクラウド環境で、コマンドや設定ファイルを使わずに自動コンパクトの発動タイミングを制御したいときに使う
  • モデルごとの既定の自動コンパクト閾値より手前でコンパクトを発動させ、コンテキスト消費を抑えたい場合に使う
  • /autocompact や --autocompact や autoCompactWindow より優先度の高い指定方法として、セッション単位で確実にウィンドウサイズを上書きしたいときに使う
英語原文(公式ドキュメントより)

Set the auto-compact window, how full the context gets before compaction, from 100000 to 1000000 tokens. Suffixed values such as 200k require v2.1.304 or later. For precedence over the other ways to set the window and the effect on the status line's used_percentage, see Set the auto-compact window

関連する変更履歴

v2.1.304(1件)

Fixed
CLAUDE_CODE_AUTO_COMPACT_WINDOW=200k が黙って 100K のウィンドウを設定する問題を修正:この変数は --autocompact と同様に k と M の接尾辞を受け付けるようになり、範囲外または無視される値に対して警告を出す
英語原文を表示
Fixed CLAUDE_CODE_AUTO_COMPACT_WINDOW=200k silently setting a 100K window: the variable now accepts k and M suffixes like --autocompact, and warns when a value is out of range or ignored

関連ドキュメント