Skip to content

libs/skills: leave out skills whose names the installer rejects - #8132

Open
simonfaltum wants to merge 22 commits into
mainfrom
skills/kname-the-skills-catalog-skips-skill-names-the
Open

simonfaltum wants to merge 22 commits into
mainfrom
skills/kname-the-skills-catalog-skips-skill-names-the

Conversation

@simonfaltum

@simonfaltum simonfaltum commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

The skills catalog now leaves out any skill whose name the installer would reject: a name longer than 64 characters, or one that is not lowercase letters, digits and single hyphens. A hand-written DATABRICKS_SKILLS_DIR manifest could list such a name, and the printed databricks skills read commands then broke. Each skipped name is logged at debug level.

Changes

  • The name check moves from libs/aitools/installer into libs/skills as IsSkillName and MaxSkillNameLength. The installer calls it from there, with unchanged messages and behavior.
  • skills read and the help footer print a skill name without quotes or --, since the catalog never lists a name that starts with -. A file name that starts with - still gets --.
  • ReadFile returns ErrUnknownSkill for a name the catalog leaves out, so skills read-file cannot serve a skipped skill.

Why

The printed commands are not quoted, so a name with a space, a shell metacharacter or a leading hyphen cannot be run as printed. The installer already refuses these names. Skipping them in the catalog keeps the printed commands valid.

Skipping one skill, rather than failing the whole manifest, matches how the installer treats a skill it cannot install.

Decisions to review

  • Skip the skill rather than reject the manifest. A bad name is silent unless debug logging is on. The read commands for it then fail with an unknown skill error that names the skill.
  • IsSkillName is the Agent Skills name format. The installer also rejects Windows device names such as con. The installer still checks those, but the catalog does not check them yet, so such a name is listed.
  • IsSkillName is exported so the installer and the catalog use one check and cannot drift apart.

Tests

  • TestCatalogLeavesOutSkillNamesTheInstallerRejects: a manifest with alpha, -foo and a b lists only alpha.
  • TestReadFileRejectsSkillNameTheCatalogLeavesOut: ReadFile on -foo returns ErrUnknownSkill.
  • TestIsSkillName: valid and invalid names, including the 64-character limit.
  • TestWriteGroupHintLeavesOutSkillNameTheInstallerRejects: the footer lists only the valid skill, checked with require.Equal.
  • TestWriteGroupHint: a preview off case checks that the footer is empty with DATABRICKS_SKILLS_PREVIEW unset, even with hints on.
  • TestWriteReadTextEndsFlagsBeforeLeadingHyphenFile still checks a file name that starts with -.
  • Acceptance help/skills/hints-invalid-name (renamed from hints-hyphen) shows a footer that lists only the valid skill, and that skills read and skills read-file fail for -foo and skills read fails for a b.
  • go test passes for ./libs/skills/..., ./cmd/skills/... and ./libs/aitools/installer/.... TestAccept/cmd/skills, TestAccept/help/skills and TestAccept/quickstart/skills pass, and ./task fmt-q lint-q reports 0 issues.
  • Not tested: the debug log line, because no test asserts it.

This pull request and its description were written by Isaac.

simonfaltum and others added 9 commits November 27, 2026 14:06
`skills read` printed `databricks skills read-file <name> <path>` for each
supporting file. A name or path that starts with "-" was read by Cobra as a
flag when the agent ran the printed command. Print "--" before the arguments
when the name or the file starts with "-". Ordinary names print as before.

Co-authored-by: Isaac <no-reply@databricks.com>
…p footer

The help footer for a command group printed "databricks skills read <name>"
for each skill. A name that starts with "-" was read by Cobra as a flag when
the printed command ran. Print "--" before the name in that case. Ordinary
names print as before.

Co-authored-by: Isaac <no-reply@databricks.com>
Move the printed read-file case into the existing read acceptance test,
using the shared release fixture, instead of a separate hyphen directory.
The printed command is asserted with contains.py before it is run, and
the separate test.toml is dropped because the parent directory sets the
same variables.

Co-authored-by: Isaac <no-reply@databricks.com>
Add a skill named -foo to the shared acceptance release, and an acceptance
test that traces the footer under `jobs --help` and runs the printed
command, so the test covers the real root command rather than a bare
flag set. The libs/skills catalog test counts the release, so it moves to
four skills too.

Co-authored-by: Isaac <no-reply@databricks.com>
The installer accepts only skill names of lowercase letters, digits and
single hyphens, up to 64 characters. The skills catalog accepted any name
from a manifest, so a hand-written DATABRICKS_SKILLS_DIR manifest could
list a name with spaces, shell metacharacters or a leading hyphen, and
the printed commands broke.

The catalog now skips such a skill and logs its name at debug level. The
name check moves from the installer into libs/skills as IsSkillName, and
the installer uses it from there. Catalogs with valid names are unchanged.

Because the catalog only lists valid names, the help footer and the read
output no longer need "--" before a skill name. A file name that starts
with "-" still gets it.

Co-authored-by: Isaac <no-reply@databricks.com>
Merge skills/k2dash-printed-read-file-commands-survive-file at 2a5b94f.
Keep both release fixture changes: guide-skill gets -notes.md, and the
hint fixture adds the -foo skill.

Co-authored-by: Isaac <no-reply@databricks.com>
The catalog now skips a skill whose name the installer rejects, so a
"-foo" skill in the shared release no longer lists. Remove it from the
shared fixture and restore the skill count in resolve_test.go.

The hints-hyphen test gets its own manifest with "-foo" and a valid
skill, and shows that the help footer lists only the valid one.

Co-authored-by: Isaac <no-reply@databricks.com>
…ls/kname-the-skills-catalog-skips-skill-names-the

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Regression test report ✅

Commit: 2f779185a | Workflow run

Selected 3 changed tests (limit=20, 0 not selected)

3 tests: regression=1 unreleased=2 coverage=0 failing=0
test branch main (d1d57e6) latest (v1.28.0)
TestAccept/cmd/skills/list ✅ ✅ ❌
TestAccept/help/skills/hints ✅ ✅ ❌
TestAccept/help/skills/hints-invalid-name ✅ ❌ ❌
TestAccept/cmd/skills/list: branch ✅ | main (d1d57e6) ✅ | latest (v1.28.0) ❌

latest (v1.28.0):

acceptance_test.go:1406: Diff:
        --- cmd/skills/list/output.txt
        +++ /tmp/TestAcceptcmdskillslist1957878996/002/output.txt
        @@ -1,108 +1,5 @@
         
         >>> [CLI] skills list
        -Pick the skill whose description matches the task.
        -Read the skill before you act on it.
        +Error: unknown command "skills" for "databricks"
         
        -demo-skill: A skill for tests.
        -future-skill: A skill that needs a newer CLI.
        -guide-skill: A skill with a supporting file.
        -To read a skill, run: databricks skills read <name>
        -
        ->>> [CLI] skills list --experimental
        -Pick the skill whose description matches the task.
        -Read the skill before you act on it.
        -
        -demo-skill: A skill for tests.
        -future-skill: A skill that needs a newer CLI.
        -guide-skill: A skill with a supporting file.
        -preview-skill: An experimental skill for tests.
        -To read a skill, run: databricks skills read <name>
        -
        ->>> [CLI] skills list --output json
        -{
        -  "source": "[TESTROOT]/cmd/skills/release",
        -  "release_version": "0.0.1",
        -  "skills": [
        -    {
        -      "name": "demo-skill",
        -      "description": "A skill for tests.",
        -      "version": "0.0.1",
        -      "files": [
        -        "SKILL.md"
        -      ],
        -      "commands": [
        -        "fs",
        -        "air"
        -      ]
        -    },
        -    {
        -      "name": "future-skill",
        -      "description": "A skill that needs a newer CLI.",
        -      "version": "0.0.1",
        -      "files": [
        -        "SKILL.md"
        -      ],
        -      "commands": []
        -    },
        -    {
        -      "name": "guide-skill",
        -      "description": "A skill with a supporting file.",
        -      "version": "0.0.1",
        -      "files": [
        -        "SKILL.md",
        -        "references/guide.md",
        -        "-notes.md"
        -      ],
        -      "commands": []
        -    }
        -  ]
        -}
        -
        ->>> [CLI] skills list --output json --experimental
        -{
        -  "source": "[TESTROOT]/cmd/skills/release",
        -  "release_version": "0.0.1",
        -  "skills": [
        -    {
        -      "name": "demo-skill",
        -      "description": "A skill for tests.",
        -      "version": "0.0.1",
        -      "files": [
        -        "SKILL.md"
        -      ],
        -      "commands": [
        -        "fs",
        -        "air"
        -      ]
        -    },
        -    {
        -      "name": "future-skill",
        -      "description": "A skill that needs a newer CLI.",
        -      "version": "0.0.1",
        -      "files": [
        -        "SKILL.md"
        -      ],
        -      "commands": []
        -    },
        -    {
        -      "name": "guide-skill",
        -      "description": "A skill with a supporting file.",
        -      "version": "0.0.1",
        -      "files": [
        -        "SKILL.md",
        -        "references/guide.md",
        -        "-notes.md"
        -      ],
        -      "commands": []
        -    },
        -    {
        -      "name": "preview-skill",
        -      "description": "An experimental skill for tests.",
        -      "version": "0.0.2",
        -      "files": [
        -        "SKILL.md"
        -      ],
        -      "commands": []
        -    }
        -  ]
        -}
        +Exit code: 1
TestAccept/help/skills/hints: branch ✅ | main (d1d57e6) ✅ | latest (v1.28.0) ❌

latest (v1.28.0):

acceptance_test.go:1406: 
        	Error Trace:	/home/runner/work/cli/cli/libs/testdiff/testdiff.go:22
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1406
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1147
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:690
        	Error:      	Not equal: 
        	            	expected: "\n>>> [CLI] --help\nUse \"databricks [command] --help\" for more information about a command.\n\nCoding agents: run `databricks skills list` to find skills for the commands you use.\n\n>>> [CLI] fs --help\nUse \"databricks fs [command] --help\" for more information about a command.\n\nCoding agents: read the skills for this command group before you use it.\n  databricks skills read demo-skill\n\n>>> [CLI] air --help\n  Coding agent skill       databricks aitools install --skills-only --skills databricks-ai-runtime\n\nCoding agents: read the skills for this command group before you use it.\n  databricks skills read demo-skill\n\n>>> [CLI] auth --help\n\n>>> [CLI] fs ls --help\n"
        	            	actual  : "\n>>> [CLI] --help\n  -v, --version[=true|false]   version for databricks\n\nUse \"databricks [command] --help\" for more information about a command.\n\n>>> [CLI] fs --help\n  -p, --profile string       ~/.databrickscfg profile\n  -t, --target string        bundle target to use (if applicable)\n\nUse \"databricks fs [command] --help\" for more information about a command.\n\n>>> [CLI] air --help\n  YAML fields and example  databricks air run -h config\n  Quickstart (AWS)         https://docs.databricks.com/aws/en/machine-learning/ai-runtime/quickstart\n  Quickstart (Azure)       https://learn.microsoft.com/azure/databricks/machine-learning/ai-runtime/quickstart\n  Coding agent skill       databricks aitools install --skills-only --skills databricks-ai-runtime\n\n>>> [CLI] auth --help\n\n>>> [CLI] fs ls --help\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -2,17 +2,17 @@
        	            	 >>> [CLI] --help
        	            	+  -v, --version[=true|false]   version for databricks
        	            	+
        	            	 Use "databricks [command] --help" for more information about a command.
        	            	 
        	            	-Coding agents: run `databricks skills list` to find skills for the commands you use.
        	            	+>>> [CLI] fs --help
        	            	+  -p, --profile string       ~/.databrickscfg profile
        	            	+  -t, --target string        bundle target to use (if applicable)
        	            	 
        	            	->>> [CLI] fs --help
        	            	 Use "databricks fs [command] --help" for more information about a command.
        	            	 
        	            	-Coding agents: read the skills for this command group before you use it.
        	            	-  databricks skills read demo-skill
        	            	-
        	            	 >>> [CLI] air --help
        	            	+  YAML fields and example  databricks air run -h config
        	            	+  Quickstart (AWS)         https://docs.databricks.com/aws/en/machine-learning/ai-runtime/quickstart
        	            	+  Quickstart (Azure)       https://learn.microsoft.com/azure/databricks/machine-learning/ai-runtime/quickstart
        	            	   Coding agent skill       databricks aitools install --skills-only --skills databricks-ai-runtime
        	            	-
        	            	-Coding agents: read the skills for this command group before you use it.
        	            	-  databricks skills read demo-skill
        	            	 
        	Test:       	TestAccept/help/skills/hints
        	Messages:   	help/skills/hints/output.txt vs /tmp/TestAccepthelpskillshints1907686792/002/output.txt
FAIL
TestAccept/help/skills/hints-invalid-name: branch ✅ | main (d1d57e6) ❌ | latest (v1.28.0) ❌

main (d1d57e6):

acceptance_test.go:1406: 
        	Error Trace:	/home/runner/work/cli/cli/libs/testdiff/testdiff.go:22
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1406
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1147
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:690
        	Error:      	Not equal: 
        	            	expected: "\n>>> [CLI] jobs --help\nUse \"databricks jobs [command] --help\" for more information about a command.\n\nCoding agents: read the skills for this command group before you use it.\n  databricks skills read alpha\n\n>>> [CLI] skills read -- -foo\nError: unknown skill \"-foo\": run \"databricks skills list\" to see the available skills\n\n>>> [CLI] skills read-file -- -foo SKILL.md\nError: unknown skill: \"-foo\"\n\n>>> [CLI] skills read a b\nError: unknown skill \"a b\": run \"databricks skills list\" to see the available skills\n"
        	            	actual  : "\n>>> [CLI] jobs --help\nCoding agents: read the skills for this command group before you use it.\n  databricks skills read -- -foo\n  databricks skills read a b\n  databricks skills read alpha\n\n>>> [CLI] skills read -- -foo\nError: read \"SKILL.md\" in skill \"-foo\": open skills/-foo/SKILL.md: no such file or directory\n\n>>> [CLI] skills read-file -- -foo SKILL.md\nError: read \"SKILL.md\" in skill \"-foo\": open skills/-foo/SKILL.md: no such file or directory\n\n>>> [CLI] skills read a b\nError: read \"SKILL.md\" in skill \"a b\": open skills/a b/SKILL.md: no such file or directory\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -2,5 +2,5 @@
        	            	 >>> [CLI] jobs --help
        	            	-Use "databricks jobs [command] --help" for more information about a command.
        	            	-
        	            	 Coding agents: read the skills for this command group before you use it.
        	            	+  databricks skills read -- -foo
        	            	+  databricks skills read a b
        	            	   databricks skills read alpha
        	            	@@ -8,9 +8,9 @@
        	            	 >>> [CLI] skills read -- -foo
        	            	-Error: unknown skill "-foo": run "databricks skills list" to see the available skills
        	            	+Error: read "SKILL.md" in skill "-foo": open skills/-foo/SKILL.md: no such file or directory
        	            	 
        	            	 >>> [CLI] skills read-file -- -foo SKILL.md
        	            	-Error: unknown skill: "-foo"
        	            	+Error: read "SKILL.md" in skill "-foo": open skills/-foo/SKILL.md: no such file or directory
        	            	 
        	            	 >>> [CLI] skills read a b
        	            	-Error: unknown skill "a b": run "databricks skills list" to see the available skills
        	            	+Error: read "SKILL.md" in skill "a b": open skills/a b/SKILL.md: no such file or directory
        	            	 
        	Test:       	TestAccept/help/skills/hints-invalid-name
        	Messages:   	help/skills/hints-invalid-name/output.txt vs /tmp/TestAccepthelpskillshints-invalid-name1862807359/002/output.txt
FAIL

latest (v1.28.0):

acceptance_test.go:1406: 
        	Error Trace:	/home/runner/work/cli/cli/libs/testdiff/testdiff.go:22
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1406
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1147
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:690
        	Error:      	Not equal: 
        	            	expected: "\n>>> [CLI] jobs --help\nUse \"databricks jobs [command] --help\" for more information about a command.\n\nCoding agents: read the skills for this command group before you use it.\n  databricks skills read alpha\n\n>>> [CLI] skills read -- -foo\nError: unknown skill \"-foo\": run \"databricks skills list\" to see the available skills\n\n>>> [CLI] skills read-file -- -foo SKILL.md\nError: unknown skill: \"-foo\"\n\n>>> [CLI] skills read a b\nError: unknown skill \"a b\": run \"databricks skills list\" to see the available skills\n"
        	            	actual  : "\n>>> [CLI] jobs --help\n  -p, --profile string       ~/.databrickscfg profile\n  -t, --target string        bundle target to use (if applicable)\n\nUse \"databricks jobs [command] --help\" for more information about a command.\n\n>>> [CLI] skills read -- -foo\nError: unknown command \"skills\" for \"databricks\"\n\n>>> [CLI] skills read-file -- -foo SKILL.md\nError: unknown command \"skills\" for \"databricks\"\n\n>>> [CLI] skills read a b\nError: unknown command \"skills\" for \"databricks\"\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -2,15 +2,15 @@
        	            	 >>> [CLI] jobs --help
        	            	+  -p, --profile string       ~/.databrickscfg profile
        	            	+  -t, --target string        bundle target to use (if applicable)
        	            	+
        	            	 Use "databricks jobs [command] --help" for more information about a command.
        	            	 
        	            	-Coding agents: read the skills for this command group before you use it.
        	            	-  databricks skills read alpha
        	            	-
        	            	 >>> [CLI] skills read -- -foo
        	            	-Error: unknown skill "-foo": run "databricks skills list" to see the available skills
        	            	+Error: unknown command "skills" for "databricks"
        	            	 
        	            	 >>> [CLI] skills read-file -- -foo SKILL.md
        	            	-Error: unknown skill: "-foo"
        	            	+Error: unknown command "skills" for "databricks"
        	            	 
        	            	 >>> [CLI] skills read a b
        	            	-Error: unknown skill "a b": run "databricks skills list" to see the available skills
        	            	+Error: unknown command "skills" for "databricks"
        	            	 
        	Test:       	TestAccept/help/skills/hints-invalid-name
        	Messages:   	help/skills/hints-invalid-name/output.txt vs /tmp/TestAccepthelpskillshints-invalid-name698374771/002/output.txt

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: d52e263

Run: 46406576718

Env ✅​pass 🙈​skip Time
✅​ aws linux-2core-8gb 119 13 2:38
✅​ aws-windows-latest-4core-16gb 119 13 3:00
✅​ azure linux-2core-8gb 118 13 3:45
✅​ azure-windows-latest-4core-16gb 118 13 3:11
✅​ gcp linux-2core-8gb 119 13 2:39
✅​ gcp-windows-latest-4core-16gb 119 13 3:01
Top 3 slowest tests (at least 2 minutes):
duration env testname
3:10 azure-windows-latest-4core-16gb TestAccept
3:00 gcp-windows-latest-4core-16gb TestAccept
2:58 aws-windows-latest-4core-16gb TestAccept

Skill reads looked the skill up in the raw manifest, so
`skills read-file -- -foo SKILL.md` served a skill that list and read
hide. The lookup now also requires IsSkillName, and returns
ErrUnknownSkill as it does for an unlisted skill.

`skills read-file` prints the skill name as it is, since the catalog only
lists valid names. The file name keeps its quoting.

IsSkillName is the Agent Skills name format. The installer also rejects
Windows device names, which the comments now say. The hints acceptance
test is renamed to match what it checks, and a test shows the footer stays
off with DATABRICKS_SKILLS_PREVIEW unset.

Co-authored-by: Isaac <no-reply@databricks.com>
@simonfaltum
simonfaltum marked this pull request as ready for review November 27, 2026 17:04
@simonfaltum
simonfaltum requested review from a team and lennartkats-db as code owners November 27, 2026 17:04

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review at 91029cf. Each finding was verified against the code.

No blocking issues found. 6 non-blocking comment(s) below.

This PR moves the installer's skill-name check into libs/skills as IsSkillName. The catalog and ReadFile now leave out skills with names the installer rejects, so the printed skills read commands no longer need -- or quoting for the name. The change itself is correct: fsSource is the only Source, and both Catalog and filePath enforce the check. The main gap is the user experience. When a manifest lists a bad name, the skill disappears with only a debug log line, and no acceptance test shows what skills read prints after that. There are also a few test-rule and wording nits.

Comment thread libs/skills/fs.go Outdated
for _, name := range slices.Sorted(maps.Keys(m.Skills)) {
if !IsSkillName(name) {
// The installer rejects this name, so the catalog leaves the skill out.
log.Debugf(ctx, "skills catalog: skipping skill %q: the name is not a valid skill name", name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nice to have] Say a DATABRICKS_SKILLS_DIR manifest lists -foo. databricks skills read -- -foo used to print the skill. Now it fails with unknown skill "-foo": run "databricks skills list", but the manifest plainly lists it, skills list is notImplemented, and the only reason given is a debug-level log line. AGENTS.md asks us not to silently ignore config we can't honor. Could this be a visible warning, or could the name check go into CheckManifestPaths (libs/skills/manifest.go) so the manifest fails with a clear error?

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.

Not changed. The ticket asks for the catalog to skip a name the installer rejects and to log the skipped name at debug level, and its acceptance criteria expect the catalog to return the valid skill. Failing the whole manifest on one bad name would hide every other skill. The user-visible effect is now in the golden of acceptance/help/skills/hints-invalid-name: skills read -- -foo, skills read-file -- -foo SKILL.md and skills read "a b" each fail with an unknown skill error that names the skill (e580301).

@@ -0,0 +1,2 @@
# The footer lists only the skills whose names the installer accepts. "-foo" is left out, so no printed command starts with a flag.
trace $CLI jobs --help | tail -n 4

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nice to have] The user-visible change is that skills read -- -foo and skills read-file -- -foo SKILL.md now fail. The old script ran the printed command, but this one only records the footer, so no golden shows the new error. Could you add musterr $CLI skills read -- -foo and musterr $CLI skills read-file -- -foo SKILL.md here? The directory already has the manifest. An "a b" entry would also cover the space case.

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.

Done in e580301. The hints acceptance test now runs skills read -- -foo, skills read-file -- -foo SKILL.md and skills read "a b" under musterr, so their unknown skill errors are in the golden. The manifest adds an "a b" entry for the space case, and the footer is unchanged.

Comment thread libs/skills/hints_test.go
}

func TestWriteGroupHintRunsLeadingHyphenSkillAsPrinted(t *testing.T) {
func TestWriteGroupHintLeavesOutSkillNameTheInstallerRejects(t *testing.T) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nit] This test uses the same -foo/alpha manifest and asserts the same footer as acceptance/help/skills/hints-invalid-name. TestCatalogLeavesOutSkillNamesTheInstallerRejects already covers the filtering. testing.md says not to add a unit test that only duplicates an acceptance test, so can this one go?

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.

Kept. The ticket names this test: its acceptance criteria ask for the footer line in the k2hint test to use require.Equal. The acceptance test runs the CLI, while this one calls WriteGroupHint directly with a manifest that has the hyphen name, so it is not only a copy. No code change.

Comment thread libs/skills/hints_test.go
WriteGroupHint(ctx, &buf, "jobs")
assert.Equal(t, "\nCoding agents: read the skills for this command group before you use it.\n"+
" databricks skills read -- -foo\n", buf.String())
require.Equal(t, "\nCoding agents: read the skills for this command group before you use it.\n"+

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nit] This is the test's last check of the result, not a precondition, so per testing.md it should be assert.Equal. The same applies to require.Empty at line 75.

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.

Kept require.Equal. The ticket asks for require.Equal on this footer line, and that is the acceptance criterion this change is checked against. testing.md would use assert for a last check, so if the owner prefers that, it is a one-word change. No code change in this push.

Comment thread libs/skills/hints_test.go Outdated
assert.Equal(t, []string{"-foo"}, fs.Args())
// With DATABRICKS_SKILLS_PREVIEW unset the feature is off, so the footer stays
// off even with hints on and the same manifest.
func TestWriteGroupHintIsOffWithoutPreview(t *testing.T) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nit] TestWriteGroupHintIsOffWithoutPreview tests that DATABRICKS_SKILLS_PREVIEW gates the footer. It passes with or without this change, and its -foo entry has no effect on the result. Could it go in a separate PR, or become a case in the TestWriteGroupHint table?

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.

Done in e580301. The standalone test is removed. Its check is now a preview off case in TestWriteGroupHint, with the preview value as a table field, so it fails if the guard is broken. The case also uses assert.Equal, which covers the require.Empty point on the same test.

Comment thread libs/skills/skills.go Outdated
type Catalog struct {
// Skills are sorted by name. Install also skips non-portable names and
// paths, which the catalog does not check yet.
// Skills are sorted by name. A name IsSkillName rejects, the Agent Skills

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nit] In "A name IsSkillName rejects, the Agent Skills name format, is left out", it reads as if the rejected name is the Agent Skills name format. Maybe: "Skills are sorted by name, and a skill whose name is not in the Agent Skills name format (see IsSkillName) is left out."

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.

Done in e580301. The Catalog comment now reads: a skill whose name is not in the Agent Skills name format (see IsSkillName) is left out.

simonfaltum and others added 3 commits November 27, 2026 17:14
The help footer printed the skill name unquoted, so a skill named with a
leading hyphen was read by Cobra as a flag. Print "--" first in that case.
Also add a quoted leading-hyphen file case and send the acceptance check's
output to LOG.read.

Co-authored-by: Isaac <no-reply@databricks.com>
The footer test for DATABRICKS_SKILLS_PREVIEW unset is now a case in
TestWriteGroupHint, with the preview value as a table field. The hints
acceptance test also runs the read commands on the names the catalog
leaves out, so their unknown-skill errors are in the golden, and the
manifest adds a name with a space. The Catalog comment names the Agent
Skills format directly.

Co-authored-by: Isaac <no-reply@databricks.com>
The help footer's leading-hyphen handling moves to the stacked pull request
that owns the footer, so this branch no longer changes libs/skills.

Co-authored-by: Isaac <no-reply@databricks.com>
simonfaltum and others added 5 commits November 27, 2026 17:43
Co-authored-by: Isaac <no-reply@databricks.com>
…-before

Brings in the squash-merged skills read change (#8121). Its
acceptance manifest conflicted with this branch's hyphen fixture;
the branch side is kept, which adds the -foo skill.

Co-authored-by: Isaac <no-reply@databricks.com>
…-before

Keep the hyphen-name fixture alongside the preview skill from main, and update the list golden for the new skill.

Co-authored-by: Isaac <no-reply@databricks.com>
Take in the parent branch's merge with main. Leave the leading-hyphen skill out of the shared acceptance release again, since the catalog skips names the installer rejects, and update the resolve test count and the list golden to match.

Co-authored-by: Isaac <no-reply@databricks.com>
Base automatically changed from skills/k2hint-the-group-help-footer-ends-flags-before to main November 28, 2026 00:57
…mes-the

Take origin/main's hints test layout and keep this branch's skip for
skill names the installer rejects: drop the leading-hyphen footer case
and the -foo fixture skill, and keep the hints-invalid-name test.

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions github-actions Bot added the aitools AI tools (databricks aitools) related changes label Nov 28, 2026
stevenayers pushed a commit to stevenayers/cli that referenced this pull request Nov 28, 2026
…atabricks#8127)

## Changes
The group help footer now prints `databricks skills read -- <name>` for
a skill whose name starts with `-`. Before, the printed command read the
name as a flag and failed. Ordinary names print exactly as before.

- `WriteGroupHint` in `libs/skills/hints.go` adds `-- ` only when the
name starts with `-`.
- The footer stays behind `DATABRICKS_SKILLS_PREVIEW` and the hints
switch, so output is unchanged while those are off.

## Why
A skill name starting with `-` passes `CheckManifestPaths`, so the
footer can list one. `skills read` had the same bug and was fixed the
same way in `cmd/skills/read.go` by databricks#8121, which is merged. This branch
merges `main` and carries only the footer change.

## Decisions to review
- The check is inline in `WriteGroupHint` rather than a shared helper.
The check in `cmd/skills/read.go` is inline too, and `libs/skills`
cannot import `cmd/skills`, so sharing it would move code across
packages in this pull request.
- Names with spaces, `;`, `$(...)` or a newline are not quoted here.
databricks#8132 makes the installer reject such names, so they never reach the
footer.
- `skills list` still prints the generic line `databricks skills read
<name>`, which fails for `-foo`. Adding `--` there changes every list
golden, not only the `-foo` line, so it is left for a follow-up.

## Tests
- `TestWriteGroupHintRunsLeadingHyphenSkillAsPrinted` checks the footer
line for a skill named `-foo`, then parses the printed arguments with
pflag to show they resolve to the name.
- `acceptance/help/skills/hints` prints the footer for `jobs`, checks
the printed line with `contains.py`, and runs it with `eval`.
- The `-foo` skill is added to the shared acceptance release fixture.
That changes the count in `TestLocalCatalogFromAcceptanceFixture` and
adds the skill to the `acceptance/cmd/skills/list` golden. That golden
is the only existing one that changes. Every other golden is unchanged.
- The existing `TestWriteGroupHint` cases are unchanged. Its hints-off
case covers the guard.
- `go test ./libs/skills/... ./cmd/skills/...`, `./task fmt-q lint-q`,
`go test ./acceptance -run TestAccept/cmd/skills` and `-run
TestAccept/help/skills` pass.

This pull request and its description were written by Isaac.

---------

Co-authored-by: Isaac <no-reply@databricks.com>
@simonfaltum
simonfaltum requested review from denik and rclarey November 28, 2026 09:02

@rugpanov rugpanov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blocking problem found. The change moves the installer's skill-name check into libs/skills as IsSkillName, and the catalog now leaves out skills that fail it. All read paths (skills read, read-file, list-files, the help footer) go through the same filter, and the installer keeps the same regex, length limit and messages.

I do not approve yet, because one design point is still open: the catalog hides an invalid name with only a debug log (see the inline question, and the open thread #8132 (comment)).

Risk: LOW. The skills command group is hidden and gated by DATABRICKS_SKILLS_PREVIEW, and Resolve serves only a local DATABRICKS_SKILLS_DIR today. The installer refactor keeps its behavior, and a revert is simple.

CI: 20 checks pass and 8 are skipped (test-sandbox, test-pipelines, test-exp-ssh matrices). task test-exp-aitools passes on linux and macos.

Already reported and still open (not repeated here): require.Equal as the main assertion (#8132 (comment)) and the duplicate unit test (#8132 (comment)).

Comment thread libs/skills/fs.go Outdated
for _, name := range slices.Sorted(maps.Keys(m.Skills)) {
if !IsSkillName(name) {
// The installer rejects this name, so the catalog leaves the skill out.
log.Debugf(ctx, "skills catalog: skipping skill %q: the name is not a valid skill name", name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Question] Is a debug-level skip the wanted behavior here? The installer reports the same name at the default log level: log.Warnf(ctx, "Skipping skill %q: %s", ...) for a full install, and a SkillError for a named install (libs/aitools/installer/installer.go:491-496). Here, skills list leaves the skill out, and skills read -- -foo says only unknown skill "-foo". A developer with a hand-written DATABRICKS_SKILLS_DIR manifest cannot see why the skill is missing. AGENTS.md also says: "Never silently ignore a flag or config field the current mode can't honor." If a visible message is wanted, use log.Warnf here, as the installer does. This adds the installer evidence to the open thread #8132 (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.

Not changed. I tried log.Warnf here. The catalog is built for the jobs --help footer too, so every help run printed a timestamped WARN line in the middle of the help text, and each skills read printed one line per bad entry before its error. That is a lot of noise for help output, which is why the ticket asks for debug level. The skill is still visible as missing: the acceptance golden hints-invalid-name shows the unknown skill error that names it. If you want a visible message, a better place is an error in CheckManifestPaths or a note in skills list, which I would do as a follow-up rather than here.

Comment thread libs/skills/fs.go Outdated
catalog.Rules = string(data)
}
for _, name := range slices.Sorted(maps.Keys(m.Skills)) {
if !IsSkillName(name) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[Question] Do you want the installer name format for skills read too? On main, a local manifest skill named Alpha, a_b or a.b works with skills read, and -foo works with skills read -- -foo. At this head, all four names are unknown skills. The first three names are safe in the shell, so the printed-command problem alone does not need this filter. If only the printed commands are the problem, a smaller fix is to keep -- and quote the name with shellquote.Arg in WriteGroupHint. The answer decides if this filter is in scope for this PR.

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.

Yes, the filter applies to skills read on purpose. The ticket for this change is that the catalog accepts only names the installer would accept, so a name that skills read shows to an agent can also be installed. Names like Alpha, a_b and a.b are not installable today, so a manifest listing them is already inconsistent with the installer. Quoting with shellquote.Arg would fix only the printed commands, not that mismatch. No code change; if you would rather take the smaller fix, say so and I will switch.

@@ -0,0 +1,4 @@
Cloud = false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[nit] Cloud = false and Env.DATABRICKS_SKILLS_PREVIEW = "1" (line 4) repeat inherited values. acceptance/test.toml already sets Cloud = false, and acceptance/help/skills/test.toml already sets the preview variable. The sibling hints/test.toml sets neither. Remove the two lines, as .agents/rules/testing.md says: "Put common test.toml options in a parent directory."

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.

Done in 233bb76. Removed Cloud = false and the preview variable from this test.toml; the parent directories set them.

Comment thread libs/skills/hints_test.go Outdated
{name: "mapped group", preview: "1", hints: "1", dir: dir, group: "jobs", want: footer},
// Without DATABRICKS_SKILLS_PREVIEW the feature is off, so the footer
// stays off even with hints on and a source that maps the group.
{name: "preview off", preview: "", hints: "1", dir: dir, group: "jobs"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[nit] The preview off case tests the DATABRICKS_SKILLS_PREVIEW gate, not the skill-name check. main has no such test, so this is a new test that is not related to the change. AGENTS.md says: "Keep each PR focused on one change." Move this case to a separate PR.

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.

Done in 233bb76. Removed the preview off case and the preview table field, so TestWriteGroupHint is back to its original shape.

Co-authored-by: Isaac <no-reply@databricks.com>

@rclarey rclarey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[nit] The Tests section still lists "TestWriteGroupHint: a preview off case…", but 233bb76 removed that case. It also says help/skills/hints-invalid-name was "renamed from hints-hyphen". hints-hyphen existed only in this branch's earlier commits, and against main this is a new directory. Could you update the description so it matches the final diff?


[nit] IsSkillName is defined in manifest.go, but TestIsSkillName is in fs_test.go. Moving it to a manifest_test.go would keep each test next to its code.


[nit] (non-blocking, raised by 2 sources) Windows device names. Is a follow-up planned to share the installer's device-name check with the catalog, for example by moving isWindowsDeviceName into libs/skills next to IsSkillName? A manifest skill named con with commands: ["jobs"] is still listed in skills list, shown in the jobs --help footer and readable with skills read con, but aitools install skips it. The description says this is deferred. I'm asking only to confirm that a follow-up is tracked, since the stated goal is to list what the installer can install.

Comment thread libs/skills/fs.go Outdated
catalog.Rules = string(data)
}
for _, name := range slices.Sorted(maps.Keys(m.Skills)) {
if !IsSkillName(name) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[nit] Catalog and filePath each repeat IsSkillName. If a future fsSource method reads m.Skills and forgets the check, it will serve a skill that Catalog hides. If manifest() dropped invalid names once (with the debug log), both places would see the same view and the extra || !IsSkillName(skill) could go. This is optional.

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.

Done in d52e263. manifest() now drops names IsSkillName rejects once, with the debug log, so Catalog and filePath see the same view. The extra check in filePath is gone.

Comment thread cmd/skills/read.go
endOfFlags = "-- "
}
fmt.Fprintf(&b, " databricks skills read-file %s%s %s\n", endOfFlags, quotedName, quotedFile)
fmt.Fprintf(&b, " databricks skills read-file %s%s %s\n", endOfFlags, name, quotedFile)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[nit] The skill name is now printed raw because "the catalog lists" only valid names. That is true today: every Source wraps fsSource, and runRead looks the name up in the catalog first. But the Source interface doesn't promise it, and the test for the -guide-skill case was deleted. One option is to keep a cheap check, libskills.IsSkillName(name), before printing the commands. Another is to state the guarantee on the Catalog.Skills field as a contract every Source must meet. Either way, a new source can't bring back flag-like names in printed commands without anyone noticing.

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.

Done in d52e263 as the contract option: the Catalog.Skills comment now says every name there is safe to print in a command and that a Source must meet this. The manifest-level filter means fsSource, which every Source wraps, meets it. Kept the print path unchanged.

func unportableSkill(name string, files []string) string {
if len(name) > maxSkillNameLength || !skillNamePattern().MatchString(name) {
return fmt.Sprintf("the name is not at most %d lowercase letters, digits and single hyphens", maxSkillNameLength)
if !skills.IsSkillName(name) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[nit] This PR touches libs/aitools, and .agents/rules/aitools-verification.md says to run ./task aitools-full before opening the PR. The Tests section lists only targeted go test runs and fmt-q lint-q. Could you run it, or note it in the description? CI test-exp-aitools (linux) passed and macOS was still pending.

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.

Ran ./task aitools-full at d52e263: lint, tests, acceptance and deadcode all pass.

simonfaltum and others added 2 commits November 30, 2026 11:07
Co-authored-by: Isaac <no-reply@databricks.com>
…mes-the

Co-authored-by: Isaac <no-reply@databricks.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aitools AI tools (databricks aitools) related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants