Skip to content

Commit 1ef9ec5

Browse files
vijayclaude
andcommitted
Pin the skill-name grammar rejection cases
validate_skill already rejects names that violate the Agent Skills grammar (SEP-2640 defers to it), but nothing pinned the edge cases. Add a parametrized test covering consecutive, leading, and trailing hyphens, uppercase, underscores, and the 64-character ceiling. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6104fa8 commit 1ef9ec5

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tests/shared/test_skills.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,31 @@ def test_validate_skill_rejects_a_non_string_frontmatter_name() -> None:
106106
validate_skill(skill)
107107

108108

109+
@pytest.mark.parametrize(
110+
"name",
111+
[
112+
"foo--bar", # consecutive hyphens
113+
"-foo", # leading hyphen
114+
"foo-", # trailing hyphen
115+
"UPPER", # uppercase not allowed
116+
"with_underscore", # underscore not allowed
117+
"a" * 65, # exceeds the 64-char limit
118+
],
119+
)
120+
def test_validate_skill_rejects_names_violating_the_agent_skills_grammar(name: str) -> None:
121+
"""SEP-2640 defers naming to the Agent Skills spec: 1-64 chars, lowercase alphanumeric and
122+
hyphens, no leading/trailing/consecutive hyphens. A URI whose final path segment carries the
123+
bad name (so `frontmatter.name` can match it) still fails the name-grammar check first."""
124+
uri = f"skill://acme/{name}/SKILL.md"
125+
skill = Skill(
126+
uri=uri,
127+
frontmatter={"name": name, "description": "d"},
128+
resources=[SkillResource(uri=uri, digest=_DIGEST, size=4)],
129+
)
130+
with pytest.raises(ValueError, match="frontmatter name"):
131+
validate_skill(skill)
132+
133+
109134
def test_validate_skill_rejects_an_invalid_resource_uri() -> None:
110135
"""A resource URI with a query component fails the same shape check as a skill URI."""
111136
skill = _skill(extra_resources=[_resource("skill://git-workflow/x.md?y=1")])

0 commit comments

Comments
 (0)