Skip to content

Make skill discovery less strict: support nested skills/ directories#13235

Merged
SamMorrowDrums merged 1 commit intotrunkfrom
sammorrowdrums/fix-skill-install-discovery
Apr 21, 2026
Merged

Make skill discovery less strict: support nested skills/ directories#13235
SamMorrowDrums merged 1 commit intotrunkfrom
sammorrowdrums/fix-skill-install-discovery

Conversation

@SamMorrowDrums
Copy link
Copy Markdown
Contributor

Problem

Repositories like hashicorp/agent-skills organize skills under nested prefixes:

terraform/code-generation/skills/terraform-style-guide/SKILL.md
packer/builders/skills/packer-builder/SKILL.md

Our current discovery logic only matched skills/ at the repository root, so these were never found by gh skill install.

Changes

Relaxes skill discovery to recognize skills/ directories at any depth in the tree:

  • matchSkillConventions: Adds checks for <prefix>/skills/<name>/SKILL.md and <prefix>/skills/<ns>/<name>/SKILL.md at any depth, after the existing root-level and plugins checks
  • isSkillPath: Also matches paths containing /skills/ or /plugins/ (not just starting with), enabling direct path-based install like gh skill install hashicorp/agent-skills terraform/code-generation/skills/terraform-style-guide
  • DiscoverSkillByPath: Fixes namespace detection to find the skills segment anywhere in the path rather than assuming parts[0] == "skills"
  • Error messages and help text: Updated to mention nested skills/ directories

Tests added

  • TestMatchSkillConventions: nested skills dir, deeply nested, nested namespaced, single prefix, root-level priority preserved
  • TestDiscoverSkills: nested skills in tree, mixed root-level and nested skills
  • TestDiscoverSkillByPath: deeply nested path, deeply nested namespaced path
  • TestDiscoverLocalSkills: nested local skills directory
  • TestMatchesSkillPath / TestMatchSkillPath: nested conventions
  • Test_isSkillPath: new test covering all path patterns (empty, plain name, SKILL.md, root skills/, nested skills/, nested plugins/, substring)
  • TestInstallRun: integration test for nested path-based install
  • Fixed stubSkillByPath to properly URL-encode parent paths with slashes

Copilot AI review requested due to automatic review settings April 20, 2026 08:56
@SamMorrowDrums SamMorrowDrums requested review from a team as code owners April 20, 2026 08:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Relaxes skill discovery and path-based installation to support repositories that place skills/ directories under nested prefixes (e.g. terraform/code-generation/skills/...), and expands tests to cover the new conventions.

Changes:

  • Extend discovery matching to recognize skills/<name>/SKILL.md and skills/<ns>/<name>/SKILL.md at any depth.
  • Treat args containing /skills/ or /plugins/ as path-based installs (skipping full tree discovery).
  • Add/adjust tests for nested discovery, nested path-based install, and URL-escaped contents lookups.
Show a summary per file
File Description
pkg/cmd/skills/install/install.go Updates CLI help text and broadens isSkillPath detection to include nested skills/ and plugins/ segments.
pkg/cmd/skills/install/install_test.go Fixes stubs to match URL-escaped parent paths and adds integration/unit tests for nested path installs and isSkillPath.
internal/skills/discovery/discovery.go Adds nested skills/ convention matching, improves error message text, and updates namespace detection for path-based lookups.
internal/skills/discovery/discovery_test.go Adds coverage for nested skills/ discovery (remote + local) and nested path-based lookup behavior.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

internal/skills/discovery/discovery.go:804

  • Similarly, the local discovery "no skills found" error message mentions {prefix}/skills/*/SKILL.md but omits the nested namespaced form {prefix}/skills/{namespace}/*/SKILL.md, even though it’s now supported. Updating the message will make troubleshooting easier.
		return nil, fmt.Errorf(
			"no skills found in %s\n"+
				"  Expected SKILL.md in the directory, or skills in skills/*/SKILL.md,\n"+
				"  skills/{scope}/*/SKILL.md, {prefix}/skills/*/SKILL.md,\n"+
				"  */SKILL.md, or plugins/*/skills/*/SKILL.md",
			dir,
  • Files reviewed: 4/4 changed files
  • Comments generated: 4

Comment thread internal/skills/discovery/discovery.go Outdated
Comment thread pkg/cmd/skills/install/install.go Outdated
Comment thread internal/skills/discovery/discovery.go
Comment thread internal/skills/discovery/discovery.go Outdated
@SamMorrowDrums SamMorrowDrums force-pushed the sammorrowdrums/fix-skill-install-discovery branch from 3518d85 to e94892e Compare April 20, 2026 09:14
@SamMorrowDrums SamMorrowDrums force-pushed the sammorrowdrums/fix-skill-install-discovery branch from e94892e to 0647686 Compare April 20, 2026 09:44
@SamMorrowDrums SamMorrowDrums added the gh-skill relating to the gh skill command label Apr 20, 2026
Copy link
Copy Markdown
Contributor

@tommaso-moro tommaso-moro left a comment

Choose a reason for hiding this comment

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

some copilot comments, but aside from those lgtm

@BagToad
Copy link
Copy Markdown
Member

BagToad commented Apr 20, 2026

👋 @SamMorrowDrums, I pushed a commit (d9f0305) with some acceptance test changes (one was failing and one new one to cover the new behavior):

Details
  • New test: acceptance/testdata/skills/skills-install-nested-discovery.txtar exercises the relaxed skills/ discovery rules end-to-end:

    • direct path-based install of a deeply nested skill (<prefix>/skills/<name>)
    • direct path-based install of a deeply nested namespaced skill (<prefix>/skills/<ns>/<name>)
    • name-based discovery resolving a deeply nested skill
  • Fix to skills-publish-dry-run.txtar: The negative case ran gh skill publish --dry-run $WORK and asserted no skills found in. The test's own testdata writes $WORK/test-repo/skills/hello-world/SKILL.md, which is now discoverable from $WORK thanks to nested skills/ matching, so the assertion stopped holding. Pointed it at a fresh empty subdirectory so it tests what it claims to.

Copy link
Copy Markdown
Member

@BagToad BagToad left a comment

Choose a reason for hiding this comment

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

LGTM after copilot comments resolved

Relax skill discovery to recognize skills/ directories at any depth
in the repository tree, not just at the root. This enables repos like
hashicorp/agent-skills that organize skills under prefixes such as
terraform/code-generation/skills/*/SKILL.md.

Changes:
- matchSkillConventions: add checks for <prefix>/skills/<name>/SKILL.md
  and <prefix>/skills/<ns>/<name>/SKILL.md at any depth
- isSkillPath: also match paths containing /skills/ for direct
  path-based install
- DiscoverSkillByPath: fix namespace detection to find the skills
  segment anywhere in the path
- Update error messages and help text to mention nested conventions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SamMorrowDrums SamMorrowDrums force-pushed the sammorrowdrums/fix-skill-install-discovery branch from d9f0305 to 9a368f4 Compare April 20, 2026 19:07
@SamMorrowDrums SamMorrowDrums merged commit a67f4f7 into trunk Apr 21, 2026
11 checks passed
@SamMorrowDrums SamMorrowDrums deleted the sammorrowdrums/fix-skill-install-discovery branch April 21, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gh-skill relating to the gh skill command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants