Repository navigation
fix(agent): install a Skill under its declared name - #393
Conversation
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.
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.
Keeps setupCaseEnvironment under the complexity limit. Also state the exact name rule in both guides.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 02e16ad79a
ℹ️ 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".
# Conflicts: # CHANGELOG.md
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.
There was a problem hiding this comment.
Reviewed 28c95ae. The previous judge-skill naming finding is fixed: the resolved install name reaches both the judge prompt and report metadata without mutating the shared Skills slice. That thread has been resolved.
After reassessing the practical impact, the compatibility risk is low and acceptable. Installing under the declared name is the intended correction. Existing evals are affected only if they depend on a differing source-folder name in hardcoded installation paths or invocation names; explicit targets can preserve the previous destination. Matching folder/declared names and missing or unusable declared names keep their previous default paths.
Same-name conflicts require multiple Skills with the same resolved name in the same installation list. I found no such use in the repository examples, E2E fixtures, or skill-upper eval configs. Separate evaluations of different snapshots do not conflict. Rejecting actual collisions is appropriate protection against overwriting or mixing Skill files, rather than a reason to require a compatibility mode.
My earlier suggestion to require an opt-in/compatibility mode was overly conservative and is withdrawn. The behavior change is already documented, and I do not consider it a blocker. No additional blocking implementation issues found.
Remote CI passes, including Build & Test, Lint, and E2E. Local Python tests passed; local Go tests and verification could not complete because Go/gofmt are unavailable.
zpzjzj
left a comment
There was a problem hiding this comment.
Approved. The previous judge-skill naming issue is fixed. After reassessing actual usage, the compatibility risk is low and acceptable: the directory-name change is intentional, and collision rejection prevents overwritten or mixed Skill installations. My earlier review has been updated to withdraw the compatibility-mode suggestion. No blocking issues found; remote CI passes.
|
This looks good to me and is more complete than my #400 (which I'm closing): the collision check, the Two small agent-level tests from #400 that #393 currently lacks — happy to have you fold them in, or I can send a test-only follow-up after this merges. Both go in
func TestCLIAgent_InstallSkillWithCmdDefaultTargetUsesDeclaredName(t *testing.T) {
t.Parallel()
rt := &runtime.NoneRuntime{}
if err := rt.Create(context.Background()); err != nil {
t.Fatal(err)
}
defer func() { _ = rt.Close() }()
ag := &CLIAgent{
BaseAgent: BaseAgent{
Cfg: Config{
Name: "test-agent",
InstallSkillCmd: "printf '%s' '{{.Target}}' > '{{.Workspace}}/target.txt'",
},
},
}
err := ag.InstallSkill(context.Background(), rt, runtime.SkillConfig{Source: "snap", Name: "my-skill"})
if err != nil {
t.Fatalf("InstallSkill failed: %v", err)
}
got, err := os.ReadFile(filepath.Join(rt.Workspace(), "target.txt"))
if err != nil {
t.Fatalf("read target: %v", err)
}
if want := filepath.Join(rt.Workspace(), "skills", "my-skill"); string(got) != want {
t.Fatalf("template target = %q, want %q", got, want)
}
}
func TestCLIAgent_InstallSkillExplicitTargetWinsOverDeclaredName(t *testing.T) {
t.Parallel()
rt := &runtime.NoneRuntime{}
if err := rt.Create(context.Background()); err != nil {
t.Fatal(err)
}
defer func() { _ = rt.Close() }()
skillDir := t.TempDir()
if err := os.WriteFile(filepath.Join(skillDir, "SKILL.md"), []byte("# Skill"), 0o600); err != nil {
t.Fatal(err)
}
ag := &CLIAgent{
BaseAgent: BaseAgent{
Cfg: Config{Name: "test-agent", SkillPath: ".claude/skills"},
},
}
explicit := filepath.Join(rt.Workspace(), ".claude", "skills", "explicit")
err := ag.InstallSkill(context.Background(), rt, runtime.SkillConfig{
Source: skillDir,
Name: "my-skill",
Target: explicit,
})
if err != nil {
t.Fatalf("InstallSkill failed: %v", err)
}
if _, err := os.ReadFile(filepath.Join(explicit, "SKILL.md")); err != nil {
t.Errorf("explicit target should win over the declared name: %v", err)
}
}Also, if it's useful for the test plan: I verified the behaviour with the real Claude Code CLI (2.1.317, |
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.
|
Thanks @Walternater, both tests are in 23e241c. I checked the first one: reverting only the |
Summary
A Skill is installed into the Agent's skills directory under its source folder's name. When that folder is named differently from the
nameinSKILL.md, for example a snapshot copysnap/holdingname: my-skill, Claude Code lists the Skill assnap (my-skill)and the Agent invokes it by the folder name. In benchmark mode thewith_skillarm then runs a Skill under a name its own text never uses.The default install directory is now the declared
name. The folder name is still used whenSKILL.mddeclares no usable name.Related issues
Closes #367.
Changes
internal/runtime/runtime.go:SkillConfigcarries the declaredName;DirName()returns it, or the source folder's name when it is empty.internal/evaluator/evaluator.go:resolveSkillConfigreads the name fromSKILL.mdfrontmatter with the reader the report already uses. A name is used only when it is safe as a directory name everywhere: ASCII letters, digits,-and_, at most 64 characters, not a Windows device name.skills(orjudge.skills) entries without atargetthat would be installed into the same directory are rejected before anything is uploaded.config.SkillRefgets a non-configurableInstallName(yaml:"-"), filled on a copy of the judge config.internal/judge/judge_skill.go:SkillInfosFromRefsusesInstallNamewhen it is set.internal/agent/agent.go,internal/agent/cli.go: both default install paths useDirName().docs/guide/writing-evals.mdand the Chinese guide.Test plan
Checked on
23e241c, which includes main atecb2499, using Go 1.26.10 and the pinned lint tools.make testpassesmake verifypasses (fmt + vet + lint)make e2epassesnpm run docs:buildpassesTestResolveSkillConfig_DeclaredName: a name that differs from the folder, a name that matches, no frontmatter, noSKILL.md, and names that fall back to the folder (path separator, space, dot, control character,CON, longer than 64).TestCheckSkillDirCollisions: same declared name, names that differ only in case, a declared name equal to another entry's folder, and an explicittargetthat avoids the collision.TestCLIAgent_InstallSkillDefaultUsesDeclaredName: the files land under the declared name and not under the folder name.TestCLIAgent_InstallSkillWithCmdDefaultTargetUsesDeclaredNameandTestCLIAgent_InstallSkillExplicitTargetWinsOverDeclaredName(from @Walternater's fix(run): install a local_path skill under its declared name #400): the customInstallSkillCmddefault target uses the declared name, and an explicittargetstill wins.environment.type: none: asnap/folder declaringmy-skilllands at.claude/skills/snapon main and at.claude/skills/my-skillwith this change.TestExecuteCase_JudgePromptNamesDeclaredSkillName: a judge Skill insnapshot/declaringrubric-skillis installed asrubric-skill, the judge prompt asks forrubric-skill, and the shared config is not modified. It fails without the prompt fix.TestWithJudgeSkillInstallNames_FallsBackToFolderName: a judge Skill atpath: .with an unusable declared name is named after its folder; an explicittargetkeeps today's name.Notes for reviewers
name"Must match the parent directory name", and a warning would leave the benchmark skew in place. If you prefer the warning, I will switch.skills[].targetis untouched. A case that refers to the old path by the folder name would need updating.target. The default directory depends on the Agent, and the code already treats explicit targets as user-controlled, so I left that comparison out.