Safe vibe coding for TypeScript.
npx strong-modestrong-mode hardens existing TypeScript projects with strict defaults, sharper lint rules, and quality guardrails built for AI-assisted coding. It upgrades the tooling around your codebase without rewriting the app itself.
Requires an ES module project (
"type": "module"inpackage.json). CommonJS projects are rejected before anything is written; see Roadmap / Known limitations.
strong-mode layers a strict baseline onto an existing repository. You keep your app code; it adds the rails around it.
TypeScript (tsconfig.json):
- All 20 options in TypeScript 5.9's Type Checking category (
strictand its family,noUncheckedIndexedAccess,exactOptionalPropertyTypes,noImplicitOverride,allowUnreachableCode: false, …), plusnoCheck: false(forced even over an explicit project value) andskipLibCheck: falseby default - An existing
tsconfig.jsonis read as JSONC and edited in place. Its type-checking options take the template's values, and strong-mode lists each explicit option it raised (or would raise with--dry-run). Other scalars, includingskipLibCheck,verbatimModuleSyntaxandisolatedModules, keep the project's values; arrays keep the project's elements, including duplicates, and append only missing template elements; the project'sextendsis preserved. Intsconfig.eslint.json,excludetakes the template's value: missing entries are appended if it starts with the project's array; otherwise it is replaced as a whole. Comments are kept, including a comment next to a type-checking option when that option is raised. The only comments deleted are those inside a value strong-mode owns and replaces as a whole; in a valid tsconfig, that is a replacedexcludearray intsconfig.eslint.json. A comment on the same line after the last entry of an object or array can end up after inserted entries, and the neighbouring line can be reindented or respaced. - A leading UTF-8 BOM is accepted and kept. Tsconfigs with duplicate keys in any object or
any key named
__proto__get conflict markers with a warning explaining the fallback.
ESLint (eslint.config.mjs):
- No
any, nots-expect-errorwithout a 10-char description, no chained assertions (as unknown as T) process.envaccess restricted tosrc/env.ts- Complexity limits: cyclomatic ≤ 10, depth ≤ 3, params ≤ 4
- Type-aware linting of every TypeScript file in the project (any framework layout) through
tsconfig.eslint.json
Runtime validation (src/env.ts, tested by tests/env.test.ts — added only when the project uses the template's src/env.ts and its test script clearly runs only Vitest and none of Jest, Playwright, Mocha, AVA or Jasmine is declared in dependencies or devDependencies):
- Zod-based env validation template — all
process.envaccess goes through here; invalid values throw at startup
Quality gates (npm scripts):
check: typecheck + lint + format check + dead code (fast, pre-commit)quality: check + tests + coverage + dep graph + dep cycles + audit (full)test: runs Vitest with coverage thresholds (90% lines/functions/statements, 85% branches) on every run
Tooling configs: Prettier, Vitest, Knip (dead code — framework-aware: it relies on knip's defaults and plugins, so Next.js, Vite, Astro and other layouts are analysed by their real entry points), dependency-cruiser, lefthook (git hooks)
--dry-run Preview changes without writing files
--yes Skip prompts; conflicting files get Git-style conflict markers
--backup Back up existing files before overwriting or writing conflicts
--force Overwrite conflicts without prompting
--no-install Skip dependency installation
--no-check Skip post-apply typecheck/lint/test run
--pm <manager> Package manager: npm | pnpm | yarn | bun
--cwd <path> Target directory (default: current directory)
strong-mode compares 14 managed files from its template against your project. New files are created automatically. Existing managed files can be merged, skipped, overwritten, or written with Git-style conflict markers depending on the file type and flags you use. package.json is handled structurally, so scripts and dependencies are added without flattening the rest of your project config.
- Vitest coverage matches your Vitest.
@vitest/coverage-v8must be the exact same version asvitest. If the project already uses Vitest, the coverage package is added after install, pinned to the Vitest version your package manager actually installed. When dependencies are not installed (--no-install, or conflicts left to resolve), strong-mode prints the command to run instead. - Replaced packages are cleaned up safely. A package the template no longer ships (for example
eslint-plugin-eslint-comments, replaced by@eslint-community/eslint-plugin-eslint-comments) is removed fromdevDependenciesonly wheneslint.config.mjsends up with the template content, so a config you kept still finds its plugin. It is kept when it is a runtime dependency, when the project is a workspace root, or when another ESLint config (eslint.config.js,.eslintrc*, or one a script selects witheslint --config) may still load it. - ES modules. A
package.jsonwithout"type"is switched to"type": "module", and strong-mode warns first, because CommonJS.jsfiles (require/module.exports) stop working. - Compatible peers. The template adds Vitest 5, which needs Vite 6.4 or later. A project that pins an older Vite (for example
~6.3.0), or whose installed Vite is older, and has no Vitest of its own is rejected before anything is written, with the upgrade to run.
npm install
npm run sync:template # sync scaffold into CLI package
npm run check # typecheck + lint + test
npm run build # build CLITest locally:
npm run build -w strong-mode
node packages/strong-mode/dist/cli.js --dry-run --yes.github/workflows/ci.ymlruns install, check, build,npm pack, and smoke tests of the packed CLI on every push/PR: a dry run, a real apply on a fresh ESM project that must then pass its owncheck(including dead code), and a CommonJS project that must be rejected..github/workflows/publish.ymlreruns validation, packs the tarball, smoke-tests it, and publishespackages/strong-modeonv*tags or manual dispatch.- The first npm publish for a new package may need to be done manually. After the package exists, configure npm trusted publishing to trust this repository and
.github/workflows/publish.yml.
- The template's
src/env.tstargets Node. It readsprocess.env; in a bundle withoutprocess, it throws on import. - Tsconfig insertion can move comments and change neighbouring formatting. A comment on the same line after the last entry of an object or array can end up after the entries strong-mode inserts. Inserting can re-indent or re-space the neighbouring line; inserted content uses 2-space indentation.
- CommonJS projects are not supported yet. The template is ESM-only (
module: NodeNext+verbatimModuleSyntax), sostrong-modestops before writing anything whenpackage.jsonhas"type": "commonjs". Planned: a CommonJS-awaretsconfig.json(verbatimModuleSyntax: false, withconsistent-type-importskeeping type-only imports explicit), and no longer switching apackage.jsonwithout"type"to"module". - Other gates still assume a
src/layout. The template'srootDir: ./srcmakestypecheckfail (TS6059) for any file outsidesrc/that the project's tsconfig includes (for example Next.jsapp/or a root*.config.ts);deps:graphanddeps:cyclesonly scansrc(madge only.ts); coverage only measuressrc/**/*.ts. Planned: derive these from the project layout. - Upgrading from an older strong-mode. Re-running
strong-modeon a project that already has an older version of the managed files treats every file that differs from the current template as a conflict (with--yes,tsconfig.json,tsconfig.eslint.json,.gitignoreand.prettierignoreare merged structurally (the ignore files by lines) and the rest get Git-style markers), and replaced packages stay untileslint.config.mjsmatches the template. Planned: recognize previously shipped template versions and update them in place. - Monorepos lint with one root program. Type-aware lint uses the root
tsconfig.eslint.jsonfor every file, so a workspace package's owncompilerOptions(for examplepathsaliases) do not apply and can produce falseno-unsafe-*errors. Planned: one lint program per workspace package. - Vitest is the only supported test runner. When the project keeps another
testscript (Jest,node --test, …), strong-mode does not addtests/env.test.ts, buttest:coverageandqualitystill run Vitest over the project's tests. Planned: detect the test runner and adapt the gates to it. - Projects with another ESLint config. ESLint loads an existing
eslint.config.jsbefore the managedeslint.config.mjs, so the strong-mode rules do not apply until they are merged into it. strong-mode warns about it but does not merge them yet. Planned: manage the config file the project already uses. - Yarn Classic (v1) and bun break type-aware lint.
eslint-plugin-sonarjsdeclares its owntypescriptdependency, and Yarn Classic and bun install a second TypeScript copy for it (TypeScript 7, which drops the JS API, so ESLint crashes loading the plugin; with newer sonarjs releases TypeScript 6, whichts-api-utilsthen picks up, producing false lint errors). npm deduplicates it to the project's TypeScript. Typecheck and tests are not affected. npm and pnpm are verified for now (Yarn Berry is not verified for this case). Planned: keep a single TypeScript version in the tree. - Peer checks need node_modules to see the installed version. The Vite check reads the declared range and the installed version. A checkout with only a lockfile (no
node_modules) or Yarn PnP is checked by declared range only (and not at all when Vite is declared with a non-semver specifier such ascatalog:or annpm:alias), so a range that also allows Vite 6.4+ (for example^5.0.0 || ^6.0.0) passes even when the lockfile pins an older Vite. Planned: read the locked version from the lockfile. - Runtime dependencies are merged per section. Template
devDependenciesalready skip packages the project declares independencies, but the reverse is not handled yet: a template runtime dependency (for examplezod) that the project lists indevDependenciesis added again todependencies. Planned: treat a package declared in either section as present.