anthropics / anthropics/skills

[Bug] skill-creator: Generated SKILL.md fails validation due to YAML list parsing in description field

未关闭
#239 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
176k
派生
20.9k
平均合并
7 小时 21 分钟
30 天内合并 PR
5

描述

## Description

The `init_skill.py` script generates a SKILL.md template with a `description` field that uses square brackets `[TODO: ...]`, which causes YAML parsers to interpret it as a list instead of a string. This results in validation failures when running `quick_validate.py` on freshly generated skills.

## Steps to Reproduce

1. Generate a new skill using the official script:
```bash
python3 skills/skill-creator/scripts/init_skill.py test-skill --path /tmp
```

2. Run validation on the generated skill:
```bash
python3 skills/skill-creator/scripts/quick_validate.py /tmp/test-skill
```

3. Observe the validation error.

## Expected Behavior

- The generated SKILL.md should pass validation without modification
- Users should be able to validate freshly created skills
- The template should produce YAML-compliant frontmatter

## Actual Behavior

**Validation Error:**
```
Description must be a string, got list
```

**Root Cause:**

The template in `init_skill.py` (line 21) generates:
```yaml
---
name: {skill_name}
description: [TODO: Complete and informative explanation of what the skill does and when to use it...]
---
```

When YAML parses this, the square brackets `[ ]` are interpreted as an array/list syntax, and the content with a colon (`:`) is parsed as a key-value pair within that list:

```python
# YAML parsing result
{
'name': 'test-skill',
'description': [{'TODO': 'Complete and informative explanation...'}]
}
# Type: list, not str
```

The validator in `quick_validate.py` (lines 74-76) expects a string:
```python
description = frontmatter.get('description', '')
if not isinstance(description, str):
return False, f"Description must be a string, got {type(description).__name__}"
```

## Impact

- **User Experience**: Freshly generated skills fail validation immediately
- **Confusing Error**: Users may think they made an error when they followed the template exactly
- **Workflow Broken**: The official workflow (generate → validate → package) is broken out of the box

## Suggested Fix

Change the template in `init_skill.py` to quote the description value:

```python
SKILL_TEMPLATE = """---
name: {skill_name}
description: "TODO: Complete and informative explanation of what the skill does and when to use it. Include WHEN to use this skill - specific scenarios, file types, or tasks that trigger it."
---
```

This ensures the YAML parser interprets it as a string:
```python
# Parsed result with quotes
{
'name': 'test-skill',
'description': 'TODO: Complete and informative explanation...'
}
# Type: str ✓
```

## Environment

- **Repository**: anthropics/skills
- **Skill**: skill-creator
- **Affected Files**:
- `skills/skill-creator/scripts/init_skill.py` (line 21)
- `skills/skill-creator/scripts/quick_validate.py` (lines 74-76)

## Verification

This issue can be reproduced with the current main branch scripts:
```bash
# Download official scripts
curl -O https://raw.githubusercontent.com/anthropics/skills/main/skills/skill-creator/scripts/init_skill.py
curl -O https://raw.githubusercontent.com/anthropics/skills/main/skills/skill-creator/scripts/quick_validate.py

# Generate skill
python3 init_skill.py test --path /tmp

# Validate (will fail)
python3 quick_validate.py /tmp/test
# Output: Description must be a string, got list
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。