Templates
This skill bootstraps a local Node.js backend development stack with Docker, PostgreSQL, and an ORM (Prisma or Sequelize). It is designed to help the next user quickly install, configure, and run the skill in a Claude-compatible skill directory.
npx -y skills add WESTsyre21/setup-backend-stack --skill templatesAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Use this skill when the user wants to initialize a local development environment using Docker, PostgreSQL, an npm server, and an ORM (Prisma/Sequelize) with automated migration workflows, including detection of existing migration metadata and database readiness checks.
SKILL.md
8.2 KB, as published. Nobody here has run it
Skill: Docker + PostgreSQL + npm Server + ORM Architecture Setup
Objective
To scaffold a containerized local development ecosystem that connects an npm backend server to a Dockerized PostgreSQL instance via an ORM, establishing automated, version-controlled database migrations.
Phase 1: Environment Assessment & State Initialization
- Check capabilities: Confirm whether you have filesystem write access and shell execution access.
- If yes, perform actions and report outputs.
- If no, output exact commands and file contents and ask the user to execute them.
- Analyze Requirements: Scan the user's prompt for specific configuration choices:
- If the user does not specify an ORM, select Prisma.
- Only select Sequelize if the user explicitly includes the exact token
Sequelize(case-insensitive). - If both ORMs are mentioned or the request is ambiguous, ask: "Which ORM do you prefer: Prisma or Sequelize?"
- Chosen web framework (e.g., Express, Fastify).
- Custom port preferences (default to 3000 for server, 5432 for DB).
- Anchor State to Disk: If you have write access, create or update
.claude_history/setup_status.mdin the project root with the chosen ORM, DB connection string, and initialization checklist. If you do not have write access, print the exact commands and file contents to create or update that file and ask the user to confirm.
Phase 2: Structural Scaffolding & ORM Initialization
If running as an agent with filesystem access, execute the following commands and report results. Otherwise, print the exact shell commands and file contents and ask the user to run them.
- Confirm Docker availability:
- Run
docker --versionanddocker-compose --version. - If either command is missing, instruct: "Install Docker Desktop (https://www.docker.com/products/docker-desktop) or run your platform's Docker install instructions" and abort further steps.
- Run
- Initialize npm if no
package.jsonexists:npm init -y - Install the core backend and database dependencies:
- For Express apps:
npm install express - For Prisma:
npm install @prisma/clientandnpm install -D prisma - For Sequelize:
npm install sequelize pg pg-hstoreandnpm install -D sequelize-cli - If using
nodemonfor development, also runnpm install -D nodemon
- For Express apps:
- Ensure
package.jsoncontains adevscript. If absent, add one before running:- Example:
npm pkg set scripts.dev "node server.js" - Or:
npm pkg set scripts.dev "nodemon server.js"
- Example:
- Trigger the ORM initialization command:
- Prisma:
npx prisma init(generates/prisma/schema.prismaand updates.env) - Sequelize:
npx sequelize-cli init(generates/models,/migrations,/seeders,/config)
- Prisma:
Phase 3: Defensive Configuration Generation
Generate the following configuration blocks using this exact variable map template:
DB_USER=postgresDB_PASSWORD=postgresDB_HOST=localhostDB_PORT=5432DB_NAME=app_dbHOST_DB_PORT=5432
1. docker-compose.yml
- Must use named volume persistence (
pgdata). - Ensure the docker-compose service maps host port
${HOST_DB_PORT}to container port5432. - For host-based development,
.envshould useDB_HOST='localhost'andDB_PORT='${HOST_DB_PORT}'. - If the server itself runs in a container, set
DB_HOSTto the compose service name andDB_PORTto5432.
2. Database URL Configuration (.env)
- Construct the fully qualified connection string required by the ORM.
- Format for Prisma:
DATABASE_URL="postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?schema=public" - If migrations fail with authentication errors, print the CLI error, verify
.envvalues forDB_USER/DB_PASSWORD/DB_HOST/DB_PORT/DB_NAME, and show the exact command to test the connection:psql postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME} -c '\l'
3. Baseline Schema & Seed Files
- Detect project type: if
package.jsoncontainstypescriptortsconfig.jsonexists, preferprisma/seed.tsand add aseedscript usingts-node. - Otherwise generate
seed.jsand add aseedscript usingnode. - Prisma: Create a boilerplate
UserorHealthCheckmodel insideprisma/schema.prisma. - Sequelize: Generate an initial model configuration file.
- If a migrations metadata table (
_prisma_migrationsorSequelizeMeta) already exists, do not run the initialinitmigration. Instead detect the table and either:- prompt the user to create a baseline migration matching the current schema, or
- instruct how to mark migrations as applied using the ORM's baseline/seed workflow.
4. Application Server Entrypoint (server.js)
- Import and instantiate the ORM client (e.g.,
const prisma = new PrismaClient()). - Replace raw SQL queries with ORM-native health checks:
- For Prisma: use
await prisma.user.findFirst()orawait prisma.$executeRaw('SELECT 1')only if necessary. - For Sequelize: use
await sequelize.authenticate().
- For Prisma: use
Phase 4: Automated Migration & Verification Loop
Do not mark this skill as complete until the entire stack passes this operational gate:
- Container Orchestration: Spin up the database using
docker-compose up -d. - Wait for DB readiness: After
docker-compose up -d, wait for PostgreSQL to accept connections with a retry loop:- Retry up to 15 times with 2s backoff (maximum 30s).
- Use
pg_isreadyor a TCP connect to${DB_HOST}:${DB_PORT}.
- Existing migration metadata detection: If
_prisma_migrationsorSequelizeMetaalready exists, do not run the initialinitmigration. Prompt for a baseline migration or marking migrations as applied. - The Migration Gate: Execute the schema migration:
- Prisma:
npx prisma migrate dev --name init - Sequelize:
npx sequelize-cli db:migrate
- Prisma:
- Database Inspection: Verify that the metadata table (
_prisma_migrationsorSequelizeMeta) exists in the container. - Client Generation (If Prisma): Run
npx prisma generateexplicitly. - Integration Run: Ensure
package.jsonhas adevscript, then start the server and hit/healthto confirm the ORM client can read the database schema. - Update State: Mark all items complete in
.claude_history/setup_status.md.
Phase 5: Error Mitigation Protocol
Handle failures in a flat deterministic sequence with explicit retries:
- Docker availability failure: If
dockerordocker-composeis not found, rundocker --versionanddocker-compose --version, then instruct: "Install Docker Desktop (https://www.docker.com/products/docker-desktop) or run your platform's Docker install instructions." Abort until Docker is available. - DB readiness failure: If PostgreSQL does not accept connections, retry
pg_isreadyor TCP connect up to 15 attempts with 2s backoff. If still failing, collect container logs and fail with exact diagnostic output. - Authentication failure: If migrations fail with authentication errors, print the CLI error, verify
.envvalues forDB_USER/DB_PASSWORD/DB_HOST/DB_PORT/DB_NAME, and show:psql postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME} -c '\l' - Prisma shadow DB permission failure: If Prisma cannot create a shadow database due to permissions, instruct the user to provide an explicit shadow database URL in
schema.prismaor use a DB user withCREATEDBprivileges. Show the exact schema snippet and env var to add. - Dev script absence: If
npm run devis not available, add thedevscript vianpm pkg set scripts.dev "node server.js"ornpm pkg set scripts.dev "nodemon server.js"before retrying. - Schema/migration failure: If migration still fails after two retries due to invalid schema syntax or constraints, halt execution and write a diagnostic summary file (
setup_error.log) with the exact CLI error output.