<!-- Generated from the Command Code docs: https://commandcode.ai/docs -->

# Install and share mods

A mod starts as a single file in `~/.commandcode/mods/`. To share it with your team or anyone else, turn it into a **package**: an npm package, a git repo, or a local folder. `cmd mods add` installs a package, and Command Code loads it in every session after that.

## Manage mods from the CLI

```bash
cmd mods add cmd-mod-hi                     # npm package (a bare name means npm)
cmd mods add @team/review-mod@1.2.0         # scoped npm package, pinned to a version
cmd mods add owner/repo@v1                  # GitHub repo (other hosts: git:<host>/…)
cmd mods add ./tools/local-mod              # local folder, used where it is
cmd mods add -g owner/repo                  # install for your user instead of this project
cmd mods list                               # list installed mods (alias: ls)
cmd mods update                             # install anything missing, refresh pinned refs (alias: up)
cmd mods remove owner/repo                  # remove by source (alias: rm)
cmd mods remove fun-stuff                   # or by the name `mods list` prints
cmd mods enable <name>                      # turn a mod on; -g for your user
cmd mods disable <name>                     # turn a mod off; -g for your user
cmd mods open                               # open this project's mods folder; --user for yours
cmd mods inspect ./some-mod                 # show what a mod hooks and reaches, without running it
```

`cmd mods list` prints one line per mod: its name, its scope, and where it comes from. Project mods come first, then user mods, then mods from packages.

```
Mods (2)
  guard · project · .commandcode/mods/guard.ts
  cmd-mod-hi · user · from npm:cmd-mod-hi
```

A mod you dropped in shows its file. A mod from a package shows `from <source>`; its files live under `.registry/`, which you never edit by hand. Built-in mods are not listed. A package source only appears when it needs attention: it is not installed yet, or it installed but added no mods.

**Removing.** `cmd mods remove` takes either a source or a mod name from `cmd mods list`, and removes whatever provides it:

- a dropped-in file or folder is deleted from the mods folder;
- a mod from a package removes that package, and tells you which other mods went with it;
- a `mods.paths` mod has its settings entry removed.

It finds the right scope on its own, so a user mod does not need `-g`. If the source is not installed in either scope, it tells you so.

**Opening the folder.** `cmd mods open` opens `<project>/.commandcode/mods`, or `~/.commandcode/mods` with `--user` (`-g`), and creates it if needed. `--path` prints the folder instead of opening it.

**How sources are read and saved.**

- A source without a slash, or a `@scope/name`, is an npm package, so the `npm:` prefix is optional. A `git:` prefix always means git.
- Sources are saved in the `mods.sources` settings key: `.commandcode/settings.json` for the project, `~/.commandcode/settings.json` with `-g`.
- Versions and refs do not change what a source is: `owner/repo@v1` and `https://github.com/owner/repo` are the same package. A project entry takes priority over the same package at the user level.
- Packages install into `<scope>/.commandcode/mods/.registry/{npm,git}/…`. Startup never runs npm or git by itself. A package that is configured but not installed shows a warning that points at `cmd mods update`.

## Turn a mod into a package

List what the package contains in `package.json`. Entries can be exact paths, folders, or globs, relative to the package root. Entries that point outside the root are ignored.

```json
{
	"name": "@team/review-mod",
	"description": "Blocks risky diffs and adds a /review command.",
	"keywords": ["cmd-mod", "cmd-mod-tool", "cmd-mod-command"],
	"repository": "https://github.com/team/review-mod",
	"commandcode": {
		"mods": ["./src/review.ts", "src/checks/*.ts"],
		"skills": ["./skills"]
	}
}
```

Without `commandcode.mods`, Command Code looks for a `mods/` folder, then a root `index.ts`.

`commandcode.skills` lists skill folders the package ships next to its mods. Each entry is one skill folder or a folder of skills, relative to the package root. They load in every session the package loads in, so one `cmd mods add` brings both the mods and their skills. A mod can add skills from code too, with `cmd.addSkillsPath`.

Add the `cmd-mod` keyword so maintainers can find your package. Kind keywords such as `cmd-mod-tool` and `cmd-mod-hook` describe it further. Publishing to npm does not put your mod on the Command Code mods hub by itself. To list it, see [Listing a mod on the mods hub](#listing-a-mod-on-the-mods-hub).

## Load only some mods from a package

To load part of a package, use the object form of a `mods.sources` entry:

```json
{
	"mods": {
		"sources": [
			{"source": "owner/review-pack", "mods": ["review/*.ts", "!review/slow.ts"]}
		]
	}
}
```

Patterns match a file's path inside the package, or its mod name. There are four kinds, applied in this order:

1. `-path` always excludes that exact path, and beats everything else.
2. `+path` always includes that exact path, even if a glob dropped it.
3. `!glob` excludes matches.
4. A plain glob includes matches. When any includes exist, a mod must match one of them.

`cmd mods add` and `cmd mods remove` keep entries you wrote by hand, filters included.

## Turn a mod on or off

`cmd mods disable <name>` turns a mod off without removing it, and `cmd mods enable <name>` turns it back on. Both write to the project settings (`.commandcode/settings.json`) by default, or to your user settings (`~/.commandcode/settings.json`) with `-g`. The change applies on the next session or after `/reload`.

```bash
cmd mods disable review-guard        # off in this project
cmd mods enable review-guard -g      # on for your user
```

They work for dropped-in files, installed packages, and the built-ins that can be turned off (`provider-copilot`, `update-notice`, `titling`, `learning`, and others). `disable` adds the name to `mods.disabled`. `enable` removes it from there, and for an opt-in built-in such as `todos` it also adds the name to `mods.enabled`:

```json
{"mods": {"disabled": ["review-guard"], "enabled": ["todos"]}}
```

A disable in any settings file wins. Command Code reads the user, project, and project local (`.commandcode/settings.local.json`) settings, and a `mods.disabled` entry in any of them keeps the mod off, even if another file turns it on. So if another file still disables the mod you enable, the command does not report success. It names that file, gives the fix, and exits with code 1 so a script's `&&` chain stops:

```bash
$ cmd mods enable review-guard
⚠ review-guard is still disabled
  Your user settings (~/.commandcode/settings.json) disable it.
  To enable it at the user level, run: cmd mods enable review-guard -g
```

No command writes to `settings.local.json`, so a disable there has to be removed by hand.

**In a project you have not opened yet.** Command Code reads project settings only after it has run in that project, the same rule project mods follow. Enabling or disabling there still saves the setting, and it applies once you start Command Code in the project. Use `-g` to apply it at the user level right away. `cmd mods list --builtin` shows when a built-in will change state, for example `enabled · disabled once you start Command Code here`.

## Trust and safety

- **There is no sandbox.** A mod is code that runs with your permissions, so only install packages you trust.
- **Inspect before you trust.** `cmd mods inspect <path>` reads a mod's source without importing it, and lists the hooks it registers, what it adds, and what it can reach: processes, the network, the filesystem, the environment, permission answers, and transcript rewrites. It only reads the text, so code the mod imports or builds at runtime can reach further, and the report says so.

```bash
$ cmd mods inspect ./permission-policy.ts
files:     1
hooks:     onPermissionRequest
registers: none
reaches:   answers permission prompts (onPermissionRequest)
imports:   none
```

- **Kill switches.** `cmd --safe-mode` loads only built-in mods for one session (no installed mods, no `--mod`). `{"mods": {"disableAll": true}}` in any settings file does the same for every session until you remove it.
- **Project mods need workspace trust**, like project skills. They load only after you accept the workspace trust prompt. User mods and `--mod` mods always load.
- **Packages install with `npm --ignore-scripts`.** Mods are TypeScript loaded directly, so they need no build step, and install scripts would only add risk.
- **Print mode loads only user mods and `--mod` mods.** Print mode never shows a trust prompt, so project mods stay out of headless runs. Pass `--dangerously-skip-permissions` to include a repo's own mods in a headless run, for example in CI.

# Listing a mod on the mods hub

The [Command Code mods hub](https://commandcode.ai/mods) lists the reviewed entries in `mods/registry.json` in the public [`CommandCodeAI/command-code`](https://github.com/CommandCodeAI/command-code) repo. Every mod on the mods hub needs an entry there, whether it is published to npm or lives on GitHub. Publishing a package or adding a keyword does not list it.

To list your mod:

1. Publish it to npm or push it to a public GitHub repo. Check that `package.json` has the right mod entry points, description, and repository.
2. Open a PR that adds one entry to [`mods/registry.json`](https://github.com/CommandCodeAI/command-code/blob/main/mods/registry.json). For an npm mod, set both `source` and `npm` to the full package name, including its scope.
3. Maintainers review the published code. Once the PR is merged, the mods hub picks up the change within about 15 minutes, with no website deploy.

```json
{
	"version": 1,
	"hidden": [],
	"mods": [
		{
			"name": "review-guard",
			"source": "owner/review-guard",
			"description": "Blocks risky diffs and adds a /review command.",
			"author": {"name": "Ada", "github": "ada"},
			"repo": "https://github.com/owner/review-guard",
			"kinds": ["tool", "command"],
			"tags": ["safety", "review"]
		}
	]
}
```

| Field | Required | What it does |
|---|:---:|---|
| `name` | yes | Unique lowercase name the mods hub shows |
| `source` | yes | What `cmd mods add <source>` installs: an npm name or `owner/repo` |
| `description` | yes | The summary on the mods hub card, up to 240 characters |
| `author.name` | yes | Who made it. Add `author.github` to link your profile |
| `kinds` | yes | At least one of `tool`, `command`, `hook`, `provider`, `renderer`, `flag` |
| `repo` | no | A GitHub URL. Adds a live star count |
| `npm` | no | The published npm package. Adds the latest version, publish date, and monthly downloads |
| `tags` | no | Lowercase search tags |
| `addedAt` | no | `YYYY-MM-DD`, used to sort by newest |

`official` marks a mod the Command Code team maintains, and the top level `hidden` list keeps spam or impersonation off the mods hub. Both are set by maintainers only. The full schema is `mods/registry.schema.json`.

The mods hub's list, with live npm data and GitHub star counts, is also served at [`commandcode.ai/mods.json`](https://commandcode.ai/mods.json). It allows requests from any origin, so the CLI or any script can read the same list the mods hub shows.
