Repository navigation
feat(plugin-profiles): launch each session with its plugin profile - #16523
Conversation
…a profile launch writes the one-session file for a folder and profile and prints the claude command that starts a session in it. It clears an inherited PLUGIN_PROFILES_SESSION, merges a launcher's own settings through --with (claude keeps only the last --settings), stops an unattended launch whose profile misses a required prerequisite, and removes session files no launch has written for 30 days. status prints the launch command for the profile in force, which a handoff uses as its restore line. Refs: #16512 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
… a worktree's copied record The /plugin-profile confirmation names the other live sessions in the folder, read from claude agents --json, and still applies on Apply. A linked worktree whose .claude/settings.local.json was copied from the main worktree now takes a copy of the main worktree's profile record when the file still holds every entry the profile wrote, so status, the session-start notice, clear and launch see the profile there. Refs: #16512 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
When the profile skill is available, the session that launches the work loop takes its start words from the plugin-profiles launch command and launches nothing when that stops on a missing required prerequisite. The skill cheat sheet lists the profile skill's launch action. Refs: #16512 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
…ugin profile continue-in-background takes its start words from the plugin-profiles launch command when that plugin is enabled; a cloud launch says it starts without the profile. The handoff resume line carries --settings for the session's profile file, and a phase change adds a line above the unchanged copy line telling the user to exit and start the next session with the next profile's command. The restore entry is the launch line status prints. Refs: #16512 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
A lane's profile field starts it through the plugin-profiles launch command, with the lane's settings merged into the profile's session file. A refused profile skips that lane, and restart checks the refusal before it stops the running lane. Without plugin-profiles the lane launches as today with a warning. Every lane launch clears an inherited PLUGIN_PROFILES_SESSION. Also rewords two session-flow code spans that began with a space. Refs: #16512 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9bb1eafc03
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Lane run report
Failed GitHub API calls
|
|
claude-security-review reviewed Security review: PR #16523 at
|
|
claude-review reviewed Incremental code review: PR #16523, changes since
|
- apply without --for is a usage error again; it had defaulted to the folder, which changes every session sharing it. - Each session file sets PLUGIN_PROFILES_SESSION_FILE to its own path, so status names the file a merged launch started the session with. - launch no longer checks the calling surface: the session it starts is a CLI session, so a launch from VS Code or Desktop works. - The lanes restart check skips cloud lanes, which carry no profile, and resolves a local-background lane's profile for its linked worktree. - The handoff skill is back under its line cap: the plugin profile steps live in the structure doc it already walks. - The status line in the usage header has its column spacing back. Refs: #16512 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
…unch The launch command and the lanes launcher's own prefix now clear PLUGIN_PROFILES_SESSION_FILE along with PLUGIN_PROFILES_SESSION, so a session launched with no profile from a profiled shell does not keep the parent's file path. status already reads the file variable only when the marker is set. USAGE is back on its own line. Refs: #16512 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
Puts `let target` in statusOf back on its own line, restores the space in `const USAGE =`, and names both variables the launch command clears in the usage header. Refs: #16512 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
- A phase-change handoff reopens the producing session with its own profile file; only the next session's start command carries the next profile. - An adopted worktree record stays in memory, so status, a dry run and launch's default write no record file. - An empty PLUGIN_PROFILES_SESSION counts as unset everywhere it is read, so status falls back to the folder profile. - launch takes --dry-run, which checks and writes no file; the lanes restart check uses it, so it writes no extra session file and the missing-plugin warning prints once. Refs: #16512 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo
Post-merge mutation testingKilled 6, survived 1, timeout 0, no coverage 0, invalid 0, not run 0.
Surviving mutants
The run's summary has the full report. |
Closes #16512
Summary
Sessions that share one folder can now each run in their own plugin profile. Every launch site starts its session through one command,
plugin-profileslaunch, which writes the one-session settings file for the folder and profile and prints theclaude --settingscommand. A phase change is a relaunch. The in-session/plugin-profileswitch stays for folders with one session.Fix
One source of truth:
profiles.mjs launch [<name>] [--folder <dir>] [--with <settings>] [--unattended] [--json]apply --for sessionuses the same per-folder file.PLUGIN_PROFILES_SESSION), else the folder's recorded one (D20). With neither, the command carries no profile.env -u PLUGIN_PROFILES_SESSION -u PLUGIN_PROFILES_SESSION_FILE claude, so a launcher never passes on an inherited marker (D21). That clear lives in this one place; the lanes launcher's no-profile prefix is the same words.PLUGIN_PROFILES_SESSION_FILEto its own path, sostatusnames the file a session was started with, merged or not.statusreads it only when the marker is set.launchworks from any surface: the session it starts is a CLI session.applystill requires--for.--withtakes a launcher's own settings (a JSON object or a file) and writes one file holding both, keyed by folder, profile and a hash of the merged content.claudekeeps only the last--settings(probe 2 below), so two flags cannot work.--unattendedstops (exit 1, nothing written) when the profile switches on a plugin missing a required prerequisite (D23). An attended launch prints it and goes ahead.statusprints "Start another session here in this profile with: ..." (the launch command). This was defect 1: the handoff reference asked for a restore entry thatstatusdid not print.Launch sites
continue-in-background:claude --bgtakes its words fromlaunchwhen the profile skill is available;--cloudcannot carry a settings file, and the launch report says so.handoff: theclaude --resumeline carries--settings "<file>"(save_point.py new --settings-file). On a phase change,--start-commandadds a line above the copy line telling the user to exit and start the next session with the next profile's command. The copy line itself is unchanged, because/session-flow:find-handoffand the hop-chain harness key on it.profilefield. The launcher finds the enabled plugin-profiles throughclaude plugin list --json, runslaunch --unattended --jsonwith the lane's settings as--with, and starts the lane with its argv. A refused profile skips that lane with an error; other lanes launch. Onrestart, the refusal is checked before the running lane is stopped, for the folder the relaunch uses (a local-background lane's linked worktree); a cloud lane, which carries no profile, skips that check. With plugin-profiles absent, the lane launches as today with a warning. Every lane launch clears an inherited marker. A cloud lane warns that the profile is not applied.restart-consumer.shrelaunches through the launcher, so it gets the same handling.work-loop: the launching session takes its words fromlaunch --unattended.Sites left alone
reachand its relay: its local hops (R1 WSL to Windows, R4 Windows to WSL) cross the WSL boundary, and only variables inWSLENVcross it (hereWT_SESSION:WT_PROFILE_ID:), so no marker leaks there. Starting a remote session in the remote's profile needs the remote'sprofiles.mjspath, which the skill has no source for today; the natural source is the per-lane paths FLEET.md already renders from dotfiles, which is outside this repository.setup: the scheduled run'sclaudeargv is built intemplates/monthly-run.ps1(lines 43 and 59) under Windows Task Scheduler, whose/tris capped at 262 characters, and the launch argv starts withenv, which Windows lacks. It needs its own small design (an argv file the wrapper reads), not a skill-text change.Not covered: a cloud lane whose cloud launch is refused falls back to a local launch, and that launch can still hit the missing-prerequisite stop after
restarthas already stopped the running lane.Defects
.claude/settings.local.jsonwith its profile entries, but the record is keyed by the file's real path. When a linked worktree's file has no record, plugin-profiles now finds the main worktree from the files git writes (no git process), and adopts a copy of its record when the file still holds every entry that record wrote (entries a deferred switch has not yet written are skipped, asstatusskips them)./plugin-profile's confirmation names the other live sessions in the folder, read fromclaude agents --json(lib/sessions.mjs), and still applies on Apply.Verification
Probes, Claude Code 2.1.325, interactive tmux sessions, 2026-11-16:
claude --settings <file setting PLUGIN_PROFILES_SESSION>, aclaude --bgchild had noPLUGIN_PROFILES_SESSIONin its process environment (/proc/<pid>/environ); in it,statusreported no session profile and a--defer-offdry run was not refused. The background supervisor spawns the child. A direct child (claudestarted from that Bash tool) does inherit the whole environment. The clear stays at every site, per D21: a--bglaunch that must first start the supervisor from a profiled shell was not probed.--settingsflags: accepted without error; the last wins wholly. Witha.jsonthenb.json, only b's env values were set; in reverse order, only a's.Observations, not acted on: a
--bgchild did not take the parent's--model(it ran the default model); a direct child took the parent's session name and bridge session id over its own--name.Tests:
plugins/plugin-profiles/scripts/profiles.test.mjs: 80 pass (launch, merge, cleanup, unattended stop, status line and merged-file path, both variables cleared, any surface,applyneeds--for, worktree record adoption,othersInFolder).plugins/plugin-profiles/lib/sessions.test.sh: 2 pass.claude plugin test plugins/plugin-profiles(mod): 17 pass, one new for D22.plugins/session-flow/scripts/tests/test_save_point.py: 298 pass.plugins/harness-ops/skills/lanes/scripts/lane-launcher.test.sh: PASS (with the restart preflight and cloud-lane restart cases);restart-consumer.test.sh: 213 cases, 0 failures.Related
🤖 Generated with Claude Code
https://claude.ai/code/session_015XWwmdCN6NUZy2Y8Uh2aXo