mirror of
https://github.com/max-sixty/worktrunk.git
synced 2026-09-14 20:00:38 +08:00
fix: add --no-session-persistence to Claude commit generation (#1454)
Without this flag, `claude -p` saves the commit generation conversation to session history. When the user later runs `claude --continue`, it resumes that ephemeral commit session instead of their previous working session. > _This was written by Claude Code on behalf of @max-sixty_ --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -385,7 +385,7 @@ tasks:
|
||||
|
||||
# Documented commands from llm-commits.md
|
||||
declare -A COMMANDS
|
||||
COMMANDS["claude"]='MAX_THINKING_TOKENS=0 claude -p --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.1-codex-mini -c model_reasoning_effort='"'"'low'"'"' --sandbox=read-only --json - | jq -sr '"'"'[.[] | select(.item.type? == "agent_message")] | last.item.text'"'"''
|
||||
|
||||
@@ -53,7 +53,7 @@ Organizations can also deploy a system-wide config file for shared defaults —
|
||||
worktree-path = ".worktrees/{{ branch | sanitize }}"
|
||||
|
||||
[commit.generation]
|
||||
command = "MAX_THINKING_TOKENS=0 claude -p --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:
|
||||
|
||||
@@ -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 --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
|
||||
command = "CLAUDECODE= 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. 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.
|
||||
`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.
|
||||
|
||||
### Codex
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ Organizations can also deploy a system-wide config file for shared defaults —
|
||||
worktree-path = ".worktrees/{{ branch | sanitize }}"
|
||||
|
||||
[commit.generation]
|
||||
command = "MAX_THINKING_TOKENS=0 claude -p --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:
|
||||
|
||||
@@ -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 --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
|
||||
command = "CLAUDECODE= 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. 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.
|
||||
`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.
|
||||
|
||||
### Codex
|
||||
|
||||
|
||||
+1
-1
@@ -1556,7 +1556,7 @@ Organizations can also deploy a system-wide config file for shared defaults —
|
||||
worktree-path = ".worktrees/{{ branch | sanitize }}"
|
||||
|
||||
[commit.generation]
|
||||
command = "MAX_THINKING_TOKENS=0 claude -p --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:
|
||||
|
||||
@@ -45,7 +45,7 @@ pub struct CommitGenerationConfig {
|
||||
///
|
||||
/// Examples:
|
||||
/// - `"llm -m claude-haiku-4.5"`
|
||||
/// - `"MAX_THINKING_TOKENS=0 claude -p --model=haiku"`
|
||||
/// - `"MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku"`
|
||||
///
|
||||
/// The command receives the prompt via stdin and should output the commit message.
|
||||
#[serde(default)]
|
||||
|
||||
@@ -34,7 +34,7 @@ impl LlmTool {
|
||||
pub fn recommended_config(&self) -> &'static str {
|
||||
match self {
|
||||
LlmTool::Claude => {
|
||||
"MAX_THINKING_TOKENS=0 claude -p --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
|
||||
"MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"
|
||||
}
|
||||
LlmTool::Codex => {
|
||||
r#"codex exec -m gpt-5.1-codex-mini -c model_reasoning_effort='low' --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == "agent_message")] | last.item.text'"#
|
||||
@@ -198,7 +198,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_llm_tool_recommended_config() {
|
||||
assert_snapshot!(LlmTool::Claude.recommended_config(), @"MAX_THINKING_TOKENS=0 claude -p --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.1-codex-mini -c model_reasoning_effort='low' --sandbox=read-only --json - | jq -sr '[.[] | select(.item.type? == "agent_message")] | last.item.text'"#);
|
||||
}
|
||||
|
||||
@@ -217,7 +217,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#""MAX_THINKING_TOKENS=0 claude -p --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]
|
||||
|
||||
@@ -91,7 +91,7 @@ Organizations can also deploy a system-wide config file for shared defaults —
|
||||
[107m [0m [2mworktree-path = [0m[2m[32m".worktrees/{{ branch | sanitize }}"[0m
|
||||
[107m [0m
|
||||
[107m [0m [2m[36m[commit.generation][0m
|
||||
[107m [0m [2mcommand = [0m[2m[32m"MAX_THINKING_TOKENS=0 claude -p --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"[0m
|
||||
[107m [0m [2mcommand = [0m[2m[32m"MAX_THINKING_TOKENS=0 claude -p --no-session-persistence --model=haiku --tools='' --disable-slash-commands --setting-sources='' --system-prompt=''"[0m
|
||||
|
||||
[1mProject config[0m — shared team settings:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user