CLAUDE_CODE_WARN_MEMORY_FREE_GIB

環境変数

Linux と WSL において、4 のような GiB 単位の整数を設定すると、利用可能なメモリがその量を下回ったときに、Claude Code が Claude に警告する。警告は利用可能なメモリ量を伝えるシステムリマインダーである。変数が未設定、0、または数字のみでない場合、リマインダーは無効になる。settings の env ブロック経由で渡されたコピーは無視されるため、Claude Code を起動する環境に設定すること。Claude Code v2.1.304 以降が必要

使い方・用途

  • WSL や Linux 上で Claude Code を長時間実行している際にメモリ枯渇で動作が不安定になる前に検知したい
  • 使用可能メモリがしきい値を下回ったことを Claude 自身に知らせ、メモリを消費する操作を避けさせたい
  • settings ファイルの env ブロックではなく起動環境で設定すべき変数であることを理解し、正しく有効化したい
英語原文

On Linux and WSL, set to a whole number of GiB such as 4 to have Claude Code warn Claude when available memory falls below that amount. The warning is a system reminder saying how much is available. The reminder is off when the variable is unset, 0, or not plain digits. Set it in the environment that launches Claude Code, since Claude Code ignores a copy delivered through a settings env block. Requires Claude Code v2.1.304 or later

関連ドキュメント