# Contributing

> Set up a development environment, run the checks, sign off your commits and find your way around the code and docs.

Source: https://timewren.com/docs/contributing

Bug fixes, translations, integrations and docs are all welcome. TimeWren lives at [github.com/timewren/timewren](https://github.com/timewren/timewren).

## Before you start

- **Bugs:** search the existing issues first, then open one with steps to reproduce.
- **Features and larger changes:** open an issue or a thread in Discussions (Ideas) before writing code, so the approach can be agreed first.
- **Security issues:** never in public. See [Security](#security).
- Issues labelled `good first issue` are a good place to begin. `help wanted` means a pull request is welcome.

## Development setup

You need Node.js 26 or newer (`engines` in `package.json`), Docker for PostgreSQL, and npm. Fork the repository, clone your fork and run:

```bash
npm run setup
```

This creates `.env.local` with local secrets (an existing file is left alone), installs dependencies, starts PostgreSQL in Docker, runs the migrations, seeds demo data and starts the dev server in the background on `http://localhost:3000`. The log is in `.next/dev.log`, and `npm run dev:stop` stops it. Afterwards, `npm run dev` runs the server in the foreground.

To do the steps by hand, for example on a machine where you already have `.env.local`:

```bash
npm ci
npm run docker:up
npm run db:migrate
npm run db:seed
npm run dev
```

Optional services (S3 storage, email, Valkey, payments, accounting integrations) are configured in `.env.local`. `.env.example` lists every option, and you can leave them empty when you do not need them.

## Making a change

1. Branch off `main` in your fork.
2. Keep the change focused: one fix or feature per pull request.
3. Run the checks before you push:

   ```bash
   npm run lint
   npx tsc --noEmit
   npm test
   npm run i18n:check
   ```

   `npm test` runs the Vitest unit tests and needs no database. `npm run test:e2e` runs the Playwright tests against a local database, see `tests/e2e/README.md`.
4. Add or update tests when you change behaviour. For a bug, write a failing test first.
5. Database changes go through Drizzle: edit `src/lib/db/schema.ts`, then run `npm run db:generate`. Migrations are forward-only: add columns and tables, and do not drop or rename them in the same release. Never edit a migration that has been released.
6. Add a line under `## [Unreleased]` in `CHANGELOG.md` for anything a user or self-hoster would notice.
7. Open the pull request against `main`. For UI changes, add before and after screenshots made with demo data.

## Conventions

- **Formatting and linting:** Biome only. Do not add ESLint or Prettier. Format only the files you changed.
- **Code style:** the `@/*` alias maps to `src/*`, with 2-space indentation.
- **Data:** archive instead of deleting user data (`isArchived`), and filter every query by `organizationId`.
- **User-facing text** lives in `src/i18n/messages/<language>/`, never hardcoded. New text needs `en` and `da`. Other languages fall back to English.
- **No gated features:** no feature may depend on a plan, license key, brand or billing setting.
- **Commit messages** are short, in the imperative mood, with a Conventional Commits prefix: `feat:`, `fix:`, `docs:`, `refactor:`, `test:`, `chore:`. Mark breaking changes with `!`, as in `feat!: ...`.

## Sign off your commits (DCO)

TimeWren uses the [Developer Certificate of Origin](https://developercertificate.org/) instead of a CLA. Signing off a commit certifies that you wrote the change or have the right to submit it under the project's license. You keep the copyright to your work.

```bash
git commit -s -m "fix: round klippekort balance correctly"
```

This adds a `Signed-off-by: Jane Doe <jane@example.com>` line using the name and email from your git config. Forgot it? Fix the last commit with `git commit --amend -s --no-edit`, or a whole branch with `git rebase --signoff main`, then force-push your branch. Pull requests with unsigned commits cannot be merged. Rebase on `main` instead of merging it into your branch.

## Documentation

These docs live in the repository under `content/docs/<locale>/`, one `.mdx` file per page. English (`en`) is the source. Danish (`da`), German (`de`) and Spanish (`es`) hold the translations, with the same file names. Each file starts with a front matter block with a `title` and a `description`. Write plain Markdown and keep the claims true to the code.

Every page is also served as Markdown by adding `.md` to its URL, and `/llms.txt` and `/llms-full.txt` list and bundle the English docs for LLMs. See [Use these docs with your LLM](https://timewren.com/docs/llm.md).

## Security

Do not open a public issue, discussion or pull request for a security problem. Report it privately through GitHub: [Report a vulnerability](https://github.com/timewren/timewren/security/advisories/new). If you cannot use GitHub, email `security@timetrack.dk`. Include a description and its impact, steps to reproduce, and the version or commit you tested. The security policy in `SECURITY.md` lists the response targets and which components are supported.

## Governance, license and trademark

- **Governance:** the project is led by Mahope, which decides the roadmap and releases and appoints maintainers. Decisions are made in the open, in issues, pull requests and Discussions. There is no closed enterprise edition and no CLA. See `GOVERNANCE.md`.
- **License:** the code is licensed under AGPL-3.0-only. The `browser-extension/` directory is MIT. Your contribution is licensed under the license of the files you change. See `LICENSE`.
- **Name and logo:** the TimeWren name and logo are not covered by the code license. Forks must use their own name. See `TRADEMARK.md`.
- **Code of Conduct:** everyone taking part follows the Contributor Covenant in `CODE_OF_CONDUCT.md`.

## Working with AI coding agents

The repository ships `AGENTS.md` and `CLAUDE.md` with project guidance for coding agents. They follow the same rules as above, including the DCO sign-off. Do not add AI attribution trailers to commits.
