MCPcopy
hub / github.com/agentskills/agentskills / validate

Function validate

skills-ref/src/skills_ref/validator.py:150–177  ·  view source on GitHub ↗

Validate a skill directory. Args: skill_dir: Path to the skill directory Returns: List of validation error messages. Empty list means valid.

(skill_dir: Path)

Source from the content-addressed store, hash-verified

148
149
150def validate(skill_dir: Path) -> list[str]:
151 """Validate a skill directory.
152
153 Args:
154 skill_dir: Path to the skill directory
155
156 Returns:
157 List of validation error messages. Empty list means valid.
158 """
159 skill_dir = Path(skill_dir)
160
161 if not skill_dir.exists():
162 return [f"Path does not exist: {skill_dir}"]
163
164 if not skill_dir.is_dir():
165 return [f"Not a directory: {skill_dir}"]
166
167 skill_md = find_skill_md(skill_dir)
168 if skill_md is None:
169 return ["Missing required file: SKILL.md"]
170
171 try:
172 content = skill_md.read_text()
173 metadata, _ = parse_frontmatter(content)
174 except ParseError as e:
175 return [str(e)]
176
177 return validate_metadata(metadata, skill_dir)

Callers 15

test_valid_skillFunction · 0.90
test_nonexistent_pathFunction · 0.90
test_not_a_directoryFunction · 0.90
test_missing_skill_mdFunction · 0.90
test_name_too_longFunction · 0.90
test_name_leading_hyphenFunction · 0.90
test_unexpected_fieldsFunction · 0.90

Calls 3

find_skill_mdFunction · 0.85
parse_frontmatterFunction · 0.85
validate_metadataFunction · 0.85

Tested by 15

test_valid_skillFunction · 0.72
test_nonexistent_pathFunction · 0.72
test_not_a_directoryFunction · 0.72
test_missing_skill_mdFunction · 0.72
test_name_too_longFunction · 0.72
test_name_leading_hyphenFunction · 0.72
test_unexpected_fieldsFunction · 0.72