anthropics / anthropics/skills

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

Offen
#1,686 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
176k
Forks
20.9k
Ø Merge
7 Std. 21 Min.
Gemergte PRs (30 T.)
5

Beschreibung

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Aktiv
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
75/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.