Skip to content

Feature Request: Support injecting hook command output into LLM context (like Claude Code) #1139

@cephalin

Description

@cephalin

Summary

Copilot CLI hooks cannot inject command output into the LLM context window, unlike Claude Code. This prevents systems like Gas Town from using hooks to load dynamic context (like CLAUDE.md files) into conversations.

Background

Claude Code supports hooks that inject context by:

  1. Running a command (e.g., gt prime)
  2. Capturing its stdout
  3. Automatically including that output in the session context

Example Claude Code flow:

  • Hook runs: gt prime --hook
  • Output: Full CLAUDE.md context (markdown)
  • Result: Context appears in Claude's system prompt

Problem

Copilot CLI hooks currently:

  • ✅ Execute commands
  • ✅ Can read stdin (for hook metadata)
  • ✅ Support side effects (logging, file writes)
  • Cannot inject stdout into LLM context

When a sessionStart hook runs gt prime --hook, the context is generated and output to stdout, but Copilot CLI discards it instead of injecting it into the conversation.

Impact

  • Gas Town and similar systems cannot use hooks to load dynamic role-specific context
  • Agents must have static instructions in system prompts instead of dynamic, role-detected context
  • Breaks feature parity with Claude Code's hook capabilities

Request

Add support for hook output injection in Copilot CLI:

  1. Allow hooks to output context that gets prepended to LLM context
  2. Specify which hooks support output injection (probably sessionStart, sessionEnd, userPromptSubmitted)
  3. Handle output format (plain text, markdown, JSON, etc.)

Example desired behavior:

{
  "version": 1,
  "hooks": {
    "sessionStart": [
      {
        "type": "command",
        "bash": "gt prime --hook",
        "injectOutput": true,
        "outputFormat": "markdown"
      }
    ]
  }
}

Workaround (if no native support)

Hooks could write context to a .github/context.md file and Copilot CLI could automatically read/inject that at session start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions