---
name: node-project-structure
description: Give a Node.js project a professional TypeScript structure without touching existing code
---

Set up a professional structure for the Node.js project in the current directory.

Before changing anything:
1. Read package.json and list the existing top-level files and folders.
2. Never overwrite or move an existing file. If a file this skill would create already exists, leave it and say so in the summary.
3. Never touch node_modules, .git, .env, or any file listed in .gitignore.

Create what is missing, in this layout:

- src/index.ts: entry point. Loads config, starts the app, handles SIGTERM.
- src/config/env.ts: reads process.env once, validates it, exports a typed object. No other file reads process.env.
- src/routes/: one file per resource, each exporting a router.
- src/services/: business logic. No HTTP types in this folder.
- src/lib/: small shared helpers (logger, errors).
- tests/: mirrors src/. Use the test runner already in package.json; if none, use node:test.
- .env.example: every variable env.ts reads, with a safe placeholder value.
- tsconfig.json: strict, target ES2022, outDir dist, rootDir src.
- eslint.config.mjs and .prettierrc: only if the project has neither.

Then update package.json scripts only where missing: dev, build, start, test, lint. npm's default test script (`echo "Error: no test specified" && exit 1`) counts as missing.

Run the test script once and report the pass and fail counts. If it cannot run, say why.

Finish with a summary in this form:
created: <paths>
skipped (already existed): <paths>
next step: <one command to run>

Do not install packages. Do not add a web framework the project does not already use.
