Documentation
¶
Overview ¶
Package claudecode holds Claude Code's header rules. They are plain functions of the request headers, so any host (the proxy, the bifrost adapter, Cortex) can call them. agent/client calls them from Identify.
This is a library package. It never imports a host. imports_test.go enforces that.
Index ¶
Constants ¶
const AgentHeader = "x-claude-code-agent-id"
AgentHeader is the request header Claude Code names a subagent's thread with. Seen on the wire with Claude Code 2.1.294 through a custom ANTHROPIC_BASE_URL: present on every subagent request, absent on the main thread. The sibling headers its code also names (x-claude-code-parent-agent-id, -agent-type, -request-class) were NOT sent in that capture, so nothing here depends on them.
const SubagentTypeField = "subagent_type"
SubagentTypeField is the argument of a SubagentTools call that names the subagent's type.
const ToolSearch = "ToolSearch"
ToolSearch is Claude Code's own client-side tool search tool.
Variables ¶
var AskHumanTools = []string{"AskUserQuestion", "ExitPlanMode"}
AskHumanTools are the tools whose call waits on a person, not on the tool itself.
var BuiltinSubagentTypes = []string{"general-purpose", "Explore", "Plan", "statusline-setup", "claude-code-guide"}
BuiltinSubagentTypes are the subagent types that ship with the client. Any other type is a name the user chose.
var BuiltinTools = []string{
"Agent", "Artifact", "ArtifactCheck", "ArtifactComments",
"ArtifactData", "AskUserQuestion", "Bash",
"BashOutput", "CronCreate", "CronDelete", "CronList",
"DesignSync", "Edit", "EndConversation", "EnterWorktree",
"ExitPlanMode", "ExitWorktree", "Glob", "Grep",
"KillShell", "ListAgents", "ListMcpResourcesTool", "LSP",
"Monitor", "NotebookEdit", "PowerShell", "Read",
"ReadMcpResourceDirTool", "ReadMcpResourceTool", "SendMessage",
"SendFeedback", "Skill", "SlashCommand", "TaskCreate",
"TaskGet", "TaskList", "TaskOutput", "TaskStop",
"TaskUpdate", "TodoWrite", "ToolSearch", "WebFetch", "WebSearch", "Write",
}
BuiltinTools is Claude Code's own client-side tool set. A name on this list is a tool the client ships, so a user cannot remove its declaration without breaking the agent.
The list errs toward EXCLUDING an unrecognised name. A name that merely looks built-in (Workflow and ScheduleWakeup on one deployment) can belong to another agent's own tool, and filing it here would hide a genuinely removable declaration behind a danger warning. A name that was verified against a live captured request, such as DesignSync (Claude Code's claude.ai/design bridge), is listed. When a new Claude Code tool appears, add it here.
var InjectedPrefixes = []string{
"This session is being continued from a previous conversation",
"[Request interrupted by user",
"[Tool use was rejected",
"[SUGGESTION MODE",
"[Image #",
"[Image:",
"The user stepped away and is coming back",
"Describe your most recent action in 3-5 words",
"Base directory for this skill:",
"Caveat: The messages below were generated by the user while running",
"API Error",
"Web page content:",
"CRITICAL: Respond with TEXT ONLY",
"Your directive:",
"Analyze if this message indicates a new conversation topic",
"## Page contract",
"The coordinator sent a message while you were working",
"Another Claude session sent a message while you were working",
"A teammate sent a message while you were working",
"[SYSTEM NOTIFICATION - NOT USER INPUT]",
"Continue from where you left off.",
}
InjectedPrefixes are whole-message markers: text starting with one of these is framework output, never a human turn. Spelled as the corpus spells them -- these were read off 30,224 role:user text parts, not guessed.
var QuestionTools = []string{"AskUserQuestion"}
QuestionTools are the AskHumanTools that ask a question. The others (ExitPlanMode) ask for an approval.
var SubagentTools = []string{"Agent", "Task"}
SubagentTools are the tools whose call starts a subagent. Task is the older name of Agent. The call's `prompt` argument becomes the subagent's first role:user message, and its `subagent_type` argument (SubagentTypeField) names the kind of subagent.
var TeammatePrefixes = []string{
"The coordinator sent a message while you were working",
"Another Claude session sent a message while you were working",
"A teammate sent a message while you were working",
}
TeammatePrefixes are the InjectedPrefixes that are another agent's message, not the harness's. A wake by one of them reads as a teammate wake. They are also in InjectedPrefixes, so the transcript reconstruction drops them as it always did.
var WrapperTags = []string{
"system-reminder",
"local-command-caveat",
"local-command-stdout",
"local-command-stderr",
"command-name",
"command-message",
"command-args",
"fork-boilerplate",
"agent-message",
"cross-session-message",
}
WrapperTags enclose injected content. They are STRIPPED rather than used to drop the whole message, because a message may hold genuine human text alongside them -- most commonly a <system-reminder> appended after a real prompt.
Functions ¶
func AgentID ¶
AgentID is the raw AgentHeader value, trimmed: Claude Code's id for a subagent's thread. "" for the main thread, and for a nil header. The host validates it (thread.HeaderAgentID) before it uses it as a key.
func IsSkillReloadNotice ¶ added in v0.7.11
IsSkillReloadNotice matches the role:user line Claude Code appends after a Skill tool call for a skill already in context: "Skill /fetch is already loaded above; instructions unchanged." Matched as the WHOLE message, not by prefix, because "Skill /" alone could begin a real prompt. Seen 2026-10-07, where it made one /fetch count as two turns; it never appears as a claude_code.interaction user_prompt.
Types ¶
This section is empty.