anthropics / anthropics/skills

docx skill: scripts need Python 3.10+ and defusedxml, but SKILL.md declares neither

Open
#1,461 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
176k
Forks
20.8k
Avg merge
7h 21m
Merged PRs (30d)
5

Description

## Summary

The docx skill's Python scripts fail on macOS system Python (3.9) in two ways, and neither requirement is declared:

1. `skills/docx/scripts/merge_runs.py` imports third-party `defusedxml` (`import defusedxml.minidom`, line 33). Not preinstalled on a stock Mac, so the first failure is `ModuleNotFoundError: No module named 'defusedxml'`.
2. After installing defusedxml, the import chain still breaks on Python 3.9: `merge_runs.py` does `from office.helpers import ...`, and `skills/docx/scripts/office/helpers/__init__.py` line 24 uses PEP 604 union syntax in a signature (`-> str | None`), which raises `TypeError: unsupported operand type(s) for |` at import time on anything below 3.10. Same syntax appears in `office/helpers/pptx_chart.py` (lines 89, 101).

SKILL.md's Dependencies section lists `docx` (npm), pandoc, LibreOffice, and pdftoppm, but no Python version or Python packages, and its usage examples invoke bare `python scripts/merge_runs.py ...`. A model following the skill on a machine where `python3` is 3.9 hits two consecutive dead ends and falls back to hand-editing `word/document.xml`, which is exactly what merge_runs.py exists to make safe.

## Environment

- macOS (Darwin 25.3.0), system python3 = 3.9
- Claude Code desktop app, bundled docx skill (matches current main of this repo)

## Suggested fix (any of these)

- Declare `Python >= 3.10` and `defusedxml` in SKILL.md's Dependencies line so the model installs/selects correctly up front
- Add an early version gate in the scripts (`sys.version_info` check with a clear message) so the failure is one obvious error instead of two confusing ones
- Or drop the 3.10-only syntax (use `Optional[str]`) and fall back to stdlib `xml.dom.minidom` when defusedxml is missing, since the input is the user's own file

🤖 Filed with [Claude Code](https://claude.com/claude-code)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.