Skip to content

feat: recommend the official Slack plugin to Claude Code users#615

Open
zimeg wants to merge 10 commits into
mainfrom
add-claude-code-plugin-hint
Open

feat: recommend the official Slack plugin to Claude Code users#615
zimeg wants to merge 10 commits into
mainfrom
add-claude-code-plugin-hint

Conversation

@zimeg

@zimeg zimeg commented Jul 14, 2026

Copy link
Copy Markdown
Member

Changelog

The CLI now recommends the official Slack plugin to Claude Code users. No change for anyone running the CLI outside Claude Code.

Summary

When the CLI runs inside Claude Code (detected via CLAUDECODE=1), it emits a one-line <claude-code-hint /> marker to stderr recommending the official slack@claude-plugins-official plugin. Claude Code strips the marker before the output reaches the model (so it never counts toward token usage), dedupes it per plugin and per session, and shows the user a one-time install prompt. Claude Code never installs anything automatically — the user always confirms.

Protocol reference: https://code.claude.com/docs/en/plugin-hints

Design decisions worth calling out:

  • Placement. The emitter lives beside the existing CLAUDECODE detection (GetAIAgent) in internal/useragent, since that package already owns "behavior conditioned on which AI agent is running us." A dedicated internal/plugins (or internal/agents) package felt premature for a ~10-line, single-vendor feature — Codex/Gemini/etc. have no equivalent protocol today. If a second agent-conditioned behavior or a second vendor protocol lands, that's the trigger to extract.
  • Two call sites. root.go's PersistentPreRunE covers every normal subcommand. Cobra serves --help before PersistentPreRunE runs, so the custom help func (cmd/help/help.go) needs its own emit to cover slack --help and slack <cmd> --help (two of the touchpoints the docs recommend).
  • stderr, on its own line. The marker is written to stderr via IO.WriteErr() so it stays out of stdout pipelines and out of the help text, and the protocol's one hard requirement (own line) is satisfied by Fprintln.

Preview

Emitted on stderr only when CLAUDECODE=1:

$ CLAUDECODE=1 slack version 2>&1 1>/dev/null
<claude-code-hint v="1" type="plugin" value="slack@claude-plugins-official" />

Nothing is emitted otherwise.

Testing

Unit tests:

  • internal/useragent/hint_test.go — emits on its own line when CLAUDECODE=1; no-op when unset or set to another value.
  • cmd/help/help_test.go — help func emits the hint on stderr (not stdout) inside Claude Code; nothing outside.

Manual end-to-end against a built binary:

  • CLAUDECODE=1 slack version → 1 hint on stderr, 0 on stdout ✅
  • slack version (no CLAUDECODE) → 0 bytes on stderr ✅
  • CLAUDECODE=1 slack --help and slack auth --help → 1 hint on stderr each, help text unaffected on stdout ✅
  • slack --help without CLAUDECODE → 0 ✅

go build ./..., go test ./cmd/... ./internal/useragent/..., and golangci-lint on the touched packages all pass.

Notes

  • Depends on an official-marketplace listing. The hint only renders for plugins in Anthropic's curated claude-plugins-official marketplace; hints pointing elsewhere are silently dropped. Until a slack plugin is listed there, this marker is emitted but not shown. This needs to be coordinated with an Anthropic contact — flagging so it isn't a surprise.
  • Emitting on every invocation is intentional and has no downside: Claude Code dedupes by plugin and shows at most one hint prompt per session.

Requirements

🤖 Generated with Claude Code

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.73%. Comparing base (a265b95) to head (7c560ad).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
cmd/root.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #615      +/-   ##
==========================================
+ Coverage   71.72%   71.73%   +0.01%     
==========================================
  Files         226      227       +1     
  Lines       19182    19188       +6     
==========================================
+ Hits        13758    13765       +7     
+ Misses       4214     4213       -1     
  Partials     1210     1210              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

zimeg added 10 commits July 14, 2026 14:41
When the CLI runs inside Claude Code (detected via CLAUDECODE=1), emit a
one-line <claude-code-hint /> marker to stderr recommending the official
slack@claude-plugins-official plugin. Claude Code strips the marker before
it reaches the model, dedupes it per plugin/session, and shows a one-time
install prompt. It is a no-op in every other environment.

The emitter lives beside the existing CLAUDECODE detection in
internal/useragent. It is called from root.go's PersistentPreRunE (covers
every normal subcommand) and from the custom help func (Cobra serves --help
before PersistentPreRunE runs, so those paths need their own emit).

See https://code.claude.com/docs/en/plugin-hints.
@zimeg zimeg force-pushed the add-claude-code-plugin-hint branch from 0eddb87 to 7c560ad Compare July 14, 2026 21:42
@zimeg zimeg added semver:minor Use on pull requests to describe the release version increment enhancement M-T: A feature request for new functionality changelog Use on updates to be included in the release notes labels Jul 14, 2026
@zimeg zimeg self-assigned this Jul 14, 2026

@zimeg zimeg left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

📝 A note for reviewers before I fall into too much a rabbit hole.

// users of Claude Code.
//
// https://code.claude.com/docs/en/plugin-hints
const claudeCodePluginHint = `<claude-code-hint v="1" type="plugin" value="slack@claude-plugins-official" />`

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

⚠️ note: I can't seem to have claude prompt but this matches spec!

@zimeg zimeg marked this pull request as ready for review July 14, 2026 22:01
@zimeg zimeg requested a review from a team as a code owner July 14, 2026 22:01
@zimeg zimeg added this to the Next Release milestone Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog Use on updates to be included in the release notes enhancement M-T: A feature request for new functionality semver:minor Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant