pnpm Monorepo
Category: monorepo October 19, 2025
Agent instructions for working with pnpm workspaces and monorepo projects
pnpmmonorepoworkspacepackage-manager
# pnpm Monorepo Development
## Project Structure
This is a pnpm workspace monorepo. Package locations are defined in `pnpm-workspace.yaml`.
## Dev Environment Tips
- Use `pnpm dlx turbo run where <project_name>` to jump to a package instead of scanning with `ls`
- Run `pnpm install --filter <project_name>` to add dependencies to a specific workspace package
- Use `pnpm create vite@latest <project_name> -- --template react-ts` to spin up a new React + Vite package
- Check the `name` field inside each package's `package.json` to confirm the right name—skip the top-level one
- Run `pnpm -r <command>` to run a command in all workspace packages recursively
## Testing Instructions
- Find the CI plan in the `.github/workflows` folder
- Run `pnpm turbo run test --filter <project_name>` to run every check defined for that package
- From the package root you can just call `pnpm test`. The commit should pass all tests before you merge
- To focus on one test, add the test pattern: `pnpm vitest run -t "<test name>"`
- Fix any test or type errors until the whole suite is green
- After moving files or changing imports, run `pnpm lint --filter <project_name>` to ensure ESLint and TypeScript rules still pass
- Add or update tests for the code you change, even if nobody asked
## Build Instructions
- Build a specific package: `pnpm build --filter <project_name>`
- Build all packages: `pnpm -r build`
- Watch mode for development: `pnpm dev --filter <project_name>`
- Clean build artifacts: `pnpm clean` (if defined in package.json scripts)
## Dependency Management
- Add a dependency to a specific package: `pnpm add <package> --filter <project_name>`
- Add a dev dependency: `pnpm add -D <package> --filter <project_name>`
- Add a workspace package as dependency: `pnpm add <workspace-package>@workspace --filter <target-package>`
- Update dependencies: `pnpm update --latest --recursive`
- Check outdated packages: `pnpm outdated --recursive`
## Common Issues
- If you see "workspace not found" errors, check `pnpm-workspace.yaml` configuration
- Peer dependency warnings can often be ignored in monorepos
- Use `pnpm install --force` only as a last resort to fix dependency issues
- Always run commands from the workspace root unless working on a specific package
## PR Instructions
- Title format: `[<project_name>] <Title>`
- Always run `pnpm lint` and `pnpm test` before committing
- Ensure all affected packages build successfully
- Update the changelog if your changes are user-facing