Skip to main content
skill CX Codex

uv-workspaces — Claude Code skill for Python monorepos on uv

A skill for multi-package Python projects on uv: workspace setup, a shared lockfile, and dependencies between members.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add laurigates/claude-plugins --skill uv-workspaces -a claude-code
Open on GitHub

What uv-workspaces does

The skill kicks in when the conversation touches uv workspaces, a Python monorepo, a shared lockfile or member dependencies. Inside is a reference on workspace layout: a root pyproject.toml with a [tool.uv.workspace] section and a members list, a separate pyproject.toml per package, and one uv.lock for all of them.

It covers the behaviours people trip over. Sources in the root tool.uv.sources apply to every member, but a member-level override cancels the root source for that dependency entirely. The workspace takes requires-python as the intersection of all members, so a package on >=3.10 next to one on >=3.11 resolves to >=3.11. Member dependencies are always editable. There is a separate table for a virtual workspace with no [project] table in the root: there uv run and uv sync fail without --package or --all-packages.

You also get commands for the usual operations, a comparison of { workspace = true } against path dependencies, a Dockerfile example that caches the dependency layer with --no-install-workspace, and a set of CI commands. The skill is not user-invocable and works with Bash, Read, Grep and Glob. For a single package, git dependencies or publishing to PyPI the document points at other skills — this one is about monorepos.

What it helps with

  • combine several Python packages into one workspace with a shared lockfile
  • wire one package as a dependency of another without publishing it
  • find out why uv sync misses a package in a virtual workspace
  • split conflicting dependency versions between two members
  • speed up a Docker build by caching the dependency layer

Example prompts for the agent

  • set up a uv workspace for the packages under packages/
  • why does uv run fail in the root without --package
  • add ../core as a dependency of packages/api

How to install uv-workspaces

1Skills CLI (Vercel)

npx skills add laurigates/claude-plugins --skill uv-workspaces -a claude-code

2Manually: put the files in place

~/.claude/skills/uv-workspaces/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/uv-workspaces/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about uv-workspaces

How do I install uv-workspaces in Claude?

Run npx skills add laurigates/claude-plugins --skill uv-workspaces -a claude-code. The skill lands in ~/.claude/skills/uv-workspaces/SKILL.md.

What does uv-workspaces do?

It hands the agent a reference for multi-package Python projects on uv: workspace structure, one shared uv.lock, member dependencies, and the uv sync, uv lock and uv run commands with --package and --all-packages.

How is a workspace dependency different from a path dependency?

With { workspace = true } you get a shared lockfile, always-editable installs, a required workspace membership and a working --package flag. A path dependency gives none of that but allows conflicting requirements and separate virtual environments.

Source text

SKILL.md · MIT
---
created: 2025-12-16
modified: 2026-05-09
reviewed: 2026-02-12
name: uv-workspaces
description: Manage multi-package Python projects with uv workspaces. Use when the user mentions uv workspaces, Python monorepo, shared lockfiles, or member dependencies.
user-invocable: false
allowed-tools: Bash, Read, Grep, Glob
---

# UV Workspaces

Quick reference for managing monorepo and multi-package projects with UV workspaces.

## When to Use This Skill

| Use this skill when... | Use another skill instead when... |
|------------------------|-----------------------------------|
| Setting up a Python monorepo with shared deps | Managing a single package (`uv-project-management`) |
| Configuring workspace members and inter-package deps | Adding git/URL dependencies (`uv-advanced-dependencies`) |
| Using `--package` or `--all-packages` flags | Building/publishing to PyPI (`python-packaging`) |
| Creating virtual workspaces (root with no project) | Managing Python versions (`uv-python-versions`) |
| Debugging workspace dependency resolution | Running standalone scripts (`uv-run`) |

## Quick Reference

### Workspace Structure

```
my-workspace/
├── pyproject.toml          # Root workspace config
├── uv.lock                 # Shared lockfile (all members)
├── packages/
│   ├── core/
│   │   ├── pyproject.toml
│   │   └── src/core/
│   ├── api/
│   │   ├── pyproject.toml
│   │   └── src/api/
│   └── cli/
│       ├── pyproject.toml
│       └── src/cli/
└── README.md
```

### Root pyproject.toml

```toml
[project]
name = "my-workspace"
version = "0.1.0"
requires-python = ">=3.11"

[tool.uv.workspace]
members = ["packages/*"]

# Optional: exclude specific members
exclude = ["packages/experimental"]
```

### Virtual Workspace (No Root Package)

When the root is purely organizational and not a package itself, omit the `[project]` table:

```toml
# Root pyproject.toml — virtual workspace (no [project] table)
[tool.uv.workspace]
members = ["packages/*"]
```

- The root is **not** a workspace member
- All members live in subdirectories
- `uv run` and `uv sync` require `--package` or `--all-packages` (will error without them)

### Member pyproject.toml

```toml
[project]
name = "my-api"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = [
    "my-core",       # Workspace member
    "fastapi",       # External (PyPI)
]

[tool.uv.sources]
my-core = { workspace = true }
```

## Common Commands

| Operation | Command |
|-----------|---------|
| Sync workspace root | `uv sync` |
| Sync all members | `uv sync --all-packages` |
| Sync specific member | `uv sync --package my-api` |
| Run in member context | `uv run --package my-api python script.py` |
| Lock entire workspace | `uv lock` |
| Upgrade a dependency | `uv lock --upgrade-package requests` |
| Build specific package | `uv build --package my-core` |
| Add dep to member | `cd packages/api && uv add requests` |
| Add workspace dep | `cd packages/api && uv add ../core` |

## Key Behaviors

### Source Inheritance

Root `tool.uv.sources` apply to **all members** unless overridden.

**Use case**: Define workspace sources in root for all members, override only when a specific member needs a different version:

```toml
# Root pyproject.toml — applies to all members
[tool.uv.sources]
my-utils = { workspace = true }

# packages/legacy/pyproject.toml — needs pinned version
[tool.uv.sources]
my-utils = { path = "../utils-v1" }  # Overrides root entirely
```

Override is **per-dependency and total** — if a member defines a source for a dependency, the root source for that dependency is ignored completely.

### requires-python Resolution

The workspace enforces the **intersection** of all members' `requires-python`:

```toml
# packages/core: requires-python = ">=3.10"
# packages/api:  requires-python = ">=3.11"
# Effective:     requires-python = ">=3.11"
```

All members must have compatible Python version requirements.

### Editable Installations

Workspace member dependencies are **always editable** — source changes are immediately available without reinstallation.

### Default Scope

| Command | Default scope | Override |
|---------|---------------|----------|
| `uv lock` | Entire workspace | — |
| `uv sync` | Workspace root only | `--package`, `--all-packages` |
| `uv run` | Workspace root only | `--package`, `--all-packages` |
| `uv build` | All members | `--package` |

## Workspace vs Path Dependencies

| Feature | `{ workspace = true }` | `{ path = "../pkg" }` |
|---------|------------------------|------------------------|
| Shared lockfile | Yes | No |
| Always editable | Yes | Optional |
| Must be workspace member | Yes | No |
| `--package` flag works | Yes | No |
| Conflicting deps allowed | No | Yes |

Use path dependencies when members need conflicting requirements or separate virtual environments.

## Docker Layer Caching

```dockerfile
# Install deps first (cached layer)
COPY pyproject.toml uv.lock packages/*/pyproject.toml ./
RUN uv sync --frozen --no-install-workspace

# Then install project (changes frequently)
COPY . .
RUN uv sync --frozen
```

| Flag | Effect |
|------|--------|
| `--no-install-project` | Skip current project, install deps only |
| `--no-install-workspace` | Skip all workspace members, install deps only |
| `--no-install-package <name>` | Skip specific package(s) |
| `--frozen` | Skip lockfile freshness check |

## Agentic Optimizations

| Context | Command |
|---------|---------|
| Sync all members | `uv sync --all-packages` |
| CI sync (frozen) | `uv sync --all-packages --frozen` |
| Test specific member | `uv run --package my-core pytest --dots --bail=1` |
| Test all members | `uv run --all-packages pytest --dots --bail=1` |
| Lock with upgrade | `uv lock --upgrade-package <dep>` |
| Build one package | `uv build --package my-core` |
| Docker deps layer | `uv sync --frozen --no-install-workspace` |

## See Also

- `uv-project-management` — Managing individual packages
- `uv-advanced-dependencies` — Path and Git dependencies
- `python-packaging` — Building and publishing workspace packages

For detailed workspace patterns (virtual workspaces, Docker integration, source inheritance, syncing strategies), CI/CD examples, and troubleshooting, see [REFERENCE.md](REFERENCE.md).

© laurigates · MIT · laurigates/claude-plugins

Similar skills

All skills for Programming languages →

From the same set5

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor