Skip to content

Claude Code Opportunity: Use SessionStart hook for automatic fleet context priming #631

@Wirasm

Description

@Wirasm

Context

Currently, fleet context (dropbox protocol, current task, fleet status) must be manually injected into worker sessions via kild prime <branch>kild inject worker "$(kild prime worker)". This is a manual step the brain must perform when (re)opening workers.

Opportunity

Claude Code now supports SessionStart hooks. A command hook on SessionStart can output text or JSON with additionalContext that gets injected into the session automatically at startup.

{
  "SessionStart": [{
    "hooks": [{
      "type": "command",
      "command": "kild prime --self --raw",
      "statusMessage": "Loading fleet context..."
    }]
  }]
}

The stdout from this command becomes context injected into the new session — no manual prime step needed.

Benefits

  • Workers automatically get fleet context on every session start/resume
  • Eliminates manual kild prime + kild inject step
  • Works on resume too (source: startup, resume, clear, compact)
  • Brain doesn't need to orchestrate priming for each worker

Considerations

  • SessionStart input includes source field — can match on startup vs resume for different behavior
  • May need a kild prime --self --raw variant that outputs plain text (no markdown formatting)
  • The CLAUDE_ENV_FILE env var is available at SessionStart for persisting env vars
  • Should be registered per-session (in project .claude/settings.json or via fleet setup), not globally

Files involved

  • crates/kild-core/src/sessions/integrations/claude.rs — settings patching
  • crates/kild-core/src/sessions/dropbox.rsgenerate_prime_context()
  • crates/kild/src/commands/prime.rs — may need --self --raw flag

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority - Backlog, when time permitseffort/lowSingle file or function, one responsibility, isolated changefeatureNew functionality (planned)fleetFleet/brain (Honryū) coordination

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions