Repository navigation
Conversation
When Claude Code runs the CLI without the Databricks plugin or skills, the install hint now also prints Claude Code's native `<claude-code-hint>` line (https://code.claude.com/docs/en/plugins/cli-hints), which makes Claude Code offer a one-click install of `databricks@claude-plugins-official`. - The native line prints only when CLAUDE_CODE_CHILD_SESSION is set, outside CI, and when no standard stream is a terminal. It shares the text hint's per-session throttle and logs a CLAUDE_CODE_NATIVE hint event. - Only tooling Claude Code itself loads (Agent.DatabricksTooling) silences the hint; skills only in the shared ~/.databricks stores no longer do. - `auth token`, `auth docker token` and CLI processes started by the CLI (DATABRICKS_CLI_SELF_EXEC, set by `air images push` and `apps init`) print no install hint. - `cmdio.HasTerminal` (any standard stream is a TTY) and `cmdio.FakeTTYReader` for tests. - Telemetry docs: one `aitools_hint_event` per printed hint line. Co-authored-by: Isaac <no-reply@databricks.com>
028eb23 to
07a831d
Compare
|
Commit: Regression test reportSelected 3 changed tests (limit=20, 0 not selected) 3 tests: regression=3 unreleased=0 coverage=0 failing=0
TestAccept/air/image-push: branch ✅ | main (eeb4ef9) ❌ | latest (v1.26.0) ❌main (eeb4ef9): latest (v1.26.0): same output as main (eeb4ef9) TestAccept/cmd/aitools/claude-config-dir: branch ✅ | main (eeb4ef9) ❌ | latest (v1.26.0) ❌main (eeb4ef9): latest (v1.26.0): same output as main (eeb4ef9) TestAccept/cmd/aitools/telemetry/hint: branch ✅ | main (eeb4ef9) ❌ | latest (v1.26.0) ❌main (eeb4ef9): latest (v1.26.0): |
✅ Integration test reportCommit: 07a831d
Top 6 slowest tests (at least 2 minutes):
|
simonfaltum
left a comment
There was a problem hiding this comment.
🤖 Automated review from simonfaltum's review agent (pr-review skill) at 07a831d. Each finding was verified against the code; simonfaltum may follow up.
No blocking issues found, approving. 10 non-blocking comment(s) and 3 question(s) below.
This PR prints Claude Code's native <claude-code-hint> line next to the existing text hint, bases Claude Code install detection on what Claude Code itself loads, and stops hinting in auth token, auth docker token and CLI processes started by the CLI. The tag format, stderr placement and CLAUDE_CODE_CHILD_SESSION gate match Claude Code's docs, the tests are thorough, and CI is green. I found nothing blocking. There are two nice-to-have points: a subagent or hook call can use up the session's throttle without ever showing the dialog, and apps init still treats shared-store skills as installed for Claude Code. There are also a few nits and three non-blocking questions about scope, the single-agent abstraction and the extra CI and terminal gates.
Questions
- This PR changes four things: the native hint; which installs count for Claude Code (shared-store skills no longer count, and project or local plugins count only inside their project); the
auth token/auth docker tokenand self-exec exclusions; and theagentHintrefactor. AGENTS.md asks for one change per PR. The exclusions look like a prerequisite for the native line, because Claude Code can't strip a tag embedded mid-line. Would you move the detection change, and possibly the refactor, into separate PRs, or do they need to land together? (non-blocking) agentHint,hintForAgent(a switch with one case), the nil check innativeLine, the empty check insessionIDandTestAgentHint_NativeLineNilIsEmptyexist for agents that don't have a hint yet. AGENTS.md asks for simplicity and no speculative flexibility. Would you keep the direct Claude Code check plus a few lines for the native line, and add the table when a second agent needs it? (non-blocking)- The cli-hints docs only ask for the
CLAUDECODE/CLAUDE_CODE_CHILD_SESSIONgate, and Claude Code itself never prompts in-p, subagent, hook or unattended runs. The CI and terminal checks add an 11-variable CI list to three acceptance scripts. If some Claude Code surface runs tools with a terminal on any stream, the native line silently never prints, and telemetry would not show it because it only counts printed lines. Was the dialog checked end to end in an attended session (the description notes Windows and macOS were not tested)? Are both checks needed? (non-blocking)
Comments outside the changed lines
- [nit]
libs/aitools/agents/hint_test.go:254: This test still writessome-other-skillinto the shared store, whichclaudeToolingInstalledno longer reads, so it passes whatever the prefix filter does. UsewriteClaudeSkillso it checks that a non-Databricks skill in~/.claude/skillsdoesn't silence the hint. - [nit]
.github/PULL_REQUEST_TEMPLATE.md: The description uses## Summary,## Evidenceand## Merge Danger..agents/skills/pr-checklist/SKILL.mdasks for the template's## Changes,## Whyand## Tests, in that order and with no extra sections, and recent merged PRs follow it. Suggest moving the content under those headings.
| if native := hint.nativeLine(ctx); native != "" { | ||
| cmdio.LogString(ctx, native) | ||
| logHintShown(ctx, hint.nativeKind) | ||
| } | ||
| cmdio.LogString(ctx, hint.text) | ||
| logHintShown(ctx, hint.textKind) | ||
| recordSessionHint(ctx, hint.sessionEnv) |
There was a problem hiding this comment.
[nice to have] The session marker is written whenever the text line prints, including when the native line printed somewhere Claude Code never shows the dialog. A subagent's Bash calls carry the parent's CLAUDE_CODE_SESSION_ID and CLAUDE_CODE_CHILD_SESSION=1, and the cli-hints docs say subagent runs and hook output strip the tag without prompting. So when a subagent or a hook makes the session's first databricks call, the main loop's commands print neither line for the next hour, and a session shorter than an hour never sees the dialog. The same happens when the native line is withheld because a terminal is attached. Consider throttling the native line under its own key, and not writing that key when the line was withheld. A shorter TTL for the native line would also limit the subagent and hook case, since Claude Code already shows the dialog at most once per session.
| // claudeToolingInstalled reports whether Claude Code has Databricks AI tooling | ||
| // in its own locations (see Agent.DatabricksTooling): the databricks plugin, or | ||
| // databricks skills in Claude's skills dirs. Skills present only in the shared | ||
| // ~/.databricks/aitools/skills store don't count, because Claude Code doesn't | ||
| // load them from there. Any read/parse failure reports false, so an unreadable | ||
| // state errs toward hinting. |
There was a problem hiding this comment.
[nice to have] This comment now says Claude Code doesn't load skills from the shared ~/.databricks/aitools/skills store. But HasDatabricksToolingInstalled (skills.go:23-33), which apps init uses, still treats shared-store skills as covering every agent, Claude Code included. With skills only in the shared store, databricks apps init under Claude Code prints this hint ("Databricks skills are not installed…") from the root hook, while the command's own check reports the tooling as installed and skips its tip. A human running apps init with Claude Code detected is never offered the install either. Either switch HasDatabricksToolingInstalled to per-agent DatabricksTooling, or say in both comments why they differ. A follow-up PR is fine.
| tooling := claude.DatabricksTooling(ctx, func() bool { return false }) | ||
| if tooling == ToolingPlugin { | ||
| version, _ := claude.DatabricksPluginVersion(ctx) | ||
| log.Debugf(ctx, "Databricks plugin detected for Claude Code (version %q); skipping install hint", version) |
There was a problem hiding this comment.
[nit] WithCallingAgentToolingInUserAgent (cmd/root/root.go:88) already computes DatabricksTooling for Claude Code right before MaybeHint. On the plugin path, DatabricksPluginVersion then parses installed_plugins.json a third time just for a debug log, and because the throttle is never written once the plugin is installed, this runs on every command. Also, func() bool { return false } duplicates noRecordedPlugin in recommend.go:45, and the Go style guide asks for a named function. Suggest dropping the version from the debug line and adding a package-level noRecordedPlugin for both callers.
| export CLAUDE_CODE_CHILD_SESSION=1 | ||
| unset CLAUDE_CODE_SESSION_ID | ||
| # CI and the CI/CD provider markers the SDK detects (GitHub Actions sets both). | ||
| unset CI GITHUB_ACTIONS GITLAB_CI JENKINS_URL TF_BUILD CIRCLECI TRAVIS BITBUCKET_BUILD_NUMBER PROJECT_ID CODEBUILD_BUILD_ARN TFC_RUN_ID |
There was a problem hiding this comment.
[nit] The same unset CI GITHUB_ACTIONS … TFC_RUN_ID line, which mirrors the SDK's CI provider list, appears here, in telemetry/hint/script:7 and in air/image-push/script:69, and again as hintEnvVars in hint_test.go. If the SDK adds a provider, the native line disappears only when tests run on that provider's CI, and four copies need updating. .agents/rules/testing.md says shared bash helpers go in a parent script.prepare, and an unset_ci_env helper there would keep a single copy.
| // in parallel (see testutil.SetAgentEnv). The first t.TempDir call runs before | ||
| // SetAgentEnv clears TMPDIR / TEMP, so later calls in the test still work. | ||
| // It also moves into an empty project with its own .git boundary, so project | ||
| // skills in the checkout running the tests are not detected. | ||
| func setClaudeAgent(t *testing.T) { | ||
| cwd := t.TempDir() | ||
| require.NoError(t, os.Mkdir(filepath.Join(cwd, ".git"), 0o755)) | ||
| t.Chdir(cwd) | ||
| testutil.SetAgentEnv(t, "CLAUDECODE", "1") | ||
| unsetEnv(t, hintEnvVars) |
There was a problem hiding this comment.
[nit] testutil.SetAgentEnv already clears the environment (NullEnvironment → os.Clearenv) and keeps TMPDIR, TEMP and TMP. So unsetEnv(t, hintEnvVars) right after it, here and at line 467, does nothing, and the sentence saying SetAgentEnv clears TMPDIR/TEMP is wrong. Suggest dropping those two calls and that sentence. hintEnvVars is then needed only in TestClaudeToolingInstalled_LogsPluginVersion, where only CLAUDE_CONFIG_DIR matters.
| // Claude Code's own manifest decides, so the CLI's install record is never | ||
| // consulted for it. | ||
| tooling := claude.DatabricksTooling(ctx, func() bool { return false }) |
There was a problem hiding this comment.
[nit] Plugin records with project or local scope now count only when the CLI's working directory is inside the recorded project. Claude Code loads them from the directory it started in, which the CLI can't see. So a session started in ~/repo with a project-scoped plugin that runs cd /tmp/scratch && databricks jobs list is now told "Databricks skills are not installed". Before this PR, any plugin record kept the hint quiet. The description and the changelog mention the shared-store change but not this one. Please add it there, or keep counting project and local records if a false hint is worse than a missed one.
| // TF_BUILD, which doesn't set CI). | ||
| func inCI(ctx context.Context) bool { | ||
| if v := env.Get(ctx, ciEnv); v != "" { | ||
| if b, err := strconv.ParseBool(v); err != nil || b { |
There was a problem hiding this comment.
[nit] strconv.ParseBool fails on no and off, so CI=no or CI=off counts as CI here and the native line is dropped. libs/versioncheck reads the same variable with env.GetBool, which treats those values as false. Treat no and off as false too, by checking them before the ParseBool fallback.
| @@ -0,0 +1 @@ | |||
| * When Claude Code runs the CLI without the Databricks plugin or skills, the CLI now also prints Claude Code's native `<claude-code-hint>` line, at most once per hour per Claude Code session together with the text hint, so Claude Code offers a one-click install of the Databricks plugin. Skills stored only in `~/.databricks/aitools/skills` or the legacy `~/.databricks/agent-skills` no longer count as installed for Claude Code, and `databricks auth token`, `databricks auth docker token` and the CLI commands that `databricks air images push` and `databricks apps init` run as subprocesses no longer print install hints. ([#7585](https://github.com/databricks/cli/pull/7585)) | |||
There was a problem hiding this comment.
[nit] .agents/skills/pr-checklist/SKILL.md asks for entries that start with a verb, or with the affected command followed by "now". This one opens with a "When…" clause. At 678 characters it is also the longest fragment in .nextchanges/cli and puts four changes in one line. Suggest leading with the change, e.g. "Print Claude Code's native plugin install hint when…", and keeping the detection and auth token notes short.
Summary
When Claude Code runs the CLI without the Databricks plugin or skills, the install hint now also prints Claude Code's native
<claude-code-hint>line, which makes Claude Code offer a one-click install ofdatabricks@claude-plugins-official.cmdio.HasTerminal(any standard stream is a TTY) andcmdio.FakeTTYReaderfor tests.agents.SelfExecEnvis set on the child processes ofair images push(auth docker configure) andapps init(post-create deploy/dev runs).protos/README.md,aitools_events.go): oneaitools_hint_eventper printed hint line..nextchanges/cli/claude-code-native-hint.md.Evidence
Run at this head with the host's agent and CI env scrubbed.
MaybeHintremoved, tests unchanged):TestAccept/air/image-push: inside a simulated Claude Code session, theauth docker configurechild adds no hint to the parent's output or to its error text.TestMaybeHint_NativeHintalso covers: CI (CI=true,CI=<provider name>,TF_BUILD) prints the text only; plugin or Claude skills installed prints nothing;auth token,auth docker token, self-exec and aitools commands print nothing.TestMaybeHint_NativeHintSilentOnTerminal: a terminal on stdin, stdout or stderr drops the native line.Merge Danger
Door: two-way
Pure CLI output and telemetry change; reverting removes the line. No exit code changes and no extra network calls.
Blast Radius: small
2>&1 | jqpipeline in that command reads it raw. With the file cache disabled, both lines print on every eligible command.~/.databricks/aitools/skillsor~/.databricks/agent-skillsno longer silence the hint for Claude Code.auth token,auth docker tokenand CLI-spawned CLI processes no longer print any install hint.CLAUDE_CODE_NATIVE, is logged.This pull request and its description were written by Isaac.