Skip to content

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

Open
johno-stripe wants to merge 4 commits into
masterfrom
johno/claude-plugin-hint
Open

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

Conversation

@johno-stripe

Copy link
Copy Markdown
Owner

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.

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.

1 participant