Index of every page on this site: llms.txt
All skills
akdevsaha-dev avatar

/init-database

@ce26f0a
Run it yourself

Connect an existing backend to a database using Prisma, Drizzle, or Supabase. Sets up config, the client, and environment variables without creating tables. Use when the user asks to initialize, set up, add, or connect a database.

Use this Skill: https://skilld.dev/gh/akdevsaha-dev/factory-skills/init-database

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesprisma.md

≈657 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Prisma

Node.js only. Works with any Postgres provider.

Install

From the backend directory:

npm install @prisma/client @prisma/adapter-pg pg dotenv
npm install -D prisma @types/pg
npx prisma init --datasource-provider postgresql

Use the current stable Prisma version. Prisma 7 and later read the database URL from prisma.config.ts and need the @prisma/adapter-pg driver adapter. If an older major version is installed, put the URL in the datasource block instead and drop the adapter.

Files

backend/
├── prisma/
│   └── schema.prisma       # generator + datasource, no models
├── prisma.config.ts
├── src/
│   ├── config/
│   │   └── env.ts          # DATABASE_URL
│   └── db/
│       └── prisma.ts       # single PrismaClient
├── .env
└── .env.example

prisma/schema.prisma:

generator client {
  provider = "prisma-client"
  output   = "../src/generated/prisma"
}

datasource db {
  provider = "postgresql"
}

No model blocks. Add src/generated/ to .gitignore.

prisma.config.ts:

import 'dotenv/config';
import { defineConfig, env } from 'prisma/config';

export default defineConfig({
  schema: 'prisma/schema.prisma',
  migrations: { path: 'prisma/migrations' },
  datasource: { url: env('DATABASE_URL') },
});

src/config/env.ts: add DATABASE_URL: z.string().url() to the existing Zod schema, or create the file with that schema if it does not exist.

src/db/prisma.ts: create one PrismaClient with new PrismaPg({ connectionString: env.DATABASE_URL }) as the adapter. Export it as prisma. Import PrismaClient from the generated output path.

Environment

.env and .env.example:

# Paste your Postgres connection string from Neon, Aiven, Supabase, RDS, or any provider.
DATABASE_URL="postgresql://USER:PASSWORD@HOST:5432/DATABASE?sslmode=require"

Tell the user to replace the placeholder in .env. On Supabase, use the direct or session connection on port 5432 for migrations.

Scripts

Add to package.json:

  • db:generate: prisma generate
  • db:migrate: prisma migrate dev
  • db:deploy: prisma migrate deploy
  • db:studio: prisma studio

Verify

npx prisma validate
npx prisma generate

With a real DATABASE_URL, also run npx prisma migrate status. It connects without changing anything.

If prisma generate refuses to run with no models, skip it and say so.

First migration

Tell the user:

# add a model to prisma/schema.prisma, then
npx prisma migrate dev --name <description>

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts11d3 checks · Risk SAFE
  • Gen Agent Trust Hub11d

    This skill securely initializes a database layer for Node.js, Python, or Go projects. It automates the setup of connection pools and migrations using trusted tools like Prisma and Drizzle, while enforcing security best practices like parameterized queries and environment-based secret management.

  • Socket11d

    No alerts

  • Snyk11d

    Risk: LOW · No issues

Signed by skilld at ce26f0a. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 2 weeks ago

README badge

README badge for akdevsaha-dev/factory-skills/init-database