feat(crew): auto-prime when exec'ing Claude in-session

When running `gt crew at <name>` from inside the target session, we exec
Claude directly. Previously this meant we couldn't send `gt prime` afterward.

Now we pass "gt prime" as the initial prompt argument to the Claude CLI,
so Claude loads context immediately upon startup.

Closes gt-qivm

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-21 11:51:06 -08:00
parent 3c5622fda0
commit 12a8b7e2b3
2 changed files with 7 additions and 2 deletions

View File

@@ -133,8 +133,9 @@ func runCrewAt(cmd *cobra.Command, args []string) error {
// Check if we're already in the target session
if isInTmuxSession(sessionID) {
// We're in the session at a shell prompt - just start Claude directly
// Pass "gt prime" as initial prompt so Claude loads context immediately
fmt.Printf("Starting Claude in current session...\n")
return execClaude()
return execClaude("gt prime")
}
// Attach to session using exec to properly forward TTY

View File

@@ -147,7 +147,8 @@ func isShellCommand(cmd string) bool {
// execClaude execs claude, replacing the current process.
// Used when we're already in the target session and just need to start Claude.
func execClaude() error {
// If prompt is provided, it's passed as the initial prompt to Claude.
func execClaude(prompt string) error {
claudePath, err := exec.LookPath("claude")
if err != nil {
return fmt.Errorf("claude not found: %w", err)
@@ -155,6 +156,9 @@ func execClaude() error {
// exec replaces current process with claude
args := []string{"claude", "--dangerously-skip-permissions"}
if prompt != "" {
args = append(args, prompt)
}
return syscall.Exec(claudePath, args, os.Environ())
}