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:
@@ -133,8 +133,9 @@ func runCrewAt(cmd *cobra.Command, args []string) error {
|
|||||||
// Check if we're already in the target session
|
// Check if we're already in the target session
|
||||||
if isInTmuxSession(sessionID) {
|
if isInTmuxSession(sessionID) {
|
||||||
// We're in the session at a shell prompt - just start Claude directly
|
// 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")
|
fmt.Printf("Starting Claude in current session...\n")
|
||||||
return execClaude()
|
return execClaude("gt prime")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach to session using exec to properly forward TTY
|
// Attach to session using exec to properly forward TTY
|
||||||
|
|||||||
@@ -147,7 +147,8 @@ func isShellCommand(cmd string) bool {
|
|||||||
|
|
||||||
// execClaude execs claude, replacing the current process.
|
// execClaude execs claude, replacing the current process.
|
||||||
// Used when we're already in the target session and just need to start Claude.
|
// 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")
|
claudePath, err := exec.LookPath("claude")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("claude not found: %w", err)
|
return fmt.Errorf("claude not found: %w", err)
|
||||||
@@ -155,6 +156,9 @@ func execClaude() error {
|
|||||||
|
|
||||||
// exec replaces current process with claude
|
// exec replaces current process with claude
|
||||||
args := []string{"claude", "--dangerously-skip-permissions"}
|
args := []string{"claude", "--dangerously-skip-permissions"}
|
||||||
|
if prompt != "" {
|
||||||
|
args = append(args, prompt)
|
||||||
|
}
|
||||||
return syscall.Exec(claudePath, args, os.Environ())
|
return syscall.Exec(claudePath, args, os.Environ())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user