How it works
Claude Code sets theCLAUDECODE environment variable to 1 for every command it runs through the Bash and PowerShell tools, and for hook commands. From v2.1.172 it also sets CLAUDE_CODE_CHILD_SESSION to 1 in those same subprocesses. When your CLI sees one of these variables, it writes a self-closing <claude-code-hint /> tag to stderr. In hook commands the hint tag is stripped and ignored. Only Bash and PowerShell tool output triggers the install prompt.
When Claude Code receives the command output, it:
- Scans for hint lines and removes them before the output reaches the model
- Checks that the hint targets a plugin in an official Anthropic marketplace
- Checks that the plugin is not already installed and has not been prompted before
- Shows the user an install prompt that names the command that emitted the hint
Emit the hint
Hint prompts only fire for plugins listed in the official Anthropic marketplace. See Get your plugin into the official marketplace before you ship the integration. Gate emission on an environment variable so the marker is unlikely to appear when a human runs your CLI directly, then write the tag to stderr on its own line. Choose which variable to check:CLAUDECODE: set on every Claude Code version, so it reaches the most sessions. It is also set in tmux sessions and stdio MCP server subprocesses that Claude Code starts. IDE extensions also set it in their integrated terminals, where a human may be running your CLI directly.CLAUDE_CODE_CHILD_SESSION: set only in subprocesses Claude Code itself spawns, such as tool calls, hook commands, and status line commands, so the tag does not normally reach a human terminal. A long-lived process that was started inside a session, such as a tmux server, captures the variable, so shells later launched from that process still show the raw tag. Requires Claude Code v2.1.172 or later, so sessions on older versions miss the hint.
CLAUDECODE for maximum reach and emit a hint for a plugin named example-cli in the official marketplace:
example-cli with your plugin’s name in the official marketplace.