claudecode

package
v0.7.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
const SubagentTypeField = "subagent_type"

SubagentTypeField is the argument of a SubagentTools call that names the subagent's type.

View Source
const ToolSearch = "ToolSearch"

ToolSearch is Claude Code's own client-side tool search tool.

Variables

View Source
var AskHumanTools = []string{"AskUserQuestion", "ExitPlanMode"}

AskHumanTools are the tools whose call waits on a person, not on the tool itself.

View Source
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.

View Source
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.

View Source
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.

View Source
var QuestionTools = []string{"AskUserQuestion"}

QuestionTools are the AskHumanTools that ask a question. The others (ExitPlanMode) ask for an approval.

View Source
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.

View Source
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.

View Source
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

func AgentID(h http.Header) string

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

func IsSkillReloadNotice(n string) bool

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.

func UserID added in v0.7.11

func UserID(body []byte) string

UserID is the `metadata.user_id` of a request body: Claude Code's one per-person id. It is a JSON object in a string ({"device_id":...,"session_id":...}); the session package parses it. "" when the body has none (any other client).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL