# csb upgrade

Update existing brains to the release of `csb` you have installed.

## Usage

```bash
csb upgrade [<name>…] [--all] [--dry-run] [-y|--yes] [--force]
```

A brain is a copy of the template from the release that created it. New releases change the schema (`CLAUDE.md`), the skills and the qmd scripts, but [`csb skills`](https://jessepinkman9900.github.io/claude-second-brain/cli/skills) only updates the global skills. `csb upgrade` updates the rest, shows you the plan first, and asks before it writes.

```bash
npm i -g claude-second-brain@latest
csb upgrade --dry-run   # see what would change
csb upgrade             # apply it (asks first)
```

## What it changes

* **Template files**: `CLAUDE.md`, `AGENTS.md`, every skill in `.claude/skills/`, the vault-local skills in other agents' folders already in the vault (`.agents/skills/`, `.windsurf/skills/`, …), everything in `scripts/`, `package.json`, `pnpm-workspace.yaml` (pnpm's native-build allowlist) and `mise.toml`. Files new in a release, such as a new script, are added.
* **`.gitignore`**: lines the template has and yours doesn't are appended. Nothing is removed.
* **Git index**: if git still tracks the qmd index (`.qmd/`, `qmd.sqlite*`) or the per-device Obsidian files (`.obsidian/workspace.json`, `workspace-mobile.json`), they are removed from git with `git rm --cached`. The files stay on disk.
* **Global skills**: `brain-ingest`, `brain-search` and `brain-refresh` in `~/.agents/skills` are updated if they're from another release, and re-linked for the agents that already have them.

It never touches `wiki/`, `raw-sources/`, `README.md` or the rest of `.obsidian/`, and it doesn't commit. Review the changes with `git status`, then commit them, or let obsidian-git commit them on its next sync. If `package.json` or `pnpm-workspace.yaml` changed, run `csb exec -- pnpm install`.

## Your edits are kept

The plan marks each file:

| Mark | Meaning |
|---|---|
| `~` | Unchanged since `csb` wrote it. Replaced with the new version. |
| `+` | New in this release. Added. |
| `!` | You edited it. Kept, unless you choose the new version. |
| `-` | You deleted it. Left deleted. |
| `=` | You kept your edits on an earlier run of this release. Not asked again. |

To tell your edits apart from old template files, `csb` records what it shipped for each file in `.csb/manifest.json` inside the brain. Commit it with the vault so every device agrees. Brains created before this file existed are compared with the content git recorded when the file was first added, usually the scaffold's initial commit.

In a terminal, `csb upgrade` asks about each file you edited: keep yours, take the new version, or show the diff first. Your old version stays in git history either way.

## Arguments

### name

`string`

Brains to upgrade. Defaults to the default brain. Also accepted as `--brain <name>`.

```bash
csb upgrade work personal
```

## Options

### --all

`boolean`

Upgrade every registered brain.

```bash
csb upgrade --all
```

### -n, --dry-run

`boolean`

Show the plan and exit without changing anything.

```bash
csb upgrade --all --dry-run
```

### -y, --yes

`boolean`

Apply without asking. Files you edited are kept. Without a terminal (CI, scripts), `csb upgrade` only shows the plan unless you pass `--yes`.

```bash
csb upgrade --yes
```

### --force

`boolean`

Also replace files you edited with the new version, and upgrade a brain that a newer `csb` already upgraded. Without it, that brain is skipped so an older `csb` can't downgrade it.

```bash
csb upgrade --force
```

### -h, --help

Displays help message.

```bash
csb upgrade --help
```

## Exit status

Exits 1 when a brain is skipped: its folder is missing, or a newer `csb` upgraded it. Pressing Ctrl-C at any prompt stops the upgrade there and exits 130; brains not yet reached are left as they were.
