環境変数

CLAUDE_CODE_DISABLE_BG_SHELL_PRESSURE_REAP

1 を設定すると、メモリ圧迫時にも Claude Code がバックグラウンドシェルコマンドを終了させなくなる。デフォルトでは、macOS と Linux において、オペレーティングシステムが危険なメモリ圧迫を報告し、セッションがターンやサブエージェントの実行なしに 30 分間アイドル状態だった場合、Claude Code はバックグラウンドシェルを終了させる。Windows にはメモリ圧迫のシグナルがないため、この変数は Windows では効果がない。Claude Code v2.1.193 以降が必要。

使い方・用途

  • macOS や Linux でメモリ圧迫時にアイドル状態のバックグラウンドシェルが自動終了されるのを防ぎ、長時間実行するバックグラウンド処理を中断されたくない場合
  • アイドル状態のセッションでもバックグラウンドタスクを継続実行させておきたい場合
  • デバッグログでタスク停止理由を確認しつつ、メモリ圧迫による自動終了を無効化して運用したい場合
英語原文(公式ドキュメントより)

Set to 1 to stop Claude Code from terminating background shell commands under memory pressure. By default, on macOS and Linux, Claude Code terminates background shells when the operating system reports critical memory pressure and the session has been idle for 30 minutes with no turn or subagent running. Windows has no memory-pressure signal, so this variable has no effect there. Requires Claude Code v2.1.193 or later

関連ドキュメント

関連する変更履歴

v2.1.193(1件)

Added
アイドル状態のバックグラウンドシェルコマンドに対するメモリの自動解放機能を追加
英語原文を表示
Added automatic memory-pressure reaping for idle background shell commands (disable with CLAUDE_CODE_DISABLE_BG_SHELL_PRESSURE_REAP=1)

変更後

長時間 CLI を使用していてもリソースの枯渇を防ぎ、常に安定した動作環境を維持することができます。

関連ドキュメント