.claude/skills/bun-workspace/SKILL.md
Manage Bun monorepo workspaces and dependencies in the FTC Metrics project. Use when adding dependencies, running package scripts, troubleshooting workspace resolution, or managing cross-package imports.
npx skillsauth add ftc8569/ftcmetrics bun-workspaceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
FTC Metrics uses Bun as the JavaScript runtime and package manager with a monorepo workspace structure.
ftcmetrics-v2/
├── package.json # Root workspace config
├── bun.lock # Lockfile (committed)
├── .nvmrc # Node version: 22
├── packages/
│ ├── web/ # @ftcmetrics/web - Next.js frontend
│ │ └── package.json
│ ├── api/ # @ftcmetrics/api - Hono API server
│ │ └── package.json
│ ├── db/ # @ftcmetrics/db - Prisma database layer
│ │ └── package.json
│ └── shared/ # @ftcmetrics/shared - Shared types/utils
│ └── package.json
{
"name": "ftcmetrics-v2",
"private": true,
"workspaces": ["packages/*"],
"scripts": {
"dev": "bun run --filter '*' dev",
"dev:web": "bun run --filter @ftcmetrics/web dev",
"dev:api": "bun run --filter @ftcmetrics/api dev",
"build": "bun run --filter '*' build",
"lint": "bun run --filter '*' lint",
"typecheck": "bun run --filter '*' typecheck",
"db:generate": "bun run --filter @ftcmetrics/db generate",
"db:push": "bun run --filter @ftcmetrics/db push",
"db:migrate": "bun run --filter @ftcmetrics/db migrate",
"db:studio": "bun run --filter @ftcmetrics/db studio"
},
"engines": {
"node": ">=22"
}
}
| Package | Name | Purpose | |---------|------|---------| | web | @ftcmetrics/web | Next.js frontend (React 19) | | api | @ftcmetrics/api | Hono REST API server | | db | @ftcmetrics/db | Prisma client and database | | shared | @ftcmetrics/shared | Shared TypeScript types |
# Run all packages in dev mode
bun run dev
# Run specific package
bun run dev:web # Next.js on http://localhost:3000
bun run dev:api # Hono API with --watch
# Run script in specific package (alternative)
bun run --filter @ftcmetrics/web dev
bun run --filter @ftcmetrics/api dev
# Build all packages
bun run build
# Build specific package
bun run --filter @ftcmetrics/web build
bun run --filter @ftcmetrics/api build
# Typecheck all packages
bun run typecheck
# Typecheck specific package
bun run --filter @ftcmetrics/web typecheck
# Generate Prisma client
bun run db:generate
# Push schema to database
bun run db:push
# Create migration
bun run db:migrate
# Open Prisma Studio
bun run db:studio
# Add to packages/web
bun add <package> --filter @ftcmetrics/web
# Add dev dependency to packages/api
bun add -d <package> --filter @ftcmetrics/api
# Example: Add zod to the api package
bun add zod --filter @ftcmetrics/api
# Add shared dev dependency at root
bun add -d typescript
# Only use root for truly shared tooling
Internal packages use workspace:* protocol for cross-package dependencies:
{
"dependencies": {
"@ftcmetrics/db": "workspace:*",
"@ftcmetrics/shared": "workspace:*"
}
}
To add an internal dependency:
# Add @ftcmetrics/shared to a package
cd packages/api
bun add @ftcmetrics/shared@workspace:*
# Or edit package.json directly
import { prisma } from "@ftcmetrics/db";
import type { User, Team } from "@ftcmetrics/db";
import type { FTCEvent, FTCMatch, TeamRole } from "@ftcmetrics/shared";
For Next.js to transpile workspace packages, add to next.config.ts:
const nextConfig = {
transpilePackages: ["@ftcmetrics/shared"],
};
Bun's --filter flag supports various patterns:
# Exact package name
bun run --filter @ftcmetrics/web dev
# Glob pattern - all packages
bun run --filter '*' build
# Glob pattern - packages starting with @ftcmetrics
bun run --filter '@ftcmetrics/*' typecheck
# Multiple packages
bun run --filter @ftcmetrics/web --filter @ftcmetrics/api dev
The bun.lock file is a binary lockfile that should be committed to git. It ensures consistent installs across environments.
# Install all dependencies (respects lockfile)
bun install
# Update lockfile after package.json changes
bun install
# Update all dependencies to latest
bun update
# Update specific package
bun update <package>
workspace:* in dependenciesbun install from rootmain and types in package.jsonVerify the package exists in packages/ and has a valid package.json with a name field.
Bun hoists dependencies to the root node_modules. If a package needs a specific version:
{
"dependencies": {
"some-package": "^1.0.0"
}
}
The hoisted version will be in /node_modules/some-package.
Each package should have its own tsconfig.json. For workspace imports to resolve:
{
"compilerOptions": {
"moduleResolution": "bundler",
"paths": {
"@ftcmetrics/*": ["../*/src"]
}
}
}
Ensure the script exists in the package's package.json:
# Check what scripts are available
cat packages/web/package.json | jq '.scripts'
{
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"typecheck": "tsc --noEmit"
}
}
{
"scripts": {
"dev": "bun run --watch src/index.ts",
"build": "bun build src/index.ts --outdir dist --target node",
"start": "bun run dist/index.js",
"typecheck": "tsc --noEmit"
}
}
{
"scripts": {
"generate": "prisma generate",
"push": "prisma db push",
"migrate": "prisma migrate dev",
"studio": "prisma studio",
"typecheck": "tsc --noEmit"
}
}
{
"scripts": {
"typecheck": "tsc --noEmit"
}
}
The project requires Node.js 22+:
# Using nvm
nvm use
# Or install directly
nvm install 22
# macOS/Linux
curl -fsSL https://bun.sh/install | bash
# Or via npm
npm install -g bun
# Verify
bun --version
@ftcmetrics/web
└── @ftcmetrics/db
└── @ftcmetrics/shared
@ftcmetrics/api
└── @ftcmetrics/db
└── @ftcmetrics/shared
@ftcmetrics/db
└── (external deps only)
@ftcmetrics/shared
└── (no dependencies)
workspace:* for internal dependencies--filtersrc/index.ts that exports public API| Task | Command |
|------|---------|
| Install all deps | bun install |
| Dev all packages | bun run dev |
| Dev web only | bun run dev:web |
| Dev API only | bun run dev:api |
| Build all | bun run build |
| Typecheck all | bun run typecheck |
| Add dep to web | bun add <pkg> --filter @ftcmetrics/web |
| Add dev dep to api | bun add -d <pkg> --filter @ftcmetrics/api |
| Generate Prisma | bun run db:generate |
| Push DB schema | bun run db:push |
| Open Prisma Studio | bun run db:studio |
development
Configure TypeScript in a Bun/npm workspaces monorepo with shared base config, package-specific overrides, path aliases, and cross-package type sharing. Use when setting up tsconfig files, configuring path aliases, resolving module errors, or sharing types between packages.
development
Tailwind CSS styling for FTC Metrics with official FIRST colors and component patterns. Use when styling React components, creating responsive layouts, or implementing dark mode.
development
Configure and integrate Soketi WebSocket server with FTC Metrics for real-time updates. Use when setting up WebSocket connections, broadcasting scouting data changes, implementing presence channels for team collaboration, or debugging real-time features.
development
Create, structure, and optimize skills for the FTC Metrics project. Use when creating a new skill, improving an existing skill, or needing guidance on skill design patterns, triggers, frontmatter, and progressive disclosure.