with one click
polylith-dependency-management
// 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.
// 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.
Create a Polylith base with `poly create base` — the entry point of a deployable application (HTTP API, CLI, message-queue consumer, AWS Lambda handler, GCP Cloud Function, scheduled job). Use when the user wants to add a service, API, endpoint, handler, or any new entry point to a Polylith workspace.
Safely remove a Polylith brick (component or base) from the workspace. Use when the user wants to delete, remove, or tear down a component or base.
Validate a Polylith workspace with `poly check` — the canonical CI gate. Verifies brick imports against project `pyproject.toml`s, third-party library declarations vs. the lock file, and (under `--strict`) cross-project version consistency. Exits 1 on failure. Use when the user wants to lint, validate, verify, or CI-gate a Polylith workspace.
Create a Polylith component with `poly create component` — a reusable, isolated brick implementing business logic, a feature, a domain module, or a capability. Use when adding non-entry-point code that bases or other components will import.
Provides foundational knowledge about Polylith architecture, including the glossary (bases, components, projects, workspaces), theme layouts, and package manager mapping. Use this when you need to understand Polylith terminology or how the repository is structured conceptually before taking action.
Visualize **brick × brick** dependencies with `poly deps` — find circular dependencies, inspect a brick's public interface, and detect interface-bypass violations. Use for "what depends on what", "circular deps", "interface violation". For brick × project usage, use `polylith-workspace-inspection`.
| 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. |
💡 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.
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.projects/<name>):
If a library is required for production by a specific deployable project, it must also be added to that project's pyproject.toml under projects/<name>/. Do this by manually editing the dependencies array in projects/<name>/pyproject.toml.⚠ Never add dependencies to a brick's directory. Bricks do not have their own
pyproject.tomlfiles.
requests to an api projectInstall it at the root so the lockfile updates and it's available for local development:
uv add requests
Manually 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/*"]), then uv workspaces is enabled.
If uv workspaces is enabled, do not specify the version in the project's pyproject.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 (load polylith-check) to verify the workspace is valid. poly check will catch if a project imports requests but forgot to declare it in its pyproject.toml.
poly libs (load polylith-libs) to inspect current dependency usage across projects.