Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nextchanges/cli/claude-code-native-hint.md
Original file line number Diff line number Diff line change
@@ -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))

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.

[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.

4 changes: 4 additions & 0 deletions acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ func testAccept(t *testing.T, inprocessMode bool, selectedTests []string, skipTo
os.Unsetenv(v) //nolint:usetesting // t.Setenv cannot unset
}

// Claude Code sets this in the commands it runs; it enables the native
// <claude-code-hint> line, so a host Claude Code session must not leak it.
os.Unsetenv("CLAUDE_CODE_CHILD_SESSION") //nolint:usetesting // t.Setenv cannot unset

// environments setup-local follows uv's UV_PROJECT_ENVIRONMENT, so a value
// from the host shell would move the venv the localenv tests expect.
os.Unsetenv("UV_PROJECT_ENVIRONMENT") //nolint:usetesting // t.Setenv cannot unset
Expand Down
24 changes: 24 additions & 0 deletions acceptance/air/image-push/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,27 @@ image inspect --format {{.Os}}/{{.Architecture}} example/image:v1
pull --platform linux/amd64 example/image:v1
image inspect --format {{.Os}}/{{.Architecture}} example/image:v1
pull --platform linux/amd64 example/image:v1

=== in a Claude Code session the auth docker configure child adds no install hint

>>> databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training
<claude-code-hint v="1" type="plugin" value="databricks@claude-plugins-official" />
Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features.
Pushing example/image:v1 as main.training.image:v1 using profile docker-test
Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.localhost
Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json
Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks
Using local source image example/image:v1
Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1
Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1
Docker push progress
Pushed image.
Now you can set `environment.unity_catalog_image = main.training.image:v1` in your YAML config and create a workload with `databricks air run -f config.yaml`.

>>> musterr databricks air images push -p pat-test -s example/image:v1 --catalog main --schema training
<claude-code-hint v="1" type="plugin" value="databricks@claude-plugins-official" />
Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features.
Pushing example/image:v1 as main.training.image:v1 using profile pat-test
Error: configure Docker authentication: run auth docker configure: exit status 1: Error: profile "pat-test" uses auth_type "pat". Docker credential helper requires a profile created by databricks auth login
19 changes: 19 additions & 0 deletions acceptance/air/image-push/script
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,22 @@ cmp "$DOCKER_LOG" "$HOME/docker.before-length.log"

title "all docker commands"
cat "$DOCKER_LOG"

title "in a Claude Code session the auth docker configure child adds no install hint"
# As in a Claude Code tool call, with no session id, so the session throttle
# can't be what keeps the child quiet. The CI variables would drop the native
# line in CI only.
unset CI GITHUB_ACTIONS GITLAB_CI JENKINS_URL TF_BUILD CIRCLECI TRAVIS BITBUCKET_BUILD_NUMBER PROJECT_ID CODEBUILD_BUILD_ARN TFC_RUN_ID CLAUDE_CODE_SESSION_ID
# A host CLAUDE_CONFIG_DIR would move the plugin lookup away from the isolated HOME.
unset CLAUDE_CONFIG_DIR
export CLAUDECODE=1 CLAUDE_CODE_CHILD_SESSION=1
trace databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training
cat >> "$HOME/.databrickscfg" <<ENDCFG
[pat-test]
host = $DATABRICKS_HOST_ORIG
token = dapi-test
auth_type = pat
ENDCFG
# The failing child's output is embedded mid-line in the error, where Claude
# Code can't strip a native line.
trace musterr databricks air images push -p pat-test -s example/image:v1 --catalog main --schema training
17 changes: 17 additions & 0 deletions acceptance/cmd/aitools/claude-config-dir/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Databricks CLI v[CLI_VERSION]
=== Custom directory takes precedence over the default installation

>>> CLAUDE_CONFIG_DIR=missing [CLI] version
<claude-code-hint v="1" type="plugin" value="databricks@claude-plugins-official" />
Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
Databricks CLI v[CLI_VERSION]

Expand All @@ -19,3 +20,19 @@ Databricks CLI v[CLI_VERSION]

>>> [CLI] version
Databricks CLI v[CLI_VERSION]

=== Outside a Claude Code subprocess only the text hint prints

>>> CLAUDE_CODE_CHILD_SESSION= [CLI] version
Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
Databricks CLI v[CLI_VERSION]

=== Within one session both lines print once, so 2>&1 pipelines see them only on the first command

>>> [CLI] version
<claude-code-hint v="1" type="plugin" value="databricks@claude-plugins-official" />
Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
Databricks CLI v[CLI_VERSION]

>>> [CLI] version
Databricks CLI v[CLI_VERSION]
17 changes: 17 additions & 0 deletions acceptance/cmd/aitools/claude-config-dir/script
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
export CLAUDECODE=1
# Claude Code sets CLAUDE_CODE_CHILD_SESSION in the commands it runs, which
# enables the native <claude-code-hint> line; CI suppresses it.
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

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.

[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.


# aitools commands skip the install hint; version exercises it without auth or network.
sethome ./empty-home
Expand All @@ -16,3 +21,15 @@ trace CLAUDE_CONFIG_DIR= $CLI version
title "Unset override uses the default installation"
unset CLAUDE_CONFIG_DIR
trace $CLI version

sethome ./empty-home
title "Outside a Claude Code subprocess only the text hint prints"
trace CLAUDE_CODE_CHILD_SESSION= $CLI version

# The session throttle lives in the file cache, which a host could disable.
export DATABRICKS_CACHE_ENABLED=true
title "Within one session both lines print once, so 2>&1 pipelines see them only on the first command"
export CLAUDE_CODE_SESSION_ID=session-1
trace $CLI version
trace $CLI version
unset CLAUDE_CODE_SESSION_ID
5 changes: 4 additions & 1 deletion acceptance/cmd/aitools/telemetry/hint/output.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@

=== hint printed on an authenticated command: one hint-shown event is uploaded
=== hint printed on an authenticated command: one hint-shown event per printed line is uploaded

>>> [CLI] jobs list
<claude-code-hint v="1" type="plugin" value="databricks@claude-plugins-official" />
Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install

>>> print_telemetry
{"command":"jobs_list","exit_code":0,"aitools_hint_event":{"hint_kind":"CLAUDE_CODE_NATIVE"}}
{"command":"jobs_list","exit_code":0,"aitools_hint_event":{"hint_kind":"INSTALL_TEXT"}}

=== hint printed on a command that resolves no auth: nothing is uploaded

>>> [CLI] version
<claude-code-hint v="1" type="plugin" value="databricks@claude-plugins-official" />
Databricks skills are not installed. To work with Databricks reliably, first run: databricks aitools install
Databricks CLI v[CLI_VERSION]

Expand Down
6 changes: 5 additions & 1 deletion acceptance/cmd/aitools/telemetry/hint/script
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Isolate HOME so the real machine's plugins and skills are not seen.
sethome home
export CLAUDECODE=1
# As inside Claude Code: enables the native <claude-code-hint> line (not in CI).
export CLAUDE_CODE_CHILD_SESSION=1
# 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
unset CLAUDE_CODE_SESSION_ID
# A host CLAUDE_CONFIG_DIR would move the plugin file away from the isolated HOME.
unset CLAUDE_CONFIG_DIR

title "hint printed on an authenticated command: one hint-shown event is uploaded"
title "hint printed on an authenticated command: one hint-shown event per printed line is uploaded"
trace $CLI jobs list
trace print_telemetry

Expand Down
2 changes: 2 additions & 0 deletions cmd/air/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"sync"

"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/aitools/agents"
"github.com/databricks/cli/libs/cmdctx"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/flags"
Expand Down Expand Up @@ -72,6 +73,7 @@ func configureImageDocker(ctx context.Context, profile string) (string, error) {

var output bytes.Buffer
cmd := exec.CommandContext(ctx, executable, "auth", "docker", "configure", profile)
cmd.Env = agents.SelfExecEnv(os.Environ())
cmd.Stdout = &output
cmd.Stderr = &output
if err := cmd.Run(); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions cmd/apps/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,7 @@ func runPostCreateDeploy(ctx context.Context, profile string) error {
args = append(args, "--profile", profile)
}
cmd := exec.CommandContext(ctx, executable, args...)
cmd.Env = agents.SelfExecEnv(os.Environ())
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
Expand Down Expand Up @@ -1992,6 +1993,7 @@ func runPostCreateDev(ctx context.Context, mode prompt.RunMode, projectInit init
args = append(args, "--profile", profile)
}
cmd := exec.CommandContext(ctx, executable, args...)
cmd.Env = agents.SelfExecEnv(os.Environ())
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
Expand Down
4 changes: 2 additions & 2 deletions libs/aitools/agents/calling.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func (t Tooling) String() string {
// record. For Codex and Copilot, pluginRecorded (the CLI install state) is the
// only plugin source, so it misses plugins installed with the agent's own CLI
// and includes plugins later removed with it. The shared skills store is not consulted: it cannot attribute skills.
// The install hint's claudeToolingInstalled differs on purpose: it stays quiet
// for any trace of an install, while this reports what the agent loads.
// The install hint uses it too, so Claude Code is hinted exactly when it loads
// no Databricks tooling.
func (a *Agent) DatabricksTooling(ctx context.Context, pluginRecorded func() bool) Tooling {
// An unknown working directory skips the project lookups below.
cwd := ""
Expand Down
Loading
Loading