Skip to content

fix(agent): install a Skill under its declared name - #393

Merged
zpzjzj merged 7 commits into
alibaba:mainfrom
karanb192:fix/skill-install-name
Nov 16, 2026
Merged

zpzjzj merged 7 commits into
alibaba:mainfrom
karanb192:fix/skill-install-name

Conversation

@karanb192

@karanb192 karanb192 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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 name in SKILL.md, for example a snapshot copy snap/ holding name: my-skill, Claude Code lists the Skill as snap (my-skill) and the Agent invokes it by the folder name. In benchmark mode the with_skill arm 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 when SKILL.md declares no usable name.

Related issues

Closes #367.

Changes

  • internal/runtime/runtime.go: SkillConfig carries the declared Name; DirName() returns it, or the source folder's name when it is empty.
  • internal/evaluator/evaluator.go:
    • resolveSkillConfig reads the name from SKILL.md frontmatter 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.
    • Two skills (or judge.skills) entries without a target that would be installed into the same directory are rejected before anything is uploaded.
    • The judge-isolation cleanup removes the same directory the install wrote.
    • The agent judge prompt and the report's judge Skill list name each judge Skill by the same install name. config.SkillRef gets a non-configurable InstallName (yaml:"-"), filled on a copy of the judge config.
  • internal/judge/judge_skill.go: SkillInfosFromRefs uses InstallName when it is set.
  • internal/agent/agent.go, internal/agent/cli.go: both default install paths use DirName().
  • Docs: docs/guide/writing-evals.md and the Chinese guide.

Test plan

Checked on 23e241c, which includes main at ecb2499, using Go 1.26.10 and the pinned lint tools.

  • make test passes
  • make verify passes (fmt + vet + lint)
  • make e2e passes
  • npm run docs:build passes
  • TestResolveSkillConfig_DeclaredName: a name that differs from the folder, a name that matches, no frontmatter, no SKILL.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 explicit target that avoids the collision.
  • TestCLIAgent_InstallSkillDefaultUsesDeclaredName: the files land under the declared name and not under the folder name.
  • TestCLIAgent_InstallSkillWithCmdDefaultTargetUsesDeclaredName and TestCLIAgent_InstallSkillExplicitTargetWinsOverDeclaredName (from @Walternater's fix(run): install a local_path skill under its declared name #400): the custom InstallSkillCmd default target uses the declared name, and an explicit target still wins.
  • @Walternater checked it with the real Claude Code CLI 2.1.317 on environment.type: none: a snap/ folder declaring my-skill lands at .claude/skills/snap on main and at .claude/skills/my-skill with this change.
  • TestExecuteCase_JudgePromptNamesDeclaredSkillName: a judge Skill in snapshot/ declaring rubric-skill is installed as rubric-skill, the judge prompt asks for rubric-skill, and the shared config is not modified. It fails without the prompt fix.
  • TestWithJudgeSkillInstallNames_FallsBackToFolderName: a judge Skill at path: . with an unusable declared name is named after its folder; an explicit target keeps today's name.

Notes for reviewers

  • The issue offered two options: install under the declared name, or only warn when the names differ. I chose the first because the Agent Skills specification says 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.
  • Behavior change: a Skill whose folder and declared name differ is now installed at a different default path. An explicit skills[].target is untouched. A case that refers to the old path by the folder name would need updating.
  • Not covered: a collision between a default install directory and another entry's explicit target. The default directory depends on the Agent, and the code already treats explicit targets as user-controlled, so I left that comparison out.
  • The collision check also rejects two entries whose source folders share a basename. Those were merged silently before.
  • The Chinese text is my translation. Please correct the wording if needed.

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

chatgpt-codex-connector Bot commented Nov 11, 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-11T15:50:59.494315Z 02e16ad 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: 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".

Comment thread internal/evaluator/evaluator.go Resolved
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.

@zpzjzj zpzjzj left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 zpzjzj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@Walternater

Copy link
Copy Markdown
Contributor

This looks good to me and is more complete than my #400 (which I'm closing): the collision check, the InstallName plumbing into the judge prompt/report, and the stricter portable-name validation are all things #400 doesn't cover.

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 internal/agent/cli_test.go:

  1. The custom InstallSkillCmd path computes its default target separately from BaseAgent.installSkillDefault, so the internal/agent/cli.go half of the change is untested by TestCLIAgent_InstallSkillDefaultUsesDeclaredName (that one uses SkillPath, i.e. agent.go). Reverting only the cli.go line keeps the rest of the suite green; this test is what catches it.
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)
	}
}
  1. An explicit target still wins over the declared name, at the install API rather than the evaluator:
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, environment.type: none): the snap/ + name: my-skill fixture lands at .claude/skills/snap on main and .claude/skills/my-skill with the patch.

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

Copy link
Copy Markdown
Contributor Author

Thanks @Walternater, both tests are in 23e241c. I checked the first one: reverting only the cli.go line makes it fail while the rest of the suite stays green, as you said. Thanks also for the check with the real Claude Code CLI.

@zpzjzj
zpzjzj added this pull request to the merge queue Nov 16, 2026
@zpzjzj
zpzjzj removed this pull request from the merge queue due to a manual request Nov 16, 2026
@zpzjzj
zpzjzj added this pull request to the merge queue Nov 16, 2026
Merged via the queue into alibaba:main with commit 8613f50 Nov 16, 2026
16 checks passed
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.

a local_path skill is installed under its folder's name, not the name in SKILL.md

3 participants