Claude-skill-registry add-backend-testing
Add backend integration testing with Vitest to an existing app. Sets up isolated test database schema and writes tests for tRPC routers.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/add-backend-testing" ~/.claude/skills/majiayu000-claude-skill-registry-add-backend-testing && rm -rf "$T"
manifest:
skills/data/add-backend-testing/SKILL.mdsafety · automated scan (low risk)
This is a pattern-based risk scan, not a security review. Our crawler flagged:
- references .env files
Always read a skill's source content before installing. Patterns alone don't mean the skill is malicious — but they warrant attention.
source content
Add Backend Testing
Goal: Set up backend integration testing with Vitest using an isolated test database schema.
Task 1: Gather Information
Before starting, you need:
: The Timescale Cloud service ID for the databaseservice_id
If not provided, check the
DATABASE_URL in .env to find it, or use service_list MCP tool.
Task 2: Set Up Test Infrastructure
-
Use the
MCP tool:setup_testingsetup_testing(application_directory: ".", service_id: "<service_id>") -
Install Vitest:
npm install -D vitest dotenv -
Add test scripts to package.json:
{ "scripts": { "test": "vitest run", "test:watch": "vitest" } } -
Write integration tests for each tRPC router using this pattern:
import { describe, it, expect } from "vitest"; import { appRouter } from "~/server/api/root"; import { createCallerFactory } from "~/server/api/trpc"; import { db } from "~/server/db"; const createCaller = createCallerFactory(appRouter); const caller = createCaller({ session: null, db, headers: new Headers() }); describe("exampleRouter", () => { it("returns data", async () => { const result = await caller.example.getAll(); expect(result).toBeDefined(); }); }); -
Run
and ensure all tests pass before completingnpm test
Task 3: Update CLAUDE.md
Add a Testing section to CLAUDE.md with the following content:
## Testing This app uses Vitest for backend integration testing with an isolated test database schema. **Test infrastructure:** - Tests run against a separate PostgreSQL schema (see `DATABASE_SCHEMA` in `.env.test.local`) - A dedicated test user has permissions only on the test schema - Schema is automatically pushed before tests via global setup - Tests use `.env.test.local` for database configuration (gitignored) **Writing tests:** \`\`\`typescript import { describe, it, expect } from "vitest"; import { appRouter } from "~/server/api/root"; import { createCallerFactory } from "~/server/api/trpc"; import { db } from "~/server/db"; const createCaller = createCallerFactory(appRouter); const caller = createCaller({ session: null, db, headers: new Headers() }); describe("myRouter", () => { it("returns data", async () => { const result = await caller.my.getData(); expect(result).toBeDefined(); }); }); \`\`\`
Also update:
- Add
andnpm test
to the Commands sectionnpm run test:watch - Add "3. Add tests in
" to the "New tRPC Router" checklistsrc/test/routers - Update "Before Committing" section to include
:npm testnpm test && npm run check
Task 4: Commit
Ask the user if they want to commit the changes.
Task 5: Offer Further Hardening
Ask the user: "Would you like to add stricter TypeScript checks as well? This catches additional bugs that standard TypeScript misses."
If yes, follow the
add-strict-checks skill.