Skip to content

CLI Reference ​

Installation ​

Srcpack runs without global install:

sh
npx srcpack [command] [options]
sh
bunx srcpack [command] [options]
sh
pnpm dlx srcpack [command] [options]
sh
yarn dlx srcpack [command] [options]

Or install as a dev dependency:

sh
npm install -D srcpack
sh
bun add -D srcpack
sh
pnpm add -D srcpack
sh
yarn add -D srcpack

Commands ​

srcpack (default) ​

Build configured bundles except those marked onDemand, and upload their text files if configured.

sh
npx srcpack
sh
bunx srcpack
sh
pnpm dlx srcpack
sh
yarn dlx srcpack

With specific bundles:

sh
npx srcpack web api
sh
bunx srcpack web api
sh
pnpm dlx srcpack web api
sh
yarn dlx srcpack web api

Naming a bundle builds it even when it is marked onDemand; a full run skips those and lists them after the summary.

Changed files only:

sh
npx srcpack --staged          # staged changes
npx srcpack --dirty           # staged + unstaged + untracked
npx srcpack --since main      # everything you changed since main

These build a one-off bundle from the current change set and need no config file — handy for handing a work-in-progress to an LLM. The bundle is named after the flag (.srcpack/staged.txt), other bundles in outDir are left alone unless you pass --emptyOutDir, and nothing is written when there are no changes.

Ad-hoc bundles stay local: they are never uploaded, even with Google Drive configured. Declare a named bundle to publish changes.

One-off flags use the discovered config's root and outDir, but replace the source definition of any configured bundle with the same name. For example, --screenshot replaces the images of a configured bundle named screenshot. Output collisions with differently named bundles are rejected.

For a permanent version with review instructions attached, put a git source in your config instead.

A page, as images:

sh
npx srcpack --screenshot localhost:5173/pricing
npx srcpack --screenshot localhost:5173 --viewport mobile

Captures the page as numbered PNGs in outDir (by default .srcpack/screenshot-00.png, screenshot-01.png, …), with detail slices for tall pages. No config file is required. A URL without a scheme gets http://. Like the change-set flags, it leaves other files in outDir alone unless you pass --emptyOutDir, and never uploads. It needs Playwright — see Screenshots, which also covers declaring a page you capture repeatedly.

srcpack init ​

Create a srcpack.config.ts interactively.

sh
npx srcpack init
sh
bunx srcpack init
sh
pnpm dlx srcpack init
sh
yarn dlx srcpack init

Detects your project structure and suggests bundle configurations.

srcpack login ​

Authenticate with Google Drive for uploads.

sh
npx srcpack login
sh
bunx srcpack login
sh
pnpm dlx srcpack login
sh
yarn dlx srcpack login

Opens a browser to authorize access. Tokens are stored in ~/.config/srcpack/credentials.json, readable only by you.

Options ​

OptionDescription
--stagedBundle staged changes only
--dirtyBundle staged, unstaged, and untracked changes
--since <rev>Bundle changes since <rev>
--screenshot <url>Capture a page as numbered PNGs
--viewport <name>desktop (default) or mobile, with --screenshot
--dry-runPreview bundles without writing files
--emptyOutDirEmpty the output directory before writing
--no-emptyOutDirSkip clearing the output directory
--no-uploadBundle only, skip upload
-h, --helpShow help
-v, --versionShow version

--no-emptyOutDir disables directory-wide clearing; bundles still replace their outputs and remove stale files from their own previous output. See output cleanup.

The one-off flags (--staged, --dirty, --since, --screenshot) cannot be combined with each other or with bundle names. --viewport applies only to --screenshot; set the viewport in config for a named bundle.

An unrecognized option is an error, not a no-op — --no-uplaod would otherwise upload, and --dry-rnu would write. Values may follow a space or an =: --since main and --since=main are the same.

Examples ​

Preview without writing ​

sh
npx srcpack --dry-run
sh
bunx srcpack --dry-run
sh
pnpm dlx srcpack --dry-run
sh
yarn dlx srcpack --dry-run

Output:

  web   3 files  842 lines
    src/api/routes.ts
    src/index.ts
    src/utils/helpers.ts
  docs  1 file   96 lines
    README.md

Dry run: 2 bundles, 4 files, 938 lines

Each bundle lists the files it would contain, so you can check the shape of a pattern before anything is written; outDir is left alone too. A bundle that declares linear still calls the API — the counts are what it would produce right now, which it can't know offline. A screenshot source is listed with its URL, viewport and destination without launching a browser. A mixed bundle still resolves its text sources.

Bundle without upload ​

sh
npx srcpack --no-upload
sh
bunx srcpack --no-upload
sh
pnpm dlx srcpack --no-upload
sh
yarn dlx srcpack --no-upload

Exit Codes ​

CodeMeaning
0Success
1Error (config, IO, etc)

Config File Locations ​

Srcpack searches for config in order:

  1. srcpack.config.ts
  2. srcpack.config.mts
  3. srcpack.config.js
  4. srcpack field in package.json

Searches from current directory up to filesystem root.

srcpack init writes .ts in an ESM project and .mts otherwise — see Configuration.