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:
Maximilian Roos
2026-03-11 16:20:00 -07:00
committed by GitHub
parent 3080eb0922
commit 9b77ab2d93
9 changed files with 13 additions and 13 deletions
+1 -1
View File
@@ -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'"'"''
+1 -1
View File
@@ -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:
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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:
+2 -2
View File
@@ -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
View File
@@ -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:
+1 -1
View File
@@ -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)]
+3 -3
View File
@@ -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 —
  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: