Skip to content

fix(run): install a local_path skill under its declared name - #400

Closed
Walternater wants to merge 1 commit into
alibaba:mainfrom
Walternater:fix/local-path-skill-name
Closed

Walternater wants to merge 1 commit into
alibaba:mainfrom
Walternater:fix/local-path-skill-name

Conversation

@Walternater

Copy link
Copy Markdown
Contributor

Summary

A local_path skill whose folder name differs from the name: in its
SKILL.md frontmatter was installed under the folder name. Agents address the
installed skill by that directory name, so a snapshot folder snap/ holding
name: my-skill was listed and invoked as snap — a name its own text never
uses — and the with_skill arm of a benchmark could run a differently named
skill without any warning (#367).

Default install targets now use the declared name. runtime.SkillConfig gains
Name (filled by resolveSkillConfig from SKILL.md) and DirName(), which
returns the declared name when it is a safe single path element and falls back
to the source folder name otherwise. Explicit skills[].target still wins.

Related issues

Changes

  • internal/runtime/runtime.go: SkillConfig.Name + DirName(); names that
    are empty, ., .., or contain a slash/backslash fall back to the source
    basename so a malformed SKILL.md cannot escape the skill directory.
  • internal/config/loader.go: SkillNameInDir(dir) wraps the existing
    parseSkillName so callers can read the declared name from any skill
    directory (the loader's own SkillName() keeps its behaviour).
  • internal/evaluator/evaluator.go: resolveSkillConfig fills Name, and the
    default run-skill cleanup before an Agent judge (removeDefaultRunSkillsBeforeJudge)
    removes DirName() instead of the source basename, so cleanup matches what
    was installed.
  • internal/agent/agent.go, internal/agent/cli.go: the two default target
    computations (installSkillDefault, and the fallback target for a custom
    InstallSkillCmd) use DirName(). judge.skills gets the same behaviour
    because it goes through the same resolver.
  • Docs (en/zh) and CHANGELOG.md.

Test plan

  • make test passes
  • make verify passes (fmt + vet + lint, 0 issues)
  • New tests: TestSkillConfigDirName (declared name wins; empty/./../
    slashed names fall back), TestSkillNameInDir, two CLIAgent tests
    (default install target; custom InstallSkillCmd default target;
    explicit target wins), and
    TestRemoveDefaultRunSkillsBeforeJudge_UsesDeclaredName.
  • Negative control: reverting the two default-target computations reddens
    the three install tests (skill should be installed under its declared name ... .claude/skills/my-skill/SKILL.md: no such file or directory),
    and dropping the Name fill reddens the cleanup test
    (got "rm -rf -- '.codex/skills/snap'").
  • Real run, environment: none + claude_code, snapshot folder snap/
    with name: my-skill, skills: [{source: local_path, path: .}]:
    before this change .claude/skills/snap/, after .claude/skills/my-skill/.

Notes for reviewers

  • A custom InstallSkillCmd template that renders {{.Target}} now receives
    the declared name in the default target instead of the folder name. That is
    the point of the change, but it is a behaviour change for such templates; an
    explicit skills[].target keeps working unchanged.
  • I did not add a warning when the names differ: with the default target they
    no longer do, and the issue offered install-under-name or warn as
    alternatives. Happy to add one for explicit targets if you want it.
  • Disclosure: prepared with DeepSeek Harness (model deepseek-v4.1-flash); I
    reviewed the full diff and ran the verification above.

A local_path skill whose folder name differs from the name declared in
SKILL.md was installed under the folder name, so the agent listed and
invoked it by a name its own text never uses (alibaba#367). The default target is
now runtime.SkillConfig.DirName: the declared name when it is a safe single
path element, otherwise the source folder name. The same name drives the
default skill cleanup before an agent judge, and explicit targets still win.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T06:48:42.560947Z de7560b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de7560ba69

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

func (c SkillConfig) DirName() string {
name := strings.TrimSpace(c.Name)
if name != "" && name != "." && name != ".." && !strings.ContainsAny(name, `/\`) {
return 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.

P2 Badge Reject duplicate declared names before installation

When an eval lists two different skills with the same frontmatter name and leaves target unset, both now resolve to the same default directory; installSkill uploads each source there without clearing it, so files can be merged or overwritten and the run evaluates a different skill than either source. validateSkillRefs permits this configuration, so fail on duplicate default targets before installing them.

Useful? React with 👍 / 👎.

zpzjzj commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the fix and the verification details. This substantially overlaps with #393, which is also still open: both address #367 by installing local Skills under their declared SKILL.md name, preserving explicit targets, and updating the default install paths and pre-judge cleanup.

The two PRs touch the same core code paths, so it would be useful to coordinate the implementations before merging to avoid duplicating the fix or losing changes when reconciling them. Please compare with #393 and identify any distinct improvements or test coverage here that we should retain.

@Walternater

Copy link
Copy Markdown
Contributor Author

Compared the two patches. Agreed on the overlap: #393 is the better base and should land instead of this one. It goes further than #400 in three places worth keeping:

Distinct coverage in #400 that #393 does not have, and I think is worth retaining:

  1. TestCLIAgent_InstallSkillWithCmdDefaultTargetUsesDeclaredName — the custom InstallSkillCmd branch in internal/agent/cli.go computes its default target separately from BaseAgent.installSkillDefault. fix(agent): install a Skill under its declared name #393 changes that line but its new test exercises the default SkillPath path (agent.go) only. I reverted just the cli.go hunk on top of fix(run): install a local_path skill under its declared name #400 and this test is the only one that fails (skill should be installed under its declared name ... skills/my-skill/SKILL.md), so without it that half of the change is unguarded.
  2. TestCLIAgent_InstallSkillExplicitTargetWinsOverDeclaredName — an agent-level guard that an explicit target still wins over the declared name. fix(agent): install a Skill under its declared name #393 covers explicit targets at the evaluator level (collision avoidance, fallback), not at the install API.
  3. Real-CLI evidence rather than a claim: with environment.type: none and claude 2.1.317, the fixture snap/ + name: my-skill installs at .claude/skills/snap before and .claude/skills/my-skill after. Can be pasted into fix(agent): install a Skill under its declared name #393's test plan if useful.

I'll close #400 now and won't push to @karanb192's branch. Happy to send the two tests as a small test-only follow-up PR after #393 merges, or as a patch here if @karanb192 prefers to fold them in — just say which.

@Walternater

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #393 after @zpzjzj's note: #393 covers the same fix plus collision detection, judge naming and stricter name validation. The two distinct tests and the real-CLI evidence are offered in #393 (comment above); I'll send them as a test-only follow-up if they're not folded in there.

karanb192 added a commit to karanb192/skill-up that referenced this pull request Nov 13, 2026
The InstallSkillCmd default target is computed separately from the
SkillPath default, and an explicit target must still win over the
declared name. Both tests come from Walternater's alibaba#400.
karanb192 added a commit to karanb192/skill-up that referenced this pull request Nov 16, 2026
* fix(agent): install a Skill under its declared name

The default install folder was the source folder's basename, so a Skill
copied into a differently named folder was listed and invoked under that
folder's name. Use the name from SKILL.md frontmatter when it is usable as
a directory name.

* fix(agent): reject skills that share an install directory

Two sources that declare the same name would be uploaded into one
directory and mixed. Also accept a declared name only when it is safe as
a directory name on every supported filesystem.

* refactor(evaluator): move run skill installation into a helper

Keeps setupCaseEnvironment under the complexity limit. Also state the
exact name rule in both guides.

* fix(judge): name judge Skills by their install directory in the prompt

A judge Skill installed under its declared name was still listed in the
agent judge prompt under its folder name, so the judge was told to
invoke a Skill that no longer existed under that name.

* test(judge): cover the folder-name fallback for judge Skill names

* test(agent): cover declared names on the custom install command path

The InstallSkillCmd default target is computed separately from the
SkillPath default, and an explicit target must still win over the
declared name. Both tests come from Walternater's alibaba#400.
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.

2 participants