Skip to content

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

Merged
johno-stripe merged 7 commits into
masterfrom
johno/claude-plugin-hint
Aug 7, 2026
Merged

Emit Claude Code plugin hint at module load time#1867
johno-stripe merged 7 commits into
masterfrom
johno/claude-plugin-hint

Conversation

@johno-stripe

@johno-stripe johno-stripe commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Why?

Claude Code supports a plugin hint protocol: if an SDK writes a specific XML tag to stderr at import time, Claude Code picks it up and loads the associated plugin automatically. Adding this hint to stripe-python means any user running Claude Code against Python code that imports stripe will get the Stripe plugin loaded without any manual setup.

What?

  • Adds _claude_code_hint() and _emit_claude_code_hint() to stripe/_util.py. Both are internal and not re-exported from the package.
  • Calls _emit_claude_code_hint() from stripe/__init__.py at module load time, just before the generated section. Gated on CLAUDECODE or CLAUDE_CODE_CHILD_SESSION being set, wrapped in try/except so it can never raise.
  • Adds TestEmitClaudeCodeHint to tests/test_util.py with three cases: emits on CLAUDECODE, emits on CLAUDE_CODE_CHILD_SESSION, silent when neither is set.
  • Updates assert_output in tests/test_exports.py to strip the hint line from stderr before asserting it's clean, so existing import tests pass whether or not Claude env vars are set in the outer process (for example, if a Stripe is editing this SDK using Claude Code).

See Also

Changelog

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

@johno-stripe
johno-stripe requested a review from a team as a code owner August 6, 2026 21:10
@johno-stripe
johno-stripe requested review from kidus-stripe and removed request for a team August 6, 2026 21:10
@johno-stripe
johno-stripe enabled auto-merge (squash) August 6, 2026 21:12
@johno-stripe
johno-stripe merged commit 5b2260a into master Aug 7, 2026
17 checks passed
@johno-stripe
johno-stripe deleted the johno/claude-plugin-hint branch August 7, 2026 03:39
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.

2 participants