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.

referencesdrizzle.md

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

Drizzle

Node.js only. Works with any Postgres provider.

Install

From the backend directory:

npm install drizzle-orm postgres dotenv
npm install -D drizzle-kit

Files

backend/
├── drizzle.config.ts
├── src/
│   ├── config/
│   │   └── env.ts          # DATABASE_URL
│   └── db/
│       ├── index.ts        # single drizzle client
│       └── schema.ts       # empty, tables go here later
├── .env
└── .env.example

drizzle.config.ts:

import 'dotenv/config';
import { defineConfig } from 'drizzle-kit';

const databaseUrl = process.env.DATABASE_URL;
if (!databaseUrl) {
  throw new Error('DATABASE_URL is not set');
}

export default defineConfig({
  dialect: 'postgresql',
  schema: './src/db/schema.ts',
  out: './drizzle',
  dbCredentials: { url: databaseUrl },
});

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/index.ts:

import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import { env } from '../config/env.js';
import * as schema from './schema.js';

const client = postgres(env.DATABASE_URL, { prepare: false });
export const db = drizzle(client, { schema });

Match the existing import style of the backend for file extensions.

src/db/schema.ts: an empty module (export {};). No tables and no placeholder comment; the report tells the user that tables go here.

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.

Scripts

Add to package.json:

  • db:generate: drizzle-kit generate
  • db:migrate: drizzle-kit migrate
  • db:studio: drizzle-kit studio

Verify

With a real DATABASE_URL, run a one-off select 1 through the db client, then delete the script.

First migration

Tell the user:

# add a table to src/db/schema.ts, then
npm run db:generate -- --name <description>
npm run db:migrate

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