Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration

workspace-utils is designed to work with zero configuration by default. It automatically detects your workspace setup and package manager, then runs with sensible defaults. However, you can customize behavior through command-line options.

No Configuration Files

Unlike many other tools, workspace-utils does not use configuration files. All behavior is controlled through:

  1. Command-line flags (primary method)
  2. Workspace structure (automatic detection)
  3. Package manager detection (automatic)

This approach keeps things simple and ensures your commands are explicit and reproducible.

Command-Line Configuration

All configuration is done through command-line options. Here are the most commonly used options:

Global Options

Available for all commands:

OptionDescriptionDefaultExample
--filter <pattern>Filter packages by glob patternAll packages--filter "@scope/*"
--concurrency <number>Max concurrent processes4--concurrency 8
--helpShow command help---help

Command-Specific Options

run command

workspace-utils run <script> [options]
OptionDescriptionDefault
--sequentialRun sequentially instead of parallelfalse

build command

workspace-utils build [options]
OptionDescriptionDefault
--skip-unchangedSkip unchanged packages (future)false

dev command

workspace-utils dev [options]

No additional options - uses global options only.

Environment Variables

workspace-utils respects these environment variables:

VariableDescriptionDefault
NODE_ENVNode environmentdevelopment
FORCE_COLORForce colored output1 (enabled)

Package Manager Detection

workspace-utils automatically detects your package manager based on lock files and configuration:

Detection Priority

  1. Bun - if bun.lockb exists or bun-specific fields in package.json
  2. pnpm - if pnpm-lock.yaml or pnpm-workspace.yaml exists
  3. npm - if package-lock.json exists

Workspace Configuration

The tool reads workspace configuration from:

Package ManagerConfiguration Source
Bunpackage.jsonworkspaces field
pnpmpnpm-workspace.yamlpackages field
npmpackage.jsonworkspaces field

Workspace Structure Requirements

Supported Workspace Formats

Bun Workspaces

{
	"name": "my-monorepo",
	"workspaces": ["packages/*", "apps/*"]
}

pnpm Workspaces

# pnpm-workspace.yaml
packages:
  - 'packages/*'
  - 'apps/*'
  - '!**/test/**'

npm Workspaces

{
	"name": "my-monorepo",
	"workspaces": {
		"packages": ["packages/*", "apps/*"]
	}
}

Common Configuration Patterns

Package.json Scripts

Add workspace-utils commands to your root package.json:

{
	"scripts": {
		"test": "workspace-utils run test",
		"test:sequential": "workspace-utils run test --sequential",
		"build": "workspace-utils build",
		"build:apps": "workspace-utils build --filter 'apps/*'",
		"dev": "workspace-utils dev",
		"lint": "workspace-utils run lint --concurrency 8",
		"typecheck": "workspace-utils run typecheck --parallel"
	}
}

CI/CD Configuration

Optimize for continuous integration:

# Lower concurrency for CI resources
workspace-utils run test --concurrency 2

# Sequential builds for predictable resource usage
workspace-utils build --concurrency 1

# Parallel linting for speed
workspace-utils run lint --concurrency 4

Development Workflow

Optimize for local development:

# Start all dev servers
workspace-utils dev

# Run tests with higher concurrency on powerful dev machines
workspace-utils run test --concurrency 8

# Filter to work on specific features
workspace-utils dev --filter "*frontend*"

Performance Tuning

Concurrency Guidelines

Task TypeRecommended ConcurrencyReasoning
Tests4-8Usually I/O bound, can run many
Builds2-4CPU intensive, fewer parallel
Linting6-12Fast, lightweight processes
Dev servers2-6Resource intensive, long-running

System Resources

Consider your system when setting concurrency:

# For 4-core machines
workspace-utils run build --concurrency 2

# For 8+ core machines
workspace-utils run test --concurrency 8

# For CI with limited resources
workspace-utils run lint --concurrency 2

Filtering Patterns

Glob Patterns

workspace-utils supports standard glob patterns:

PatternMatchesExample
@scope/*All packages in scope@company/utils, @company/ui
apps/*All packages in apps directoryapps/web, apps/mobile
*-utilsPackages ending with -utilsdate-utils, string-utils
*frontend*Packages containing frontendmy-frontend-app, frontend-utils

Multiple Filters

Use multiple invocations for complex filtering:

# Run tests on backend packages only
workspace-utils run test --filter "@company/backend-*"

# Build all apps and shared libraries
workspace-utils build --filter "apps/*"
workspace-utils build --filter "@company/shared-*"

Error Handling Configuration

Exit Behavior

workspace-utils has different exit behaviors by command:

CommandFailure Behavior
run (parallel)Continue other packages, exit 1 if any failed
run (sequential)Stop on first failure, exit with that code
buildStop current batch on failure, skip remaining
devStop all servers on any failure

Error Codes

Exit CodeMeaning
0All operations successful
1One or more package operations failed
2Configuration or workspace detection error

Next Steps