Clarify skill publish error for nested skill directories by tommaso-moro · Pull Request #14259 · cli/cli · GitHub
Skip to content

Clarify skill publish error for nested skill directories - #14259

Draft
tommaso-moro wants to merge 2 commits into
trunkfrom
tommaso-moro-fix-skill-publish-target-error
Draft

tommaso-moro wants to merge 2 commits into
trunkfrom
tommaso-moro-fix-skill-publish-target-error

Conversation

@tommaso-moro

@tommaso-moro tommaso-moro commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14134

Description

When gh skill publish is given a skill directory containing SKILL.md directly, shared discovery represents that skill's path as .. Publish then compares the skill name with . and reports the misleading error name "reskill" does not match directory name ".".

This change recognizes only that already-failing case when the selected skill directory is inside a Git repository and replaces the name-mismatch error with an explanation that gh skill publish must target the repository root. It does not add general repository-root enforcement or change successful publishing behavior.

How did you test this change?

Given this checkout contains skills/gh-skill, when I ran go run ./cmd/gh skill publish skills/gh-skill --dry-run, then the command still exited unsuccessfully but explained that the selected path is a skill directory within a repository and that publishing must target the repository root.

Key points

  • Checks only a single directly supplied skill represented by discovery as ..
  • Preserves the existing failure and changes only its explanation.
  • Leaves all other directory targeting and publishing behavior unchanged.

Notes for reviewers

Start with the targeted check in publishRun, followed by TestPublishRun_ExplainsSkillDirectoryWithinRepository. #14134 contains the original misleading diagnostic.

Authorship and follow-up

Who wrote this:

  • A human wrote it.
  • An agent wrote it under close human direction.
  • An agent wrote it independently, and no human has guided the implementation beyond the initial prompt.

Who answers review comments:

  • @tommaso-moro will read and reply directly. Name the account.
  • An agent will draft replies and @username will read them before they are posted.
  • Nobody has explicitly committed to replying.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d7cfd21b-8317-42d4-aba0-2b0ac2d7bb87
Copilot AI balanced review requested due to automatic review settings August 25, 2026 14:52

Copilot AI 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.

Pull request overview

Requires gh skill publish to target a repository root, preventing partial skill validation before tagging and releasing.

Changes:

  • Adds repository-root validation.
  • Documents the restriction and adds regression coverage for nested directories.
Show a summary per file
File Description
pkg/cmd/skills/publish/publish.go Adds root validation and help text.
pkg/cmd/skills/publish/publish_test.go Tests nested-directory rejection and updates Git stubs.

Review details

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread pkg/cmd/skills/publish/publish.go Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d7cfd21b-8317-42d4-aba0-2b0ac2d7bb87
@tommaso-moro tommaso-moro changed the title Require skill publish to target repository root Clarify skill publish error for nested skill directories Aug 25, 2026
@tommaso-moro
tommaso-moro marked this pull request as ready for review August 25, 2026 15:04
@tommaso-moro
tommaso-moro requested review from a team as code owners August 25, 2026 15:04
@tommaso-moro
tommaso-moro requested a review from BagToad August 25, 2026 15:04
@BagToad
BagToad requested a balanced review from Copilot August 31, 2026 17:12

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

The early return masks existing validation diagnostics and changes non-interactive output behavior beyond the stated scope.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity · 1 Low severity

New issues introduced by this change (2)
Severity Finding
Low severity pkg/​cmd/​skills/​publish/​publish_test.go — 🛑 Requirement: Cover the preserved diagnostic contract and the false branch. This test discards…
Medium severity pkg/​cmd/​skills/​publish/​publish.go — 🛑 Requirement: Keep this in the validation-diagnostic path instead of returning early. This…
Issues resolved since last review (1)
Severity Finding
Low severity pkg/​cmd/​skills/​publish/​publish.go — 💭 Commentary: This overstates the new restriction. git.Client.PathFromRoot returns an empty… View resolved comment

Comment on lines +193 to +197
ios, _, _, _ := iostreams.Test()
err := publishRun(&PublishOptions{
IO: ios,
Dir: skillDir,
GitClient: newTestGitClient(),
Comment on lines +199 to +203
if len(skills) == 1 && skills[0].Path == "." && opts.GitClient != nil {
dirGitClient := opts.GitClient.Copy()
dirGitClient.RepoDir = dir
if dirGitClient.PathFromRoot(context.Background()) != "" {
return fmt.Errorf("%s is a skill directory within a repository; gh skill publish must target the repository root", dir)
@BagToad
BagToad marked this pull request as draft September 23, 2026 21:30
@BagToad

BagToad commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gh skill publish fails with correct skills/<name>/SKILL.md structure: name does not match directory name '.'

3 participants