> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gatojs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Working with the kit

> How your GatoJS project relates to the kit: which changes stay local and which to send upstream, commit conventions, the npm run verify gate, generated files and staying up to date.

GatoJS is not a dependency you import. `gato create` copies the kit's code into your repository, and from then on it is **your code**: you can read it, change it and delete it like anything else you wrote. This page covers what that means in practice: where a change belongs, which checks it passes on the way in, which files you must not edit by hand, and how to pull in later kit releases.

## Your project and the kit

`.wa/kit.json` records where your code came from: the kit version, the repository it came from, and for each kit module its manifest and a hash of every file it installed. Those hashes let `gato update` and `gato remove` tell which kit files you've changed locally. Your own features live in a separate `projectModules` section with no hashes, so the CLI never touches them. See the [`.wa/kit.json` reference](https://docs.gatojs.com/cli/kit-json).

Fixes made in the kit reach an existing project only through a new kit release and `npx gato update` in your project. The reverse is also true: a fix you make in your project stays there unless you send it upstream.

### What stays in your project and what goes upstream

Ask one question: **would this change be correct in every project built on the kit?**

| Change | Where | Why |
| - | - | - |
| A domain feature: `src/features/<x>/`, its schema file in `prisma/schema/`, its `projectModules` entry, its pages | Your project | It's specific to your app. See the [feature tutorial](https://docs.gatojs.com/guides/build-a-feature.md). |
| Project name and slug in `src/shared/config/project.ts` | Your project | Every project has its own. |
| Migrations in `prisma/migrations/` | Your project | Migration history depends on your modules; the kit doesn't commit migrations. |
| A bug in core code: a guard, command, query, component, environment validation | Upstream, and in your project right away if it's urgent | The same code is in every project. |
| Shared strings in `src/app/messages/`, a new language | Upstream | Core strings and the locale list are kit code. |
| Changes to the CLI or generator | Upstream | Generator output must be identical everywhere. |
| Agent rules (`AGENTS.md`, `CLAUDE.md`), hooks and agents in `.claude/`, CI workflows, husky, lint-staged and commitlint config | Upstream | A shared way of working. Changing it in one project makes it drift from the rest. |
| Your feature needs something the core doesn't offer, such as a new seam for modules to plug into | Upstream, with a local core change until it lands | Modules don't edit core files; missing seams belong in the kit. |

Why upstream matters: a fix that never returns to the kit is missing from every new project, so someone finds the same bug again. And the same bug fixed differently in several projects leaves copies of the core that can no longer be compared with the kit or with each other.

> [!TIP]
>
> Commit a kit fix in your project as a **separate commit** containing only that fix. It is then easy to move upstream. This doesn't apply to core changes that belong to your feature, like its `projectModules` entry and the regenerated files; those go in with the feature.

### Sending a fix upstream

The kit and your project share the same directory layout, so file paths match.

**1. Branch in a clone of the kit**

```bash theme={null}
git clone https://github.com/webamigos/gatojs.git
cd gatojs
git switch -c fix/<topic>
```

**2. Move the change as a patch**

In your project, export the fix commit:

```bash theme={null}
git diff <commit>~1 <commit> -- <kit file paths> > ~/fix.patch
```

In the kit clone, check and apply it:

```bash theme={null}
git apply --check ~/fix.patch
git apply ~/fix.patch
```

If `--check` fails because the kit changed around those lines, try `git apply -3 ~/fix.patch` for a three-way merge, or port the change by hand.

**3. Add a test that fails without the fix**

Every bug fix needs one. If you wrote it in your project, bring it along.

**4. Run the gates**

`npm run verify`, plus integration and e2e tests when you touched a query, command or the sign-in flow. For files on the `critical` list in `mutation-gate.json`, also run `npm run test:mutation:task -- <files>` and `npm run test:mutation:gate`. See [Testing](https://docs.gatojs.com/guides/testing.md).

**5. Open a pull request**

Use a [conventional commit](#commits) message. The contribution process is described in [Contributing](https://docs.gatojs.com/contributing/overview.md).

Once merged, the fix reaches other projects through the next kit release and `npx gato update`.

## Where a change is checked

```mermaid theme={null}
flowchart LR
    edit["Edit<br/>(Claude Code hooks)"] --> commit["git commit<br/>(lint-staged, commitlint)"]
    commit --> verify["npm run verify<br/>before handing in"]
    verify --> pr["Pull request<br/>(CI workflows)"]
    pr --> human["Human review<br/>and merge"]
```

| Checkpoint | What runs | What it stops | What it misses |
| - | - | - | - |
| An agent edits a file in Claude Code | The `block-comments` and `protect-tests` hooks | New code comments; test edits during the implementation phase | Shell writes, other tools, your editor |
| `git commit` | husky: lint-staged and commitlint | ESLint errors `--fix` can't repair; non-conventional messages | Files outside the commit; `--no-verify` skips both |
| Before handing in work | `npm run verify` | Lint, type, unit test, build, workspace package and hook test failures | Integration, e2e and mutation tests; stale generated files |
| Pull request and push to `main` | CI workflows | Everything `verify` checks, plus stale generated files, integration and e2e tests, leaked secrets | Commit messages and Prettier formatting |
| Review | A human | Rules no tool enforces | — |

The first three can be bypassed, so CI is the last automatic checkpoint, and reviewers also check the rules that only hooks enforce. See [Built for AI agents](https://docs.gatojs.com/guides/ai-agents.md) for the hooks and [CI](https://docs.gatojs.com/deployment/ci.md) for the workflows.

## Commits

Commit messages follow [Conventional Commits](https://www.conventionalcommits.org) with a lowercase subject. One format lets you filter history by kind of change, for example `git log --oneline --grep '^fix'`.

The first line is `type(scope): subject`:

* **Type** is one of `build`, `chore`, `ci`, `docs`, `feat`, `fix`, `perf`, `refactor`, `revert`, `style`, `test` (from `@commitlint/config-conventional`).
* **Scope** is optional, usually a feature or area: `auth`, `users`, `organizations`, `notes`, `i18n`, `prisma`.
* **Subject** starts lowercase and has no trailing period. Identifiers keep their spelling.

Examples: `feat(organizations): let superadmin enter any organization`, `fix(cli): keep line endings and reject marker tokens in region bodies`, `refactor: rename BETTER_AUTH_URL to APP_URL`.

| commitlint rule | Checks | Rejected example |
| - | - | - |
| `type-enum`, `type-case`, `type-empty` | Type is present, lowercase and from the list. | `feature: add x`, `Feat: add x` |
| `subject-case` | Subject is not sentence case, start case, PascalCase or upper case. | `feat: Add notes`, `feat: ADD NOTES` |
| `subject-empty`, `subject-full-stop` | Subject is present, no trailing period. | `feat: add x.` |
| `header-max-length` | First line is at most 100 characters. | — |
| `body-max-line-length`, `footer-max-line-length` | Body and footer lines are at most 100 characters. | — |

A rejected message aborts the commit:

```text theme={null}
⧗   input: feat: Add notes
✖   subject must not be sentence-case, start-case, pascal-case, upper-case [subject-case]
```

Check a message before committing:

```bash theme={null}
echo "feat(notes): organization notes" | npx --no -- commitlint
```

### What happens on `git commit`

`npm install` runs the `prepare` script (`husky`), which points git at the hooks in `.husky/`:

| Git hook | Runs | Does |
| - | - | - |
| `pre-commit` | `lint-staged` | Runs `eslint --fix` on staged JS/TS files and `prettier --write` on staged JSON, JS, TS and HTML files. Fixes are included in the commit; an unfixable ESLint error aborts it. |
| `commit-msg` | `npx --no -- commitlint --edit $1` | Checks the message. |

lint-staged only touches staged files. ESLint and Prettier skip generated files, so a commit never reformats them.

> [!WARNING]
>
> `git commit --no-verify` and `HUSKY=0` skip the hooks. CI runs neither commitlint nor Prettier, so a commit made that way leaves an unchecked message and unformatted code in history. Don't skip them.

## The `npm run verify` gate

Run `npm run verify` before you hand in work: before a push, a pull request or an agent's final report. The CI `verify` job runs the same script, so anything you miss locally stops the pull request anyway.

```json package.json theme={null}
"verify": "npm run lint && npm run typecheck && npm test && npm run build && turbo run test typecheck lint && npm run test:hooks"
```

| Step | Checks |
| - | - |
| `npm run lint` | ESLint rules. |
| `npm run typecheck` | `tsc --noEmit`. |
| `npm test` | Unit and component tests, including the [architecture tests](https://docs.gatojs.com/guides/ai-agents.md#architecture-tests-keep-the-instructions-honest). |
| `npm run build` | The production build. |
| `turbo run test typecheck lint` | Scripts of workspace packages in `packages/*`, if any. |
| `npm run test:hooks` | The Claude Code hook tests. |

Steps are chained with `&&`, so the first failure stops the run. `verify` does not run integration, e2e or mutation tests, and does not check that generated files are current. The CI job runs the generator first and fails on any diff, so do the same locally:

```bash theme={null}
npx gato generate
npm run verify
```

## Generated files

The generator writes the places through which the core learns about modules. **Never edit them by hand:**

* `src/modules.generated.ts` and `src/modules.client.generated.ts`: the module registry;
* `src/i18n/locales.generated.ts`: the locale list from `locales` in `.wa/kit.json`;
* the `wa:relations` region in `prisma/schema/auth.prisma` and `prisma/schema/organizations.prisma`;
* the `wa:modules` region in `.env.example`;
* the `wa:services` region in `docker-compose.yml`;
* the `wa:ci-integration` region in `.github/workflows/ci.yml` and `.github/workflows/mutation.yml`.

Generated files start with a header line:

```ts src/modules.generated.ts theme={null}
// generated by wa — nie edytuj. Uruchom: npm run wa -- generate
```

("generated by wa — do not edit. Run: `npm run wa -- generate`.") A region is the part of a file between marker lines:

```prisma prisma/schema/organizations.prisma theme={null}
model Organization {
  // …
  members     Member[]
  invitations Invitation[]

  // wa:relations:start
  apiKeys ApiKey[]
  auditLogs AuditLog[]
  uploads Upload[]
  // wa:relations:end

  @@map("organizations")
}
```

Why not by hand:

* The generator rewrites these places on every run from `.wa/kit.json`, the files in feature folders and the files referenced by `compose` and `ciSteps`. A manual edit disappears on the next run.
* CI runs the generator and `git diff --exit-code`. A manual edit, or adding a file the generator tracks without rerunning it, fails the job.
* No hook blocks these edits; CI is what catches them.

Run the generator after:

* any change to `.wa/kit.json`;
* adding or removing a `module.ts`, `env.ts`, `auth.ts`, `auth-client.ts`, `audit-sink.ts` or `i18n/<locale>.json` in a feature;
* adding, removing or renaming a feature folder;
* changing a file referenced by a manifest's `compose` or `ciSteps`.

Editing the content of `module.ts`, adding a key to an existing translation file, or adding a command, query, component or page doesn't need it: the registry imports files rather than copying them.

```bash theme={null}
npx gato generate
```

The output is `Bez zmian` ("no changes") or one `zmieniono <file>` ("changed") line per file written. Commit the regenerated files with the change that caused them. `npm run wa -- generate` runs the same command from the CLI bundle committed in `.wa/bin/`, which works even before `npm install`. More in [`gato generate`](https://docs.gatojs.com/cli/generate) and [Module registry](https://docs.gatojs.com/concepts/module-registry.md).

The Prisma client in `src/generated/prisma/` is generated too, by `prisma generate` (on `postinstall` and via `npm run db:generate`), and is git-ignored. Regenerate it after schema changes instead of editing it.

## Staying up to date

When the kit releases a new version, update your project with:

```bash theme={null}
npx gato update 0.9.0
```

`gato update` requires a clean git working tree, so commit or stash first. It merges the kit's changes between your current version and the target into your files. Files you haven't modified are updated, files you changed are merged, and where you and the kit changed the same lines it leaves a merge conflict for you to resolve. Some cases are left for you to decide and are listed in its report. It never downgrades. Use `--dry-run` to see the plan first. Details and flags are in [`gato update`](https://docs.gatojs.com/cli/update).

After an update, run the generator, `npm run verify` and your integration tests, and commit the result as its own commit.

> [!NOTE]
>
> The more of the kit's code you change locally, the more conflicts updates bring. Prefer adding code in your own features over editing core files, and send generally useful core changes upstream so they come back to you in the next release.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.