---
title: Contributing
description: "Set up the keypal repository, run the unit tests and the Redis and Postgres suites locally, and send a pull request that keeps every key working."
---

keypal is MIT licensed and developed in the open on [GitHub](https://github.com/izadoesdev/keypal). Bug reports, fixes, docs edits, and new storage adapters are all welcome.

## Before you start

- Search [open issues](https://github.com/izadoesdev/keypal/issues) first. If your change is large, open an issue to agree on the approach before writing it.
- Don't report a security problem in a public issue. Contact the maintainer, [@izadoesdev](https://github.com/izadoesdev), privately first.

## Set up

keypal uses [Bun](https://bun.sh) for installs and scripts and [Vitest](https://vitest.dev) for tests.

```bash
git clone https://github.com/izadoesdev/keypal
cd keypal
bun install
bunx lefthook install  # once, enables the pre-commit hook

# Everything that doesn't need a database
bunx vitest run \
  --exclude '**/redis.test.ts' \
  --exclude '**/drizzle.test.ts' \
  --exclude '**/kysely.test.ts' \
  --exclude '**/prisma.test.ts'
```

`bun run test` starts Vitest in watch mode; `bunx vitest run` runs once and exits. That covers key generation, hashing, verification, scopes, the manager, and the memory store.

## Test against the databases

The adapter tests run against real servers. `docker-compose.yml` starts one of each, on the ports the tests expect:

```bash
docker compose up -d
```

| Service | Port | Test command |
| --- | --- | --- |
| Redis | 6379 | `bun run test:redis` |
| Postgres for Kysely | 5433 | `bun run test:kysely` |
| Postgres for Drizzle | 5434 | `bun run test:drizzle` |
| Postgres for Prisma | 5435 | `bun run test:prisma`, after creating the schema once (below) |

:::warning
The Redis tests clear the database they connect to. Point them at the Compose container, or set `REDIS_HOST` and `REDIS_PORT` to a Redis that holds nothing you need.
:::

The Prisma suite needs its schema pushed once. `prisma/schema.prisma` reads `DATABASE_URL`, so set it to the Compose database unless you already point it elsewhere:

```bash
DATABASE_URL="${DATABASE_URL:-postgresql://keypal:keypal_dev@localhost:5435/keypal_prisma}" bunx prisma db push
```

Each Postgres suite also reads `DATABASE_URL` if you'd rather use your own server.

## Making a change

- Keep key generation and hashing byte-for-byte compatible. `src/core/compat.test.ts` pins hashes from earlier releases; if it fails, existing users' keys would stop verifying.
- Add a test that fails without your change. Storage changes belong in the shared contracts in `src/storage/store-contract.ts`, so every adapter is held to them.
- Run `bun run typecheck` and `bunx ultracite check` before you push. The pre-commit hook formats staged files for you once you've run `bunx lefthook install`.
- Update the docs in `apps/docs/docs` when behavior changes. Run them locally with `cd apps/docs && bun install && bun run dev`.

## Pull requests

Write the PR description for someone who hasn't read the code: what changed, why, and how you tested it. CI runs the unit tests and every database suite on each push.

## Releases

Releases are published to npm from GitHub Actions with provenance. Each GitHub release appears in the changelog at keypal.dev/changelog.
