> ## 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.

# gato remove

> Remove a kit module from a GatoJS project: checks, what gets deleted, what stays in the database, storage and .env, and which migration to create.

```bash theme={null}
gato remove <module> [--force] [--no-install]
```

`gato remove` deletes a kit module's files (except its seed files), drops the npm dependencies no other module declares, removes the module from `.wa/kit.json` and regenerates the wiring. It needs neither the kit nor the network: everything it uses (files, hashes, manifest, dependencies) is in the project's [`.wa/kit.json`](https://docs.gatojs.com/cli/kit-json).

```bash theme={null}
npx gato remove uploads
npm run wa -- remove api-keys --force --no-install
```

## Options

**module** `string` *required*

Name of an installed kit module.

**--force** `boolean`

Delete the module's files even if you changed them locally. Your changes are lost.

**--no-install** `boolean`

Skip `npm install` at the end.

## Order of checks

Every check runs before anything is deleted.

**1. Read .wa/kit.json**

As in [`gato add`](https://docs.gatojs.com/cli/add#order-of-checks).

**2. Refusals**

* `core`: `Cannot remove core`.
* A project module: `Module <x> belongs to the project; remove only handles kit modules. Delete its files and its projectModules entry by hand`.
* Not installed: `Module <x> is not installed`.
* Required by another kit module or a project module: `Module <x> is required by: <list>`.

**3. Paths outside the project**

Any recorded file path that, after resolving symlinks, points outside the project gives `Path outside the project: <path>`.

**4. Changed files**

The CLI hashes every existing module file and compares it with the hash in `.wa/kit.json`. If any differs, the command stops without `--force` and lists them. A file that no longer exists does not block the command.

**5. package.json**

Must parse as JSON, otherwise a raw parser error stops the command before deleting files.

```text theme={null}
$ npx gato remove api-keys --no-install
Changed files in module api-keys (use --force):
  src/features/api-keys/i18n/pl.json
  src/features/api-keys/services/api-scopes.ts
```

Move changes you want to keep, for example into a project feature, before you pass `--force`.

## What it deletes

1. The module's recorded files, except seed files, and the empty directories above them, up to the first non-empty one. Directory cleanup does not follow symlinks and never removes the project root. A module file that is itself a symlink is removed as a link; its target stays.
2. From `package.json`, the module's dependencies that no remaining kit module or project module declares **in the same section**. This applies even if the project had the dependency before `add` or changed its version.
3. The module's entry in `.wa/kit.json`. Then [`gato generate`](https://docs.gatojs.com/cli/generate) clears the module from the registry and the `wa:*` regions.
4. `npm install` (unless `--no-install`). Then, when the module had seed files that still exist, the list of them, and the hint `npx prisma migrate dev --name remove-<module>`.

### Seed files stay

Seed files (recorded as `seed` in `.wa/kit.json`) belong to the project, so `gato remove` never deletes them. Since `gato-cli` 0.16.0 it lists the ones it left behind:

```text theme={null}
$ npx gato remove legal --no-install
Kept seed files of legal (yours, edit or delete them):
  src/features/legal/content/index.ts
  src/features/legal/content/privacy.en.tsx
  src/features/legal/content/privacy.pl.tsx
  src/features/legal/content/terms.en.tsx
  src/features/legal/content/terms.pl.tsx
  src/features/legal/legal.config.ts
npx prisma migrate dev --name remove-legal
```

Delete them yourself when you no longer need them. A seed file of a kit module, as shipped, imports nothing from the module, so the project still compiles with them in place. If you added an import of a module file to a seed file, remove that import or delete the seed file. The changed-files check skips seed files, so editing them does not require `--force`.

`gato add api-keys` followed by `gato remove api-keys` leaves the project byte for byte as it was before `add`, unless `package.json` already had one of the module's dependencies: the rule above removes it too. For a module with seed files, such as `legal`, the seed files stay.

## What stays, and which migration to create

`gato remove` changes project files only. It does not touch the database, file storage or `.env`.

| What | After `gato remove` | What to do |
| - | - | - |
| The module's tables (`audit_logs`, `api_keys`, `uploads`) and their data | Stay until you apply a migration. The schema no longer describes them and the app no longer uses them. | Back up the data if you need it. Then `npx prisma migrate dev --name remove-<module>`: the generated migration drops the tables with their data. Commit it; production applies it with `npx prisma migrate deploy`. |
| Stored files (`uploads`) | Stay: in `STORAGE_LOCAL_PATH` with `local`, in the bucket with `s3`. Dropping the `uploads` table loses the list of keys. | Export the keys from the `uploads` table before the migration, then delete the directory or empty the bucket. |
| Local MinIO data (`volumes/minio`) | Stays on disk. The `minio` services disappear from `docker-compose.yml`, but a running container keeps running as an orphan. | `docker compose up -d --remove-orphans`, then delete the directory if you do not need the data. |
| The module's entry in [`src/gato.config.ts`](https://docs.gatojs.com/configuration/project-configuration) | Stays. The next build, dev run or test fails with `unknown module: <module>`. | Delete the entry under `modules`. |
| Module variables in `.env` (`API_KEY_PEPPER`, `STORAGE_*`, `S3_*`) | Stay in `.env`; they are removed only from `.env.example`. Harmless. | Remove them from `.env` and from production settings. |
| npm dependencies | Removed by the rule above, even ones your own code uses if no manifest declares them. | Declare a dependency you use in a [project module](https://docs.gatojs.com/cli/kit-json.md#project-modules) manifest, in the same section as the kit module. |
| Your code that imports module files | Stays. `remove` does not look for imports, so build and typecheck fail. | Remove the imports, or move the code you need into the project before `remove`. |
| `node_modules` | With `--no-install`, still holds the removed packages. | `npm install`. |

## Rollback and its limits

`gato remove` has no rollback. "All or nothing" applies to the checks: a failed check changes nothing. A failure while deleting (for example a permission error) leaves a partial state: some files gone, the module still in `.wa/kit.json`. Fix the cause and run `gato remove` again; missing files do not block it.

A failed `npm install` at the end gives `Module removed, but npm install failed. Run: npm install`. The module is already gone from the state and the disk.

## Safety

* `gato remove` trusts `.wa/kit.json`: it deletes every recorded file whose hash matches, and with `--force` every recorded file. Review a `.wa/kit.json` from an untrusted source (someone else's pull request, an archive) before running it.
* It only deletes files inside the project after resolving symlinks.
* It is not safe against another process changing the project directory at the same time; there is no lock between check and delete.


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