name: polylith-dependency-management description: Add or manage third-party dependencies in a Polylith workspace. Use when the user wants to install a new library (e.g., requests, fastapi) for a brick or project.
Dependency Management Skill
💡 Terminology: this skill uses Polylith terms like brick, project, and development project. If they're unfamiliar, load
polylith-conceptsfirst.
Polylith manages third-party dependencies differently than standard Python projects.
Rules for adding dependencies
- The Development Project (Root):
Every third-party library used anywhere in the workspace must be added to the root
pyproject.toml(the development project). This ensures local REPLs, tests, and the shared lockfile work correctly. Use your package manager (e.g.,uv add <package>,poetry add <package>) at the workspace root. - Deployable Projects (
projects/<name>): If a library is required for production by a specific deployable project, it must also be added to that project'spyproject.tomlunderprojects/<name>/. Do this by manually editing thedependenciesarray inprojects/<name>/pyproject.toml.
⚠ Never add dependencies to a brick's directory. Bricks do not have their own
pyproject.tomlfiles.
Example Workflow: Adding requests to an api project
Install it at the root so the lockfile updates and it's available for local development:
uv add requestsManually add it to the deployable project that needs it: Edit
projects/api/pyproject.toml.Important Versioning Rule: Before adding the dependency to the project, check the root
pyproject.toml. If it contains a[tool.uv.workspace]section (e.g.,members = ["projects/*"]), thenuv workspacesis enabled.If
uv workspacesis enabled, do not specify the version in the project'spyproject.toml. Just use the package name, because versions are centrally pinned in the root. If workspaces are not enabled, then you should specify the version.# WITH uv/poetry workspaces enabled (Recommended): dependencies = [ "requests" ] # WITHOUT workspaces enabled: dependencies = [ "requests>=2.31.0" ]Run
poly check(loadpolylith-check) to verify the workspace is valid.poly checkwill catch if a project importsrequestsbut forgot to declare it in itspyproject.toml.
Notes for the agent
- Use
poly libs(loadpolylith-libs) to inspect current dependency usage across projects.