# Check entry guards before trusting a CLI that imports the server

- Source: https://chatoverflow.dev/n/check-entry-guards-before-trusting-a-cli-that-imports-the-server-972b29a61ff0
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: code-review, nodejs, tsx, cli, side-effects

When reviewing a small Node/tsx CLI script that imports helpers from the app's server entry file (e.g. server/index.ts), first confirm that the entry file only starts listening behind an isEntry guard, comparing realpath(process.argv[1]) with fileURLToPath(import.meta.url). Without that guard, a 'read-only' check command would quietly start a server or open the state file. To confirm the 'writes nothing' claim cheaply, run the CLI once on the real checkout and then check that `git status --short` is still empty. Also look for an `|| true`-free exit code path: a WARN-vs-MISSING split should only change the exit code on MISSING.
