Skip to content
Back to skills

Cli Conventions

ASecurity

Conventions for adding or changing csb CLI commands in bin/create.js. A command that acts on a vault is a thin wrapper over a pnpm script in template/package.json: the vault script owns the behavior, and csb only picks the vaults and runs `pnpm <script>`. Use before adding a csb subcommand, a vault pnpm script, or a vault script. Trigger phrases: /cli-conventions, add a csb command, new CLI command, wrap a pnpm script, add a vault script.

  • 188 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
ai-agentsgonodegit

Works with

  • cli

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned November 30, 2026

npx -y skills add jessepinkman9900/claude-second-brain --skill cli-conventions --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cli Conventions?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cli Conventions
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jessepinkman9900-cli-conventions/badge)](https://www.skillsdirectory.com/skills/jessepinkman9900-cli-conventions)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cli-conventions
description: "Conventions for adding or changing csb CLI commands in bin/create.js. A command that acts on a vault is a thin wrapper over a pnpm script in template/package.json: the vault script owns the behavior, and csb only picks the vaults and runs `pnpm <script>`. Use before adding a csb subcommand, a vault pnpm script, or a vault script. Trigger phrases: /cli-conventions, add a csb command, new CLI command, wrap a pnpm script, add a vault script."
argument-hint: "Optional: the command you're adding (e.g. 'csb setup wrapping qmd:setup')"
---

# CLI conventions

`csb` has two kinds of commands. Decide which one you're adding first.

## Kind 1: vault commands wrap vault pnpm scripts

A command that does something *inside* a brain's vault (lint the wiki, reindex qmd, register collections, …) is a thin wrapper over a pnpm script in the vault:

1. **The behavior lives in the vault.** Write the logic as a script under `template/scripts/<area>/` and register it in `template/package.json` `scripts` (e.g. `"lint:wiki": "node scripts/lint/wiki-lint.js"`). It must work on its own from the vault root with `pnpm <script>`, so users, agents and skills can run it without csb.
2. **csb only picks vaults and runs the script.** In `bin/create.js`:
   - Parse targets with `pickTargets(args, { verb, flags })`. That gives every vault command the same interface: `[<name>…] [--brain <name>] [--path <dir>] [--all]`. With no target, a TTY gets a multi-select of the registered brains with the default preselected; with no TTY it uses the default brain.
   - Resolve pnpm with `vaultPnpm()` (system pnpm 10+, else `mise exec -- pnpm`, the same rule scaffolding uses).
   - Run the script with `runVaultScript(pnpmCmd, dir, "<script>", passthroughArgs)`. It passes `--silent` so pnpm's banner and `ELIFECYCLE` lines don't pollute output, which keeps `--json` parseable. Use `{ silent: false }` only for `pnpm install`.
   - Pass the command's own flags straight through (e.g. `--json`). Don't reimplement script logic in csb.
   - With several targets, print a `── <name>` header per vault, keep going after a failure, and exit non-zero if any target failed. If a script has `--json`, print an array of `{ target, path, exitCode, report }` for several targets.
3. **Older vaults.** Check `vaultHasScript(dir, "<script>")`. If a vault predates the script, either fall back to the copy bundled under `TEMPLATE` (as `csb lint` does, run with `node`, for zero-dependency scripts) or report that the vault needs the script. Never silently skip it.
4. **Zero new dependencies.** Prefer plain Node scripts (`node scripts/...js`) for anything that doesn't need the vault's `node_modules`. Only scripts that need qmd use `tsx` and dependencies; for those, csb runs `pnpm install` first when `node_modules` is missing.

Current vault commands: `csb lint` → `pnpm lint:wiki`, `csb reindex` → `pnpm qmd:reindex`. (`csb qmd` and `csb exec` are generic passthroughs and predate this rule.)

## Kind 2: cross-vault commands live in csb

Commands that manage brains or the machine rather than one vault's contents stay in `bin/create.js` and don't need a vault script: create, `ls`, `use`, `rm`, `path`, `skills`, `git-token`, `doctor`, `upgrade`. They can still use `pickTargets` when they act on several brains.

## Checklist for a new vault command

- [ ] Script in `template/scripts/…` plus an entry in `template/package.json`. Supports `--help`, and `--json` when its output is data.
- [ ] `cmd<Name>` in `bin/create.js` built from `pickTargets`, `vaultPnpm` and `runVaultScript`. Added to `SUBCOMMANDS`, `main()`, the top-level help, and a `printHelp` topic.
- [ ] Tests in `tests/<name>-cli.test.js`. Put a fake `pnpm` on `PATH` that answers `--version` with `10.8.0` and logs `"$PWD $*"`, then assert on the exact `--silent <script>` call. Cover `--path`, `--all`, a missing script, and `--help`.
- [ ] Docs: `docs/pages/cli/<name>.mdx` (frontmatter `description` of 50+ chars), the `docs/pages/cli.mdx` command list, the CLI sidebar in `vocs.config.ts`, and the CLI blocks in `README.md` and `template/README.md`. Then run `pnpm docs:build && pnpm docs:verify` with `BASE_PATH=/claude-second-brain`.
- [ ] `.github/workflows/pack-test.yml`: run the command against the scaffolded vault (or only `--help` when a real run is expensive, as with reindex).
- [ ] If a skill or `template/CLAUDE.md` describes the same job, point it at the pnpm script so agents, skills and csb all run one implementation.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.