# @macrulez/devtoolz — AI Reference A toolbox of independent command-line commands (binary `devtoolz`) for routine developer chores on a JavaScript/TypeScript project: strip comments and leftover `console.log`, find dead exports and unused dependencies, catch import-case bugs that only break on Linux CI, find import cycles, verify `package.json` paths and README code examples, find swallowed errors, collect TODOs, check scripts and test files for consistency, find stale `@ts-ignore`. One binary, one subcommand per chore. The image commands `image-hash` and `image-batch` moved to `@macrulez/mediatoolz` in 0.5.0; here they are stubs that print where they went and exit 2. Version 0.5.0. This document is hand-written for AI agents and other tools that drive this CLI: every flag, default, exit code and behavior note below is verified against the TypeScript source. It covers what `--help` does not make obvious: which command to pick, whether a command can change files, exit codes, the JSON shapes, the rules each check uses to decide something is a problem, and the false positives to expect. For narrative docs, see the site: - Full docs (EN): https://npm.vuecraft.ru/en/packages/devtoolz/guide/overview - Full docs (RU): https://npm.vuecraft.ru/packages/devtoolz/guide/overview - GitHub: https://github.com/macrulezru/devtoolz - npm: https://www.npmjs.com/package/@macrulez/devtoolz Links starting with "/" are relative to https://npm.vuecraft.ru. Install: `npm install -g @macrulez/devtoolz`, or run without installing: `npx @macrulez/devtoolz ...`. Node >= 20. --- ## 1. Read this first — rules that prevent most mistakes 1. **Only these commands can change files: `strip-comments`, `console-strip`, `case-check --fix`.** Everything else is read-only. The three code-changing ones PREVIEW by default and write only with `-y`/`--yes` (and never with `--dry-run`). 2. **Exit code 1 means "found something", not "the tool broke".** Every diagnostic command exits 1 when it reports findings and 0 when clean. A preview of a code-changing command that WOULD change something also exits 1 (so a CI step fails until the change is applied). There is no separate code for a crash: an uncaught exception also exits 1. See section 4 for the exact rules. 3. **Add `--json` whenever you will parse the result.** It prints the full report as one JSON document on stdout, with no banner and no color. The human text output is for people; do not parse it. 4. **Output is colored only in a real terminal.** Piped, `CI`, `NO_COLOR`, `TERM=dumb` turn color off; `--color` or `FORCE_COLOR=1` force it on; `--plain` removes color, the banner and the joke lines; `--quiet` prints nothing when there is nothing to report. Text is identical with and without color. 5. **Nothing here is interactive except `full-check` (one question).** It is avoidable: `full-check --no-prompt`. Without a terminal nothing asks. 6. **`[paths...]` vs `[dir]`.** Some commands take file/directory paths to scan (`[paths...]`, default current directory); others take ONE package directory (`[dir]`, default `.`) because they read one `package.json` there. Passing a directory to a `[dir]` command does not scan sub-packages. 7. **Preview before applying**: run the code-changing commands once without `-y` (add `--diff` to see exactly what changes), then again with `-y`. --- ## 2. Choosing a command | Task | Command | Changes files? | |---|---|---| | Remove `//`, `/* */`, `/** */`, `` comments | `strip-comments` | with `-y` | | Remove forgotten `console.log`/`console.debug`/`debugger` | `console-strip` | with `-y` | | Exports nothing imports | `dead-exports` | no | | Dependencies nothing imports / imports not declared | `unused-deps` | no | | Import cycles | `circular-imports` | no | | Import path case differs from the file on disk | `case-check` | with `--fix -y` | | `package.json` main/module/types/bin/exports point at missing files | `exports-doctor` | no | | README/docs `ts` code blocks do not typecheck | `readme-check` | no | | `catch` blocks that swallow the error | `empty-catch` | no | | List TODO/FIXME/HACK | `todo-report` | no | | Docs/CI mention a script that does not exist | `scripts-check` | no | | Test files whose source is gone | `orphan-tests` | no | | `@ts-ignore` that suppresses nothing | `stale-ts-ignore` | no | | Run all diagnostics, one summary | `full-check` | no (always preview) | Typical pre-commit chain: `case-check`, `circular-imports`, `dead-exports`, `unused-deps`, `empty-catch`. Typical library-publish chain: `exports-doctor`, `readme-check`, `scripts-check`. Or just `full-check`. --- ## 3. Shared behavior ### Common flags Present on EVERY command: `--json`, `--quiet`, `--plain`, `--color`. Commands that scan files also take: `--cwd ` (paths are resolved against it, default the current directory), `--ext `, `--ignore ` (repeatable, added on top of the defaults), `--no-respect-gitignore`. ### What gets scanned `[paths...]` are files and/or directories (directories are walked recursively). An explicitly named file is included whatever its extension. Always ignored: `node_modules`, `dist`, `build`, `.git`, `coverage`, `.nuxt`, `.output`, `.next`; plus the `.gitignore` in the `--cwd` root only (nested `.gitignore` files are NOT read); plus every `--ignore` pattern (gitignore syntax). `dead-exports` also always skips build-tool config files (`*.config.{ts,js,mjs,cjs}`). Default extensions: `.ts,.tsx,.js,.jsx,.cjs,.mjs` (+ `.vue` for `strip-comments`, `console-strip`, `case-check`, `empty-catch`, `todo-report`). `.vue`: the `