Skip to content

fix(launch): forward env vars into tmux sessions#2190

Closed
pgagarinov wants to merge 4 commits intoYeachan-Heo:devfrom
pgagarinov:fix/tmux-env-forward-v2
Closed

fix(launch): forward env vars into tmux sessions#2190
pgagarinov wants to merge 4 commits intoYeachan-Heo:devfrom
pgagarinov:fix/tmux-env-forward-v2

Conversation

@pgagarinov
Copy link
Copy Markdown

Summary

Comprehensive fix for CLAUDE_CONFIG_DIR not being respected across OMC. Three commits:

1. fix(launch): forward env vars into tmux sessions

  • tmux new-session inherits the server's environment, not the calling process's. CLAUDE_CONFIG_DIR set before omc is silently lost when the tmux session spawns.
  • Injects critical env vars as export statements into the tmux shell command, after RC sourcing.
  • Tests: unit tests for buildEnvExportPrefix, allowlist contract; integration tests creating real tmux sessions with printenv (no API tokens), including shell quoting with spaces and single quotes.

2. fix(skills): use CLAUDE_CONFIG_DIR in skill bash blocks

  • All skill markdown files hardcoded $HOME/.claude in bash code blocks. Replaced with ${CLAUDE_CONFIG_DIR:-$HOME/.claude}.
  • Tests: regression test scanning all 52 skill markdown files for bare $HOME/.claude in bash blocks.

3. fix(installer): use CLAUDE_CONFIG_DIR in generated hook and HUD commands

  • The installer generates settings.json hook commands and HUD statusLine commands that hardcode $HOME/.claude. When running with a custom profile, hooks and HUD point to the wrong directory.
  • Replaced with ${CLAUDE_CONFIG_DIR:-$HOME/.claude} in generated Unix commands.
  • Updated hud SKILL.md JSON examples.
  • Tests: backward-compat tests ensuring isOmcHook/isOmcStatusLine recognize both old and new command formats.

Reproduction

  1. Set CLAUDE_CONFIG_DIR=~/.claude-personal
  2. Run omc (non--p mode, outside tmux)
  3. Inside the session, printenv CLAUDE_CONFIG_DIR shows wrong value
  4. Run /omc-setup — bash commands reference ~/.claude instead of the custom dir
  5. Check settings.json hooks — commands point to $HOME/.claude/hooks/...

Rebased on latest dev. Supersedes #2170.

🤖 Generated with Claude Code

pgagarinov and others added 3 commits April 5, 2026 10:43
tmux new-session inherits the server's environment, not the calling
process's. When CLAUDE_CONFIG_DIR is set before running omc, the value
is picked up by prepareOmcLaunchConfigDir() but silently lost when the
tmux session spawns because the server was started earlier without it.

Inject critical env vars as export statements into the shell command
that runs inside the tmux pane, after .zshrc/.bashrc sourcing so omc
values take precedence over stale tmux server state. Values are quoted
via the existing quoteShellArg helper.

Constraint: tmux server env is inherited at session creation, not client env
Rejected: tmux set-environment before new-session | race with concurrent launches
Rejected: tmux new-session -e flag | requires tmux 3.2+, not portable
Confidence: high
Scope-risk: narrow

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Skill markdown files hardcoded $HOME/.claude in bash code blocks,
ignoring the user's CLAUDE_CONFIG_DIR override. Replace all instances
with ${CLAUDE_CONFIG_DIR:-$HOME/.claude} so skills respect custom
config directories.

Also adds a regression test that scans all skill markdown files for
bash blocks containing bare $HOME/.claude without the fallback pattern.

Confidence: high
Scope-risk: narrow

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The installer generates shell commands for settings.json hooks and HUD
statusLine that hardcode $HOME/.claude. When a user runs a different
profile via CLAUDE_CONFIG_DIR, these commands point to the wrong
directory.

Replace $HOME/.claude with ${CLAUDE_CONFIG_DIR:-$HOME/.claude} in
generated Unix commands so hooks and HUD resolve to the active profile
at runtime while preserving the $HOME/.claude default.

Also updates hud SKILL.md JSON examples and adds backward-compat tests
ensuring isOmcHook/isOmcStatusLine recognize both old and new formats.

Confidence: high
Scope-risk: moderate

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

The pre-tool enforcer was updated to use PreToolUse deny API
(permissionDecision: 'deny') but the test still expected the old
decision: 'block' format.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@Yeachan-Heo
Copy link
Copy Markdown
Owner

Thanks — there is useful work in here, especially the tmux env-forwarding direction and the CLAUDE_CONFIG_DIR coverage improvements. The allowlisted export approach itself looks reasonably safe.

I'm still marking this request-changes / not-merge-ready for two concrete reasons:

  1. The PR scope is too mixed for the issue it claims to fix. It bundles tmux env forwarding, installer command generation changes, skill-doc scanning changes, and an unrelated behavioral test expectation update.
  2. src/__tests__/pre-tool-enforcer.test.ts changes expected behavior without the corresponding issue scope being justified here. That is not a small follow-on to CLAUDE_CONFIG_DIR forwarding; it changes the asserted contract from decision=block to a different deny path. That needs to be isolated and justified separately, not piggybacked into this PR.

The current failing CI signal is also not clean because hooks-command-escaping is still red elsewhere, so I'm judging this mostly on diff scope and contract safety.

If you want this to land, please split and resend as a tighter PR focused on the actual tmux / CLAUDE_CONFIG_DIR fix path only, without the unrelated pre-tool-enforcer contract adjustment.


[repo owner's gaebal-gajae (clawdbot) 🦞]

@Yeachan-Heo
Copy link
Copy Markdown
Owner

Closing for now instead of leaving this in request-changes limbo. Please reopen as a tighter PR scoped only to the tmux / CLAUDE_CONFIG_DIR fix path, without unrelated contract shifts.\n\n—\n*[repo owner's gaebal-gajae (clawdbot) 🦞]*

@Yeachan-Heo Yeachan-Heo closed this Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants