Emit Claude Code plugin hint at module load time - #2800
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a Claude Code “plugin hint” emission path to the Stripe Node SDK so that when running under Claude Code (detected via environment variables), the SDK writes the documented <claude-code-hint ... /> line to stderr to prompt installation of Stripe’s official plugin.
Changes:
- Introduces a
PlatformFunctions.writeStderr()hook (no-op by default; implemented for Node). - Emits the Claude Code plugin hint during
Stripe.initialize()whenCLAUDECODEorCLAUDE_CODE_CHILD_SESSIONis present. - Adds unit tests verifying hint emission / non-emission behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/stripe.spec.ts | Adds tests covering stderr hint emission when Claude env vars are present. |
| src/stripe.core.ts | Emits Claude Code plugin hint during platform initialization based on env vars. |
| src/platform/PlatformFunctions.ts | Adds a no-op writeStderr platform hook. |
| src/platform/NodePlatformFunctions.ts | Implements writeStderr via process.stderr.write. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (env?.CLAUDECODE || env?.CLAUDE_CODE_CHILD_SESSION) { | ||
| try { | ||
| platformFunctions.writeStderr( | ||
| '<claude-code-hint v="1" type="plugin" value="stripe@claude-plugins-official" />\n' | ||
| ); | ||
| } catch (_) { | ||
| // never let hint emission crash the SDK | ||
| } | ||
| } |
There was a problem hiding this comment.
@johno-stripe - this is correct, unfortunately. You'll need to add it in both places
| } catch (_) { | ||
| // never let hint emission crash the SDK | ||
| } |
xavdid
left a comment
There was a problem hiding this comment.
A couple of bits but looks good otherwise!
| if (env?.CLAUDECODE || env?.CLAUDE_CODE_CHILD_SESSION) { | ||
| try { | ||
| platformFunctions.writeStderr( | ||
| '<claude-code-hint v="1" type="plugin" value="stripe@claude-plugins-official" />\n' | ||
| ); | ||
| } catch (_) { | ||
| // never let hint emission crash the SDK | ||
| } | ||
| } |
There was a problem hiding this comment.
@johno-stripe - this is correct, unfortunately. You'll need to add it in both places
| } catch (_) { | ||
| // never let hint emission crash the SDK | ||
| } |
Pull request was closed
Why?
Claude Code supports a plugin hint feature, where if we detect the
CLAUDECODEorCLAUDE_CODE_CHILD_SESSIONenvironment variables, emitting the following string will prompt the user to install our official plugin:<claude-code-hint v="1" type="plugin" value="stripe@claude-plugins-official" />Our plugin's source code can be found here.
What?
Note that while this will fire frequently, Claude Code will automatically hide these log lines and keep the user from being re-prompted:
My first approach was to emit this using a post-install script, but npm unfortunately hides the output from the installing process, so those error logs didn't successfully reach Claude.
See Also
Key source here is the documentation on how plugin hints work:
Changelog
CLAUDECODEorCLAUDE_CODE_CHILD_SESSIONenvironment variables are detected.