Strip CLAUDECODE env var when spawning claude-code agent#273
Conversation
When the daemon is started from within a Claude Code session (or hooks fire during one), the CLAUDECODE environment variable gets inherited by worker processes. Claude Code's nested-session guard then rejects the spawn with "cannot be launched inside another Claude Code session". Strip CLAUDECODE alongside ANTHROPIC_API_KEY when building the child process environment. Make filterEnv variadic to support multiple keys cleanly. Closes #270 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
roborev: Combined ReviewVerdict: No Medium, High, or Critical issues found; this change appears safe and security-positive. Findings (Medium+)No findings at Medium severity or higher after deduplicating all agent outputs. Synthesized from 4 reviews (agents: codex, gemini | types: security, default) |
The arrow characters (↑↓←→) are 3 bytes in UTF-8 but 1 terminal column wide. Using len() overestimated help line wrapping at widths 91-93, costing a visible row unnecessarily. Switch to runewidth.StringWidth() in both queue and review views. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
roborev: Combined ReviewVerdict: No Medium/High/Critical issues identified; changes look safe to merge. Findings (Medium+)No findings at Medium severity or above after deduplicating all review outputs. Synthesized from 4 reviews (agents: codex, gemini | types: security, default) |
go test on Windows can exit 1 when it fails to remove temp .exe
files due to OS file locking ("Access is denied"), even when all
tests pass. Check for actual FAIL lines in test output instead of
relying on the exit code alone.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Only suppress non-zero exit when the output contains "Access is denied" and no FAIL lines. Propagate all other non-zero exits (toolchain errors, module failures, etc.) as real failures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
roborev: Combined ReviewVerdict: No Medium, High, or Critical issues found; PR is acceptable as-is. Findings (Medium+)None. All reported concerns were Low severity (primarily around CI heuristic robustness in Synthesized from 4 reviews (agents: codex, gemini | types: security, default) |
Split on first = and compare key portion exactly, preventing false matches when one key is a prefix of another (e.g. CLAUDE would have also stripped CLAUDECODE, CLAUDE_NO_SOUND). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify that stripping "CLAUDE" does not also strip "CLAUDECODE" or "CLAUDE_NO_SOUND" — the prefix-collision scenario that motivated the strings.Cut change. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
roborev: Combined ReviewVerdict: One Medium issue should be fixed before merge. Medium
Synthesized from 4 reviews (agents: codex, gemini | types: security, default) |
The PowerShell script was missing `exit 0` after suppressing the temp .exe cleanup error, so the non-zero exit code from `go test` propagated through. Also narrowed the match from "Access is denied" to the specific "go: remove ...\.exe: Access is denied" pattern to avoid masking unrelated permission failures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
roborev: Combined ReviewVerdict: No Medium, High, or Critical issues identified across all reviews; the PR appears clean. Consolidated Findings (Medium+)No findings to report. Reviewer ConsensusAll four review outputs reported no issues, including both security-focused and general correctness/regression passes. Synthesized from 4 reviews (agents: codex, gemini | types: security, default) |
…#273) ## Summary - Strip `CLAUDECODE` from the child process environment when spawning the claude-code agent, preventing Claude Code's nested-session guard from rejecting the spawn - Make `filterEnv` variadic to support stripping multiple env vars cleanly - Add test for multi-key filtering Same class of fix as roborev-dev#267 (`GIT_DIR` stripping for daemon spawn). When the daemon starts from within a Claude Code session, or post-commit hooks fire during one, `CLAUDECODE` gets inherited by worker processes and Claude Code refuses to launch. Closes roborev-dev#270 ## Test plan - [x] `go test ./internal/agent/` passes (including new `TestFilterEnvMultipleKeys`) - [x] `go vet ./...` clean - [x] Manual: start daemon from within Claude Code session, verify reviews succeed 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
CLAUDECODEfrom the child process environment when spawning the claude-code agent, preventing Claude Code's nested-session guard from rejecting the spawnfilterEnvvariadic to support stripping multiple env vars cleanlySame class of fix as #267 (
GIT_DIRstripping for daemon spawn). When the daemon starts from within a Claude Code session, or post-commit hooks fire during one,CLAUDECODEgets inherited by worker processes and Claude Code refuses to launch.Closes #270
Test plan
go test ./internal/agent/passes (including newTestFilterEnvMultipleKeys)go vet ./...clean🤖 Generated with Claude Code