|
| 1 | +--- |
| 2 | +name: typo-checker |
| 3 | +description: > |
| 4 | + Run typos-cli on the codebase, review findings, fix real typos, and update |
| 5 | + _typos.toml config to suppress false positives. Use this skill for routine |
| 6 | + codebase typo maintenance. Invoke when doing periodic codebase hygiene, |
| 7 | + when the user mentions typos or spelling checks, or as a scheduled |
| 8 | + maintenance task. |
| 9 | +--- |
| 10 | + |
| 11 | +# Typo Checker |
| 12 | + |
| 13 | +Scan the codebase with `typos-cli`, classify findings, fix real typos, and maintain `_typos.toml` so false positives don't recur. |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | + |
| 17 | +`typos-cli` must be installed. If not available, install via one of: |
| 18 | + |
| 19 | +| Method | Command | |
| 20 | +|---|---| |
| 21 | +| cargo | `cargo install typos-cli` | |
| 22 | +| brew | `brew install typos-cli` | |
| 23 | +| pipx | `pipx install typos` | |
| 24 | +| Binary | Download from https://github.com/crate-ci/typos/releases | |
| 25 | + |
| 26 | +## Workflow |
| 27 | + |
| 28 | +### 1. Scan |
| 29 | + |
| 30 | +```bash |
| 31 | +typos --format=brief |
| 32 | +``` |
| 33 | + |
| 34 | +This outputs one finding per line: `file:line:col: \`typo\` -> \`suggestion\``. Compact and easy to parse. |
| 35 | + |
| 36 | +`typos` respects `.gitignore` by default, so `node_modules/`, `dist/`, build outputs are already excluded. |
| 37 | + |
| 38 | +To get an overview first: |
| 39 | + |
| 40 | +```bash |
| 41 | +# Count unique typo words by frequency |
| 42 | +typos --format=brief 2>&1 | sed "s/.*\`//;s/\`.*//" | sort | uniq -c | sort -rn | head -20 |
| 43 | +``` |
| 44 | + |
| 45 | +If many findings come from minified/generated files, add those paths to `_typos.toml` `extend-exclude` first, then re-scan. |
| 46 | + |
| 47 | +### 2. Classify each finding |
| 48 | + |
| 49 | +For every finding, decide: |
| 50 | + |
| 51 | +- **Real typo** — fix it |
| 52 | +- **False positive** — add to `_typos.toml` |
| 53 | + |
| 54 | +Common false positive patterns: |
| 55 | +- Short variable names that happen to be words (`ba`, `fo`, `nd`) |
| 56 | +- Domain abbreviations (`als` for AsyncLocalStorage, `PnP` for Plug'n'Play) |
| 57 | +- File extensions in regexes (`.styl`, `.pcss`) |
| 58 | +- Test fixture strings and test data |
| 59 | +- Line truncation artifacts in inline snapshots (`afte...`, `wrapp...`) |
| 60 | +- Product names and proper nouns |
| 61 | +- Lorem ipsum text |
| 62 | + |
| 63 | +When in doubt about whether a misspelled variable name is "intentional" — it's still a typo. Propagated typos are still typos. Fix them. |
| 64 | + |
| 65 | +### 3. Fix real typos |
| 66 | + |
| 67 | +- **Comments, docs, JSDoc**: fix the text directly |
| 68 | +- **Variable/property names**: rename all occurrences consistently |
| 69 | +- **Test names**: fix the name, update corresponding snapshot files |
| 70 | +- **Filenames**: rename the file and update all imports/references — check for references before renaming |
| 71 | + |
| 72 | +### 4. Update `_typos.toml` |
| 73 | + |
| 74 | +Add false positives to `[default.extend-words]` with a comment explaining why: |
| 75 | + |
| 76 | +```toml |
| 77 | +[default.extend-words] |
| 78 | +# AsyncLocalStorage abbreviation |
| 79 | +als = "als" |
| 80 | +``` |
| 81 | + |
| 82 | +For file-level exclusions, use `[files].extend-exclude`: |
| 83 | + |
| 84 | +```toml |
| 85 | +[files] |
| 86 | +extend-exclude = [ |
| 87 | + "*.js.map", |
| 88 | + "*.svg", |
| 89 | +] |
| 90 | +``` |
| 91 | + |
| 92 | +If `_typos.toml` doesn't exist yet, create it. |
| 93 | + |
| 94 | +### 5. Commit |
| 95 | + |
| 96 | +Commit fixes and config updates together: |
| 97 | + |
| 98 | +``` |
| 99 | +chore: fix typos and update _typos.toml |
| 100 | +``` |
0 commit comments