Skip to content

CLI Options

Complete reference for all new-branch command-line options.

Usage

bash
npx new-branch [options]
npx new-branch init [--yes]

Also available as git subcommands:

bash
git new-branch [options]
git nb [options]

Subcommands

SubcommandDescription
initLaunch the interactive config wizard to create a .newbranchrc.json file.
init --yesCreate a .newbranchrc.json with sensible defaults (no prompts).

Options

Input Options

OptionTypeDescription
-p, --pattern <pattern>stringBranch name pattern. Takes highest precedence over all config sources.
--use <name>stringUse a named pattern alias defined in configuration.
--type <type>stringBranch type value (e.g., feat, fix, chore).
--title <title>stringTask or feature title.
--id <id>stringTask identifier (e.g., PROJ-123, 456).

Behavior Options

OptionTypeDefaultDescription
-L, --max-length <n>numberMaximum length for the final branch name. Truncates from the end if the name exceeds.
--createbooleanfalseCreate the branch using git switch -c and switch to it.
--no-promptbooleanfalseDisable interactive prompts. Fails if required values are missing.
--quietbooleanfalseSuppress non-essential output. Only prints the branch name.

Didactic Options

OptionTypeDescription
--explainbooleanShow a detailed breakdown of the entire branch pipeline.
--list-transformsbooleanList all available transforms with descriptions.
--print-configbooleanPrint the resolved configuration and its source.

Help

OptionDescription
-h, --helpShow help message.

Examples

Generate a branch name

bash
npx new-branch \
  --pattern "{type}/{title:slugify}-{id}" \
  --type feat \
  --title "Add login" \
  --id PROJ-123
feat/add-login-PROJ-123

Create branch from a named alias

bash
npx new-branch --use hotfix --title "Fix crash" --id PROJ-456 --create
✅ Branch created and switched to: hotfix/fix-crash-PROJ-456

Generate quietly (for scripts)

bash
BRANCH=$(npx new-branch \
  --pattern "{type}/{title:slugify}-{id}" \
  --type feat \
  --title "My task" \
  --id 123 \
  --no-prompt \
  --quiet)

git checkout -b "$BRANCH"

Limit branch name length

bash
npx new-branch \
  --pattern "{type}/{title:slugify}-{id}" \
  --type feat \
  --title "Implement user authentication flow" \
  --id PROJ-123 \
  --max-length 30
feat/implement-user-authentica

Inspect the pipeline

bash
npx new-branch \
  --pattern "{type}/{title:slugify;max:25}-{id}" \
  --type feat \
  --title "Implement user authentication" \
  --id PROJ-789 \
  --explain

Released under the MIT License.