Skip to content

Emit Claude Code plugin hint at module load time - #2800

Closed
johno-stripe wants to merge 2 commits into
stripe:masterfrom
johno-stripe:johno/claude-plugin-hint
Closed

Emit Claude Code plugin hint at module load time#2800
johno-stripe wants to merge 2 commits into
stripe:masterfrom
johno-stripe:johno/claude-plugin-hint

Conversation

@johno-stripe

Copy link
Copy Markdown
Contributor

Why?

Claude Code supports a plugin hint feature, where if we detect the CLAUDECODE or CLAUDE_CODE_CHILD_SESSION environment 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?

  • Sets up a platform function for writing to stderr, void by default, implemented for Node.
  • During initialization, checks to see if either variable is set. If so, emits the relevant log line.

Note that while this will fire frequently, Claude Code will automatically hide these log lines and keep the user from being re-prompted:

Claude Code deduplicates by plugin, so emitting on every invocation has no downside (source)

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

  • Emits new Claude Code plugin hint when CLAUDECODE or CLAUDE_CODE_CHILD_SESSION environment variables are detected.

Copilot AI review requested due to automatic review settings July 31, 2026 20:24
@johno-stripe
johno-stripe requested a review from a team as a code owner July 31, 2026 20:24
@johno-stripe
johno-stripe requested review from xavdid and removed request for a team July 31, 2026 20:24
@johno-stripe
johno-stripe enabled auto-merge (squash) July 31, 2026 20:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() when CLAUDECODE or CLAUDE_CODE_CHILD_SESSION is 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.

Comment thread src/stripe.core.ts
Comment on lines +1094 to +1102
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
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johno-stripe - this is correct, unfortunately. You'll need to add it in both places

Comment thread src/stripe.core.ts
Comment on lines +1099 to +1101
} catch (_) {
// never let hint emission crash the SDK
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this one too

@xavdid xavdid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of bits but looks good otherwise!

Comment thread src/stripe.core.ts
Comment on lines +1094 to +1102
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
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johno-stripe - this is correct, unfortunately. You'll need to add it in both places

Comment thread src/stripe.core.ts
Comment on lines +1099 to +1101
} catch (_) {
// never let hint emission crash the SDK
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this one too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants