Validate Bun workspace configuration and detect common monorepo issues. Ensures proper workspace setup, dependency catalogs, isolated installs, and Bun 1.3+ best practices.
Resources
2Install
npx skillscat add shipshitdev/library/bun-validator Install via the SkillsCat registry.
Bun Validator
Validates Bun workspace configuration and prevents common monorepo issues. Ensures Bun 1.3+ patterns and proper workspace isolation.
When This Activates
- Setting up a new Bun monorepo
- Before adding dependencies to workspaces
- Auditing existing Bun workspaces
- After AI generates package.json files
- CI/CD pipeline validation
Quick Start
python3 ~/.claude/skills/bun-validator/scripts/validate.py --root .
python3 ~/.claude/skills/bun-validator/scripts/validate.py --root . --strictWhat Gets Checked
1. Bun Version
# GOOD: v1.3+
bun --version # 1.3.0 or higher
# BAD: v1.2 or earlier
bun --version # 1.2.x2. Root package.json
GOOD - Monorepo root:
{
"name": "my-monorepo",
"private": true,
"workspaces": ["apps/*", "packages/*"]
}BAD - Dependencies in root:
{
"workspaces": ["apps/*"],
"dependencies": {
"react": "^19.0.0" // BAD: Don't put deps in root
}
}3. Workspace Structure
GOOD:
my-monorepo/
โโโ package.json # Root with workspaces, private: true
โโโ bun.lockb # Single lockfile at root
โโโ apps/
โ โโโ web/
โ โ โโโ package.json # Own dependencies
โ โโโ api/
โ โโโ package.json # Own dependencies
โโโ packages/
โโโ ui/
โ โโโ package.json # Shared package
โโโ config/
โโโ package.json # Shared configBAD:
my-monorepo/
โโโ package.json
โโโ apps/
โ โโโ web/
โ โโโ package.json
โ โโโ bun.lockb # BAD: Lockfile in workspace4. Workspace Dependencies
GOOD - Using workspace protocol:
{
"dependencies": {
"@myorg/ui": "workspace:*",
"@myorg/config": "workspace:^1.0.0"
}
}BAD - Hardcoded versions:
{
"dependencies": {
"@myorg/ui": "1.0.0" // BAD: Use workspace:*
}
}5. Dependency Catalogs (Bun 1.3+)
GOOD - Centralized versions:
// Root package.json
{
"catalog": {
"react": "^19.0.0",
"typescript": "^5.7.0",
"@types/node": "^22.0.0"
}
}// apps/web/package.json
{
"dependencies": {
"react": "catalog:" // Uses version from catalog
}
}6. Isolated Installs
GOOD - Default in Bun 1.3:
Packages can only access dependencies they explicitly declare.
BAD - Hoisted dependencies:
// Don't disable isolation
{
"workspaces": {
"packages": ["apps/*"],
"nohoist": ["**"] // Don't do this
}
}Bun 1.3+ Features
Dependency Catalogs
Centralize version management:
// Root package.json
{
"catalog": {
"react": "^19.0.0",
"next": "^16.0.0",
"typescript": "^5.7.0"
}
}Interactive Updates
bun update --interactive # Selectively update depsDependency Chains
bun why react # Explain why a package is installedWorkspace Commands
# Install in specific workspace
bun add express --cwd apps/api
# Run script in workspace
bun run --cwd apps/web dev
# Run in all workspaces
bun run --filter '*' buildCommon Issues
Issue: "Cannot find module"
Cause: Dependency not declared in workspace package.json
Fix:
bun add <package> --cwd <workspace>Issue: Multiple lockfiles
Cause: Running bun install in workspace directory
Fix:
rm apps/*/bun.lockb packages/*/bun.lockb
bun install # From root onlyIssue: Version conflicts
Cause: Same package with different versions across workspaces
Fix: Use dependency catalogs:
{
"catalog": {
"problematic-package": "^1.0.0"
}
}Validation Output
=== Bun Workspace Validation Report ===
Bun Version: 1.3.2 โ
Root package.json:
โ private: true
โ workspaces defined
โ Found dependencies in root (should be empty)
Workspace Structure:
โ apps/web - valid workspace
โ apps/api - valid workspace
โ packages/ui - valid workspace
โ apps/web/bun.lockb - lockfile should only be at root
Dependencies:
โ Using workspace:* protocol
โ @myorg/ui uses hardcoded version "1.0.0"
Catalogs:
โ No dependency catalog found (recommended for Bun 1.3+)
Summary: 3 issues foundBest Practices
1. Always use workspace protocol
"@myorg/shared": "workspace:*"2. Use --cwd for workspace operations
bun add lodash --cwd apps/web # NOT: cd apps/web && bun add3. Single lockfile at root
# Only run bun install from root
bun install4. Use catalogs for shared dependencies
{
"catalog": {
"typescript": "^5.7.0",
"vitest": "^3.0.0"
}
}5. Declare all dependencies explicitly
Each workspace should list all its dependencies - don't rely on hoisting.
CI/CD Integration
# .github/workflows/validate.yml
- name: Validate Bun Workspace
run: |
python3 ~/.claude/skills/bun-validator/scripts/validate.py \
--root . \
--strict \
--ciIntegration
linter-formatter-init- Sets up Biome with Bunproject-scaffold- Creates workspace structurenextjs-validator- Validates Next.js in workspace