anthropics / anthropics/skills

skill-creator scripts crash on Windows for any skill containing non-ASCII text (missing encoding on read_text())

オープン
#1,686 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
176k
フォーク
20.9k
平均マージ
7時間 21分
マージ済み PR(30日)
5

説明

## Summary

Three scripts in `skills/skill-creator/scripts/` read or write text without
specifying an encoding. On Windows, Python defaults to the ANSI code page
(cp1252 on most systems), so any SKILL.md containing non-ASCII characters
raises `UnicodeDecodeError` before validation begins.

This affects Anthropic's own shipped skills. In a local library of 60 skills,
**28 crashed the validator (47%)**, including `docx`, `pdf`, `pptx`, `xlsx`,
`mcp-builder`, and `webapp-testing`.

The bug is invisible on macOS and Linux, where the default encoding is UTF-8.

## Reproduction

Windows, Python 3.x:

```bash
mkdir crash-demo && cd crash-demo
cat > SKILL.md <<'EOF'
---
name: crash-demo
description: Provjeri dostupnost artikla i rok isporuke.
---
Body.
EOF
cd ..
python skills/skill-creator/scripts/quick_validate.py crash-demo
```

Result:

```
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 1476:
character maps to
```

Any non-ASCII character reproduces it — accented Latin, CJK, emoji, or a
typographic dash.

## Affected locations

**1. `scripts/quick_validate.py`, line 22**
```python
content = skill_md.read_text()
```
Crashes before any validation runs.

**2. `scripts/utils.py`, line 9 (`parse_skill_md`)**
```python
content = (skill_path / "SKILL.md").read_text()
```
Same defect. Reached via `improve_description.py` and `run_eval.py`, so the
description-optimization loop fails on the same skills.

**3. `scripts/package_skill.py`, line 122 (separate but related)**
```python
print(f"\U0001f4e6 Packaging skill: {skill_path}")
```
Raises `UnicodeEncodeError` writing the 📦 emoji to a cp1252 console, so
packaging fails on Windows for *every* skill regardless of content:
```
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f4e6'
```
Confirmed workaround: `PYTHONIOENCODING=utf-8`.

## Suggested fix

For the two readers:

```python
content = skill_md.read_text(encoding="utf-8-sig")
```

`utf-8-sig` is byte-identical to `utf-8` on files without a byte-order mark
and additionally tolerates one when present. A real BOM was found in the
wild during this investigation, and it silently breaks the
`content.startswith('---')` frontmatter check under plain `utf-8`.

For `package_skill.py`, either reconfigure stdout at entry:

```python
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
```

or drop the emoji from console output.

## Impact

Windows users cannot validate or package a skill whose SKILL.md contains any
non-ASCII character — which includes most non-English skills and several of
Anthropic's own. Because `validate_skill()` is called by `package_skill.py`,
the failure also blocks distribution.

## Notes

`quick_validate.py` reads bytes in the fixed version and normalises newlines
explicitly, since `read_bytes()` bypasses Python's universal-newline
translation that the `^---\n` frontmatter regex depends on. `utils.py` uses
`read_text()` and therefore needs only the encoding argument.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start with skills/skill-creator/scripts/quick_validate.py, utils.py, and package_skill.py at the affected locations, then run the Windows reproduction with a non-ASCII SKILL.md. Trace the quick_validate.py, improve_description.py, run_eval.py, and package_skill.py entry points; done means validation and packaging handle the described non-ASCII and BOM cases on Windows without encoding errors.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
活発
明瞭さ
明確に書かれている
初心者へのやさしさ
75/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。