From 62413d55cbb0a40cba7586d09e32370618b0a5ca Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Fri, 26 Dec 2025 16:52:38 -0800 Subject: [PATCH] Fix GT_ROLE not set for crew workers (gt-sij0a) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit crew_at.go and crew_lifecycle.go were not setting GT_ROLE when starting crew sessions. This caused crew workers to inherit GT_ROLE from the parent environment (often "mayor"), leading to incorrect role detection. Now properly exports GT_ROLE=crew along with GT_RIG, GT_CREW, and BD_ACTOR when spawning Claude for crew workers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/cmd/crew_at.go | 9 +++++++-- internal/cmd/crew_lifecycle.go | 6 +++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/internal/cmd/crew_at.go b/internal/cmd/crew_at.go index ae5e99a5..e2373a59 100644 --- a/internal/cmd/crew_at.go +++ b/internal/cmd/crew_at.go @@ -91,6 +91,7 @@ func runCrewAt(cmd *cobra.Command, args []string) error { } // Set environment (non-fatal: session works without these) + _ = t.SetEnvironment(sessionID, "GT_ROLE", "crew") _ = t.SetEnvironment(sessionID, "GT_RIG", r.Name) _ = t.SetEnvironment(sessionID, "GT_CREW", name) @@ -120,7 +121,9 @@ func runCrewAt(cmd *cobra.Command, args []string) error { // Use respawn-pane to replace shell with Claude directly // This gives cleaner lifecycle: Claude exits → session ends (no intermediate shell) // Pass "gt prime" as initial prompt so Claude loads context immediately - claudeCmd := `claude --dangerously-skip-permissions "gt prime"` + // Export GT_ROLE and BD_ACTOR since tmux SetEnvironment only affects new panes + bdActor := fmt.Sprintf("%s/crew/%s", r.Name, name) + claudeCmd := fmt.Sprintf(`export GT_ROLE=crew GT_RIG=%s GT_CREW=%s BD_ACTOR=%s && claude --dangerously-skip-permissions "gt prime"`, r.Name, name, bdActor) if err := t.RespawnPane(paneID, claudeCmd); err != nil { return fmt.Errorf("starting claude: %w", err) } @@ -143,7 +146,9 @@ func runCrewAt(cmd *cobra.Command, args []string) error { // Use respawn-pane to replace shell with Claude directly // Pass "gt prime" as initial prompt so Claude loads context immediately - claudeCmd := `claude --dangerously-skip-permissions "gt prime"` + // Export GT_ROLE and BD_ACTOR since tmux SetEnvironment only affects new panes + bdActor := fmt.Sprintf("%s/crew/%s", r.Name, name) + claudeCmd := fmt.Sprintf(`export GT_ROLE=crew GT_RIG=%s GT_CREW=%s BD_ACTOR=%s && claude --dangerously-skip-permissions "gt prime"`, r.Name, name, bdActor) if err := t.RespawnPane(paneID, claudeCmd); err != nil { return fmt.Errorf("restarting claude: %w", err) } diff --git a/internal/cmd/crew_lifecycle.go b/internal/cmd/crew_lifecycle.go index 4538aa48..cc8fda92 100644 --- a/internal/cmd/crew_lifecycle.go +++ b/internal/cmd/crew_lifecycle.go @@ -221,6 +221,7 @@ func runCrewRestart(cmd *cobra.Command, args []string) error { } // Set environment + t.SetEnvironment(sessionID, "GT_ROLE", "crew") t.SetEnvironment(sessionID, "GT_RIG", r.Name) t.SetEnvironment(sessionID, "GT_CREW", name) @@ -234,7 +235,10 @@ func runCrewRestart(cmd *cobra.Command, args []string) error { } // Start claude with skip permissions (crew workers are trusted) - if err := t.SendKeys(sessionID, "claude --dangerously-skip-permissions"); err != nil { + // Export GT_ROLE and BD_ACTOR since tmux SetEnvironment only affects new panes + bdActor := fmt.Sprintf("%s/crew/%s", r.Name, name) + claudeCmd := fmt.Sprintf("export GT_ROLE=crew GT_RIG=%s GT_CREW=%s BD_ACTOR=%s && claude --dangerously-skip-permissions", r.Name, name, bdActor) + if err := t.SendKeys(sessionID, claudeCmd); err != nil { return fmt.Errorf("starting claude: %w", err) }