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:
- Command-line flags (primary method)
- Workspace structure (automatic detection)
- 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:
| Option | Description | Default | Example |
|---|---|---|---|
--filter <pattern> | Filter packages by glob pattern | All packages | --filter "@scope/*" |
--concurrency <number> | Max concurrent processes | 4 | --concurrency 8 |
--help | Show command help | - | --help |
Command-Specific Options
run command
workspace-utils run <script> [options]
| Option | Description | Default |
|---|---|---|
--sequential | Run sequentially instead of parallel | false |
build command
workspace-utils build [options]
| Option | Description | Default |
|---|---|---|
--no-skip-unchanged | Disable caching, build all packages | (caching enabled) |
cache command
workspace-utils cache [command]
| Command | Description | Default |
|---|---|---|
status | Show cache statistics and cached packages | ✓ |
clear | Clear all cached build data |
dev command
workspace-utils dev [options]
No additional options - uses global options only.
Environment Variables
workspace-utils respects these environment variables:
| Variable | Description | Default |
|---|---|---|
NODE_ENV | Node environment | development |
FORCE_COLOR | Force colored output | 1 (enabled) |
Package Manager Detection
workspace-utils automatically detects your package manager based on lock files and configuration:
Detection Priority
- Bun - if
bun.lockbexists or bun-specific fields inpackage.json - pnpm - if
pnpm-lock.yamlorpnpm-workspace.yamlexists - npm - if
package-lock.jsonexists
Workspace Configuration
The tool reads workspace configuration from:
| Package Manager | Configuration Source |
|---|---|
| Bun | package.json → workspaces field |
| pnpm | pnpm-workspace.yaml → packages field |
| npm | package.json → workspaces 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/*'",
"build:all": "workspace-utils build --no-skip-unchanged",
"dev": "workspace-utils dev",
"lint": "workspace-utils run lint --concurrency 8",
"typecheck": "workspace-utils run typecheck --parallel",
"cache:clear": "workspace-utils cache clear"
}
}
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 Type | Recommended Concurrency | Reasoning |
|---|---|---|
| Tests | 4-8 | Usually I/O bound, can run many |
| Builds | 2-4 | CPU intensive, fewer parallel |
| Linting | 6-12 | Fast, lightweight processes |
| Dev servers | 2-6 | Resource 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
Build Caching
The build command includes intelligent caching to skip unchanged packages:
How Caching Works
- Content hashing - SHA256 hashes of source files and
package.json - Git-aware - Only tracks files not ignored by
.gitignore - Dependency tracking - Cache invalidated when dependencies change
- Automatic management - Cache stored in
.wsu/(auto-added to.gitignore)
Cache Configuration
Caching is enabled by default. Control it with:
# Build with caching (default) - skips unchanged packages
workspace-utils build
# Build all packages (disable caching)
workspace-utils build --no-skip-unchanged
Cache Management Commands
# View cache status and statistics
workspace-utils cache
# Clear all cached builds
workspace-utils cache clear
When to Disable Caching
- Clean builds - When you want to ensure everything rebuilds
- CI/CD - Some pipelines prefer full builds for consistency
- Debugging - When investigating build issues
CI/CD Caching Strategy
# For CI with caching (faster incremental builds)
workspace-utils build
# For release builds (full rebuild)
workspace-utils build --no-skip-unchanged
Filtering Patterns
Glob Patterns
workspace-utils supports standard glob patterns:
| Pattern | Matches | Example |
|---|---|---|
@scope/* | All packages in scope | @company/utils, @company/ui |
apps/* | All packages in apps directory | apps/web, apps/mobile |
*-utils | Packages ending with -utils | date-utils, string-utils |
*frontend* | Packages containing frontend | my-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:
| Command | Failure Behavior |
|---|---|
run (parallel) | Continue other packages, exit 1 if any failed |
run (sequential) | Stop on first failure, exit with that code |
build | Stop current batch on failure, skip remaining |
dev | Stop all servers on any failure |
Error Codes
| Exit Code | Meaning |
|---|---|
0 | All operations successful |
1 | One or more package operations failed |
2 | Configuration or workspace detection error |
Next Steps
- Learn about Workspace Detection
- Explore Package Manager Support
- See Performance Tuning for optimization tips