環境変数

CLAUDE_SUBAGENT_BG_SHELL_MAX_MS

サブエージェントが起動したバックグラウンドのシェルコマンドの最大生存期間(ミリ秒単位)を設定し、これを超えるとClaude Codeがそのコマンドを強制終了します(Claude Code v2.1.133以降が必要です)。

使い方・用途

  • サブエージェントが開始したバックグラウンドプロセスが、意図せず無期限に走り続けてリソースを消費するのを防ぎたい場合に使用します
  • デフォルト値は 3600000 ミリ秒(60分)で、0 を設定しても制限は無効化されず、デフォルトの60分制限が適用されます
  • この制限はメインセッションのバックグラウンドコマンドには適用されません
英語原文(公式ドキュメントより)

Maximum lifetime in milliseconds for a background shell command that a subagent started, after which Claude Code terminates the command. Default 3600000 (60 minutes). Setting 0 doesn't disable the cap: Claude Code applies the 60-minute default instead. Claude Code doesn't apply a lifetime cap to background commands in the main session; CLAUDE_CODE_DISABLE_BG_SHELL_PRESSURE_REAP covers the separate memory-pressure limit that applies to them. Requires Claude Code v2.1.133 or later