Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

refactor(commit-generation): drop the CLAUDECODE= nesting workaround (#2979)

Maximilian Roos7d16e63fad0f
diff --git a/Taskfile.yaml b/Taskfile.yaml
index 53b4d0a54..0c3b439d2 100644
--- a/Taskfile.yaml
+++ b/Taskfile.yaml
@@ -408,7 +408,7 @@ tasks:
# Documented commands from llm-commits.md
declare -A COMMANDS
- COMMANDS["claude"]='CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='"'"''"'"' --disable-slash-commands --setting-sources='"'"''"'"' --system-prompt='"'"''"'"''
+ COMMANDS["claude"]='MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='"'"''"'"' --disable-slash-commands --setting-sources='"'"''"'"' --system-prompt='"'"''"'"''
COMMANDS["llm"]='llm -m claude-haiku-4.5'
COMMANDS["aichat"]='aichat -m claude:claude-haiku-4.5'
COMMANDS["codex"]='codex exec -m gpt-5.4-mini -c model_reasoning_effort='"'"'low'"'"' -c system_prompt='"'"''"'"' --sandbox=read-only --json - | jq -sr '"'"'[.[] | select(.item.type? == "agent_message")] | last.item.text'"'"''
diff --git a/dev/config.example.toml b/dev/config.example.toml
index b46eb2e10..ab42ace4e 100644
--- a/dev/config.example.toml
+++ b/dev/config.example.toml
@@ -60,7 +60,7 @@
# ### Claude Code
#
# [commit.generation]
-# command = "CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
+# command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
#
# ### Codex
#
diff --git a/docs/content/config.md b/docs/content/config.md
index 9dbbf996c..5a06cd780 100644
--- a/docs/content/config.md
+++ b/docs/content/config.md
@@ -45,7 +45,7 @@ Organizations can deploy a system-wide config file for shared defaults — run `
worktree-path = ".worktrees/{{ branch | sanitize }}"
[commit.generation]
-command = "CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
+command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
```
**Project config** — shared team settings:
@@ -137,7 +137,7 @@ Generate commit messages automatically during merge. Requires an external CLI to
```toml
[commit.generation]
-command = "CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
+command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
```
### Codex
diff --git a/docs/content/llm-commits.md b/docs/content/llm-commits.md
index 3749ae161..ca0e9b62f 100644
--- a/docs/content/llm-commits.md
+++ b/docs/content/llm-commits.md
@@ -24,10 +24,10 @@ Any command that reads a prompt from stdin and outputs a commit message works. A
```toml
[commit.generation]
-command = "CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
+command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
```
-`CLAUDECODE=` unsets the nesting guard so `claude -p` works from within a Claude Code session. `--no-session-persistence` prevents the commit conversation from polluting `claude --continue`. The other flags disable tools, skills, settings, and system prompt for fast text-only output. See [Claude Code docs](https://docs.anthropic.com/en/docs/build-with-claude/claude-code) for installation.
+`--no-session-persistence` prevents the commit conversation from polluting `claude --continue`. The other flags disable tools, skills, settings, and system prompt for fast text-only output. See [Claude Code docs](https://docs.anthropic.com/en/docs/build-with-claude/claude-code) for installation.
### Codex
diff --git a/skills/worktrunk/reference/config.md b/skills/worktrunk/reference/config.md
index 8572e4442..dac86f2bc 100644
--- a/skills/worktrunk/reference/config.md
+++ b/skills/worktrunk/reference/config.md
@@ -44,7 +44,7 @@ Organizations can deploy a system-wide config file for shared defaults — run `
worktree-path = ".worktrees/{{ branch | sanitize }}"
[commit.generation]
-command = "CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
+command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
```
**Project config** — shared team settings:
@@ -136,7 +136,7 @@ Generate commit messages automatically during merge. Requires an external CLI to
```toml
[commit.generation]
-command = "CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
+command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
```
### Codex
diff --git a/skills/worktrunk/reference/llm-commits.md b/skills/worktrunk/reference/llm-commits.md
index 66ff61a1a..153c1ecd0 100644
--- a/skills/worktrunk/reference/llm-commits.md
+++ b/skills/worktrunk/reference/llm-commits.md
@@ -10,10 +10,10 @@ Any command that reads a prompt from stdin and outputs a commit message works. A
```toml
[commit.generation]
-command = "CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
+command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
```
-`CLAUDECODE=` unsets the nesting guard so `claude -p` works from within a Claude Code session. `--no-session-persistence` prevents the commit conversation from polluting `claude --continue`. The other flags disable tools, skills, settings, and system prompt for fast text-only output. See [Claude Code docs](https://docs.anthropic.com/en/docs/build-with-claude/claude-code) for installation.
+`--no-session-persistence` prevents the commit conversation from polluting `claude --continue`. The other flags disable tools, skills, settings, and system prompt for fast text-only output. See [Claude Code docs](https://docs.anthropic.com/en/docs/build-with-claude/claude-code) for installation.
### Codex
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index 6ca07408d..c3d47f49b 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -1617,7 +1617,7 @@ Organizations can deploy a system-wide config file for shared defaults — run `
worktree-path = ".worktrees/{{ branch | sanitize }}"
[commit.generation]
-command = "CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
+command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
```
**Project config** — shared team settings:
@@ -1709,7 +1709,7 @@ Generate commit messages automatically during merge. Requires an external CLI to
```toml
[commit.generation]
-command = "CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
+command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
```
### Codex
diff --git a/src/llm.rs b/src/llm.rs
index 98e61cc81..e60c24bb9 100644
--- a/src/llm.rs
+++ b/src/llm.rs
@@ -364,18 +364,11 @@ pub(crate) fn execute_llm_command(command: &str, prompt: &str) -> anyhow::Result
}
let shell = ShellConfig::get()?;
- // TODO(claude-code-nesting): Claude Code sets CLAUDECODE=1 and blocks nested
- // invocations, even non-interactive `claude -p`. Remove this env_remove if
- // Claude Code relaxes the check for non-interactive mode. If they don't fix
- // it, replace with a deprecation warning + config.new migration to have users
- // add `CLAUDECODE=` to their command string themselves.
- // https://github.com/anthropics/claude-code/issues/25803
let output = Cmd::new(shell.executable.to_string_lossy())
.args(&shell.args)
.arg(command)
.external("commit.generation")
.stdin_bytes(prompt)
- .env_remove("CLAUDECODE")
.run()
.context("Failed to spawn LLM command")?;
diff --git a/src/output/commit_generation.rs b/src/output/commit_generation.rs
index bcd0c2935..302cc8e2b 100644
--- a/src/output/commit_generation.rs
+++ b/src/output/commit_generation.rs
@@ -258,7 +258,7 @@ mod tests {
#[test]
fn test_llm_tool_recommended_config() {
- assert_snapshot!(LlmTool::Claude.recommended_config(), @"CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''");
+ assert_snapshot!(LlmTool::Claude.recommended_config(), @"MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''");
assert_snapshot!(LlmTool::Codex.recommended_config(), @r#"codex exec -m gpt-5.4-mini -c model_reasoning_effort='low' -c system_prompt='' --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == "agent_message")] | last.item.text'"#);
assert_snapshot!(LlmTool::OpenCode.recommended_config(), @"opencode run -m anthropic/claude-haiku-4.5 --variant fast");
}
@@ -317,7 +317,7 @@ mod tests {
// Long commands stay as single-line TOML
let cmd = LlmTool::Claude.recommended_config();
let result = format_command_for_display(cmd);
- assert_snapshot!(result, @r#""CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''""#);
+ assert_snapshot!(result, @r#""MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''""#);
}
#[test]
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_create.snap b/tests/snapshots/integration__integration_tests__help__help_config_create.snap
index 44dc88c43..0ff31b042 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_create.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_create.snap
@@ -127,7 +127,7 @@ Creates ~/.config/worktrunk/config.toml with the following content:
  # ### Claude Code
  #
  # [commit.generation]
-  # command = "CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
+  # command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
  #
  # ### Codex
  #
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_long.snap b/tests/snapshots/integration__integration_tests__help__help_config_long.snap
index 020b666de..3691ef6f9 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_long.snap
@@ -102,7 +102,7 @@ Organizations can deploy a system-wide config file for shared defaults — run 
  worktree-path = ".worktrees/{{ branch | sanitize }}"
 
  [commit.generation]
-  command = "CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
+  command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
Project config — shared team settings:
@@ -175,7 +175,7 @@ Generate commit messages automatically during merge. Requires an external CLI to
Claude Code
  [commit.generation]
-  command = "CLAUDECODE= MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
+  command = "MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
Codex