cleanup-weak-types
Installation
SKILL.md
Replace weak escape-hatch types with strong types inferred from actual usage. Per-occurrence verification — each replacement is typechecked individually, reverted if it breaks. Conservative on public APIs.
Preflight
- Language detect: TS/JS (
any,unknown,as unknown as,Function,Object), Python (Any, missing type hints), Go (interface{},anysince 1.18), Rust (Box<dyn Any>is rare; mostly look forBox<dyn Trait>where a concrete type would do). - Git state: refuse on dirty tree.
- Report dir: ensure exists.
- Read project conventions: check for a
check:weak-types(or similar) script in package.json. Checktsconfig.jsonforstrict/noImplicitAnyflags. Checkmypy.ini/pyproject.toml [tool.mypy]for strictness. - Read allow-list: many projects allow weak types in specific files (e.g.,
*.test.ts, generated code, third-party shim files). Find and respect them.
Detect
TypeScript / JavaScript
# Explicit `any`
grep -rn --include="*.ts" --include="*.tsx" -E "\b(: any\b|<any>|as any\b|as unknown as)" \
--exclude-dir=node_modules --exclude-dir=dist --exclude-dir=.next . > /tmp/ts-weak.txt