Skip to content

claude-profile: an opt-in --lane hands the final Claude launch to lane-start - #44

Merged
brettheap merged 1 commit into
mainfrom
feat/claude-profile-lane-start
Sep 11, 2026
Merged

brettheap merged 1 commit into
mainfrom
feat/claude-profile-lane-start

Conversation

@brettheap

@brettheap brettheap commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openreposhape-2 (openRepoShape-2)
Claim: #43 (comment)

Closes #43.

Summary

  • base-image/files/claude-profile gains an opt-in --lane <repo>-<n> (and
    CLAUDE_LANE fallback): when named, the run action's final
    exec "$claude_bin" … becomes exec lane-start "$lane" -- <the same claude args>, with CLAUDE_BIN/CLAUDE_CONFIG_DIR exported so lane-start
    starts the same Claude under the same profile.
  • With no --lane/CLAUDE_LANE, behaviour is unchanged — verified
    byte-for-byte (Claude's argv and every tmux call identical to the
    pre-change script under matched inputs).
  • A named lane whose lane-start is not on PATH refuses (exit 2, names the
    opensoft/brett-wip clone + scripts/link-estates fix) before
    claude_run_is_interactive/start_profile_tmux ever run, so no tmux
    session is created first.
  • The interactive auto-tmux path re-invokes the launcher inside a new
    detached tmux session; CLAUDE_LANE is threaded through that
    re-invocation explicitly (not relied on via tmux's environment
    inheritance, which does not reliably hand a freshly-exported variable to a
    new session on an already-running server).
  • --lane/-h/--help are recognised only as leading options, before the
    action/profile, so anything after the profile name still reaches Claude
    untouched (e.g. claude-profile work --help still shows Claude's help).

Test plan

  • New devcontainer.test/test-claude-profile-lane-start.sh (fake tmux,
    lane-start, claude on PATH): --help documents --lane/
    CLAUDE_LANE; no lane leaves lane-start uninvoked and Claude's args
    unchanged; --lane hands off with CLAUDE_BIN/CLAUDE_CONFIG_DIR
    set; a missing lane-start refuses before any tmux command runs;
    CLAUDE_LANE (env, no flag) behaves the same as --lane.
  • Existing launcher regression tests re-run against the patched script:
    test-claude-tmux-statusline.sh, test-claude-profile-preserves-model.sh,
    test-shared-mcp-profiles.sh — all pass.
  • devBenches/devcontainer.test/test-openspeckit-bootstrap.sh (742
    pass), test-speckit-git-feature.sh (56 pass), test-speckit-git-compat.sh
    (22 pass), test-ct-launchers.sh (exit 0) — unaffected, all green.
  • bash base-image/files/claude-profile --help | grep -n lane shows the
    new option.

🤖 Generated with Claude Code

Summary by Sourcery

Enable optional Claude profile launches to hand off named sessions to lane-start without changing the default launch behavior.

New Features:

  • Add opt-in lane handoff support to claude-profile through --lane and CLAUDE_LANE, delegating named launches to lane-start while preserving the selected Claude profile and arguments.

Bug Fixes:

  • Prevent named lane launches from creating tmux sessions when lane-start is unavailable, and provide guidance for installing it.

Enhancements:

  • Preserve existing launcher behavior when no lane is specified and explicitly propagate lane configuration through interactive tmux re-invocations.

Documentation:

  • Document lane-based Claude launches, prerequisites, fallback configuration, and behavior when lane-start is unavailable.

Tests:

  • Add regression coverage for help output, unchanged no-lane launches, flag and environment-based handoff, argument and profile preservation, and early failure without lane-start.

…e-start

New --lane <repo>-<n> (and CLAUDE_LANE fallback), off by default: when a
lane is named, the final `exec "$claude_bin" …` in the `run` action becomes
`exec lane-start "$lane" -- <the same claude args>`, with CLAUDE_BIN and
CLAUDE_CONFIG_DIR exported so lane-start starts this same Claude under this
same profile. lane-start then renames the tmux window to the lane, writes
the lane register row, and launches with --resume/--name <lane>.

With no --lane/CLAUDE_LANE, behaviour is unchanged (verified byte-for-byte
against the prior exec's argv and tmux calls). A named lane whose lane-start
is not on PATH refuses with the clone/link-estates fix and exits 2 before
claude_run_is_interactive/start_profile_tmux ever run, so no tmux session is
created. The interactive auto-tmux path re-invokes the launcher inside a new
detached tmux session; CLAUDE_LANE is threaded through that re-invocation
explicitly rather than relied on via tmux environment inheritance, which
does not reliably hand a freshly-exported variable to a new session on an
already-running tmux server. --lane/-h/--help are recognised only as leading
options, before the action/profile, so anything after the profile name is
still forwarded to Claude untouched.

Adds devcontainer.test/test-claude-profile-lane-start.sh (fake tmux,
lane-start and claude on PATH) proving: --help documents --lane/CLAUDE_LANE;
no lane leaves lane-start uninvoked and Claude's args unchanged; --lane hands
off with CLAUDE_BIN/CLAUDE_CONFIG_DIR set; a missing lane-start refuses
before any tmux command runs; CLAUDE_LANE (env, no flag) behaves the same as
--lane. Adds one paragraph to docs/claude-multi-account-profiles.md.

Closes #43.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 11, 2026 03:04
@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 hour and 7 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR adds an opt-in --lane/CLAUDE_LANE path that delegates the final Claude launch to lane-start, explicitly preserves the selected Claude binary and profile, validates the dependency before tmux setup, and maintains unchanged behavior when no lane is specified. New regression tests and user documentation cover the hand-off and failure paths.

Sequence diagram for the optional lane-start Claude launch

sequenceDiagram
    participant User
    participant Profile as claude-profile
    participant Tmux
    participant Lane as lane-start
    participant Claude

    User->>Profile: run [--lane lane]
    Profile->>Profile: command -v lane-start
    alt interactive auto-tmux
        Profile->>Tmux: start_profile_tmux
        Tmux->>Profile: re-invoke with CLAUDE_LANE
    end
    Profile->>Lane: exec lane-start lane -- Claude args
    Lane->>Claude: launch with CLAUDE_BIN and CLAUDE_CONFIG_DIR
    Claude-->>User: Claude session
Loading

Flow diagram for claude-profile lane option handling

flowchart TD
    A[claude-profile leading options] --> B{lane selected?}
    B -->|No| C[exec Claude with original args]
    B -->|Yes| D{lane-start on PATH?}
    D -->|No| E[exit 2 with setup fix]
    D -->|Yes| F[export CLAUDE_BIN and CLAUDE_CONFIG_DIR]
    F --> G[exec lane-start lane -- Claude args]
Loading

File-Level Changes

Change Details Files
Add opt-in lane hand-off support to the Claude profile launcher while preserving the existing default launch path.
  • Parse leading --lane <lane> and CLAUDE_LANE fallback, without consuming Claude arguments after the profile.
  • Validate lane-start availability before interactive/tmux setup and provide installation guidance on failure.
  • Export the selected Claude binary and profile directory, then invoke lane-start <lane> -- with the original Claude arguments.
  • Thread the lane through interactive auto-tmux re-invocation explicitly.
  • Keep all non-lane launches byte-for-byte equivalent in Claude argv and tmux behavior.
base-image/files/claude-profile
Add focused regression coverage for lane selection, hand-off, validation, and argument preservation.
  • Verify help output documents the lane option, environment fallback, and lane-start dependency.
  • Verify baseline launches bypass lane-start and preserve Claude arguments.
  • Verify both flag and environment forms pass the lane and profile environment correctly.
  • Verify missing lane-start exits 2 before any tmux command and names the brett-wip/link-estates fix.
devcontainer.test/test-claude-profile-lane-start.sh
Document how to enable lane-start integration and its operational prerequisites.
  • Describe --lane/CLAUDE_LANE usage and opt-in behavior.
  • Document the required opensoft/brett-wip scripts/link-estates setup and same-profile launch behavior.
docs/claude-multi-account-profiles.md

Assessment against linked issues

Issue Objective Addressed Explanation
#43 Add an opt-in --lane <repo>-<n> option with CLAUDE_LANE as a fallback, documented in help, that hands the final Claude launch to lane-start <lane> -- <same Claude arguments> while exporting CLAUDE_BIN and CLAUDE_CONFIG_DIR. ✅
#43 Preserve default behavior when no lane is specified, while correctly handling leading-option parsing and propagating CLAUDE_LANE through the interactive auto-tmux re-invocation. ✅
#43 Refuse a named-lane launch with exit status 2 and an actionable lane-start installation message before creating any tmux session, and document and regression-test the new behavior. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@brettheap
brettheap merged commit d0685a3 into main Sep 11, 2026
6 checks passed
@brettheap
brettheap deleted the feat/claude-profile-lane-start branch September 11, 2026 03:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Moderate issues remain in option validation, interactive propagation, MCP handling, and test coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds opt-in --lane/CLAUDE_LANE support to delegate Claude profile launches to lane-start while preserving default behavior.

Changes:

  • Adds lane parsing, validation, and handoff.
  • Propagates profile context through tmux.
  • Documents lane usage and adds regression tests.
File summaries
File Summary
docs/claude-multi-account-profiles.md Documents lane-based launches and prerequisites.
devcontainer.test/test-claude-profile-lane-start.sh Tests lane, no-lane, environment fallback, and failure behavior.
base-image/files/claude-profile Implements lane parsing, validation, tmux propagation, and delegation.
Review details

Suppressed comments (4)

base-image/files/claude-profile:266

  • --lane= leaves lane empty, so this invocation silently takes the no-lane path; --lane --help likewise consumes --help as the lane and falls through to the default list action. The option is documented as requiring <repo>-<n>, so reject empty or option-looking values here instead of silently disabling the handoff.
    --lane)
      [[ $# -ge 2 ]] || { echo "pclaude: --lane needs a value: <repo>-<n>" >&2; exit 2; }
      lane="$2"; shift 2 ;;
    --lane=*) lane="${1#--lane=}"; shift ;;

base-image/files/claude-profile:159

  • The successful lane cases force TMUX=fake-session, so claude_run_is_interactive is false and this new propagation path is never exercised. The missing-lane-start pty case exits before constructing the tmux command, leaving successful outside-tmux launches unable to catch a broken CLAUDE_LANE re-invocation. Add a fake-tmux scenario that executes or inspects the detached child command.
  [[ -n "${lane:-}" ]] && env_prefix+=("CLAUDE_LANE=$lane")

devcontainer.test/test-claude-profile-lane-start.sh:84

  • The positive lane cases set TMUX, explicitly bypassing claude_run_is_interactive; the only pty case exits before start_profile_tmux because lane-start is missing. Thus the new environment-threading path is not covered by a successful interactive handoff, so a regression there can pass all of these tests.
# --lane's realistic case is a terminal already inside tmux (a lane is always
# started from an existing tmux window; lane-start itself refuses otherwise),
# which is also the simplest to simulate: TMUX set means claude_run_is_interactive
# is false, so the launcher does not try to wrap a NEW tmux session around it.

docs/claude-multi-account-profiles.md:135

  • The launcher only recognizes --lane before the action/profile, but this paragraph does not state that restriction. A user following it as pclaude work --lane ... will pass the option to Claude instead of starting a lane, so document the required placement.
Pass `--lane <repo>-<n>` (or set `CLAUDE_LANE=<repo>-<n>` in the environment)
  • Files reviewed: 3/3 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

# tmux does not reliably hand a freshly-exported variable to a new session
# on an already-running server, so it is threaded through explicitly here
# rather than relied on via inheritance — same idiom as the guard above.
[[ -n "${lane:-}" ]] && env_prefix+=("CLAUDE_LANE=$lane")
Comment on lines +336 to +340
if [[ -n "${lane:-}" ]]; then
command -v lane-start >/dev/null 2>&1 || {
echo "pclaude: --lane $lane needs lane-start on PATH. Fix:" >&2
echo " git clone [email protected]:opensoft/brett-wip.git ~/projects/brett-wip && ~/projects/brett-wip/scripts/link-estates" >&2
exit 2
# inherited from whatever shell runs the test — including a shell that is
# itself a claude-profile-launched tmux child (WORKBENCHES_CLAUDE_TMUX_CHILD=1)
# or already inside some other tmux session (TMUX set to a real socket).
unset TMUX WORKBENCHES_CLAUDE_TMUX_CHILD WORKBENCHES_TMUX_SESSION WORKBENCHES_TMUX_PANE TMUX_PANE 2>/dev/null || true
@@ -0,0 +1,187 @@
#!/usr/bin/env bash
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.

claude-profile: an opt-in --lane so a profile launch can hand off to lane-start

2 participants