anthropics / anthropics/skills

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

Đang mở
#239 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
176k
Fork
20.8k
Merge trung bình
7 giờ 21 phút
Pull request đã merge (30 ngày)
5

Mô tả

## 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
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.