Dependencies
This skill requires Python 3.8+ and standard library only. No external packages needed.
To install this skill's dependencies:
pip-compile ./requirements.in
pip install -r ./requirements.txt
See ./requirements.txt for the dependency lockfile (currently empty — standard library only).
Dependency Management
- One runtime per service. Each isolated service owns its own
./requirements.txt lockfile.
Script Architecture & Packaging
For plugin packaging, DRY script distribution, and Windows symlink/junction compatibility rules, see the authoritative shared plugin packaging guidelines.
Repository Layout (Example)
src/
├── requirements-core.in # Tier 1: shared baseline (fastapi, pydantic…)
├── requirements-core.txt # Lockfile for core
├── services/
│ ├── auth_service/
│ │ ├── requirements.in # Tier 2: inherits core + auth deps
│ │ └── requirements.txt
│ ├── payments_service/
│ │ ├── requirements.in
│ │ └── requirements.txt
│ └── database_service/
│ ├── requirements.in
│ └── requirements.txt
Tiered Hierarchy
| Tier |
Scope |
File |
Examples |
| 1 – Core |
Shared by >80% of services |
requirements-core.in |
fastapi, pydantic, httpx |
| 2 – Specialized |
Service-specific heavyweights |
<service>/requirements.in |
stripe, redis, asyncpg |
| 3 – Dev tools |
Never in production containers |
requirements-dev.in |
pytest, black, ruff |
Each service .in file usually begins with -r ../../requirements-core.in to inherit the core dependencies.
Workflow: Adding or Upgrading a Package
Declare — Add or update the version constraint in the correct .in file.
- If the package is needed by most services →
requirements-core.in
- If only one service → that service's
.in
- Security floor pins use
>= syntax: cryptography>=46.0.5
Lock — Compile the lockfile:
# Core
pip-compile src/requirements-core.in \
--output-file src/requirements-core.txt
# Individual service (example: auth)
pip-compile src/services/auth_service/requirements.in \
--output-file src/services/auth_service/requirements.txt
Because services inherit core via -r, recompiling a service also picks up core changes.
Sync — Install locally to verify:
Preferred (if available):
pip-sync src/services/<service>/requirements.txt
Fallback:
pip install -r src/services/<service>/requirements.txt
Verify — Rebuild the affected Docker/Podman container to confirm stable builds.
Commit — Stage and commit both .in and .txt files together.
Workflow: Responding to Dependabot / Security Alerts
Identify the affected package and fixed version from the advisory (GHSA/CVE).
Determine tier placement:
- Check if the package is a direct dependency (appears in an
.in file).
- If it only appears in
.txt files, it's transitive — pinned by something upstream.
For direct dependencies: Bump the version floor in the relevant .in file.
# SECURITY PATCHES (Mon YYYY)
package-name>=X.Y.Z
For transitive dependencies: Add a version floor pin in the appropriate .in file
to force the resolver to pull the patched version, even though it's not a direct dependency.
Recompile all affected lockfiles. Since services inherit core, a core change means
recompiling every service lockfile. Use this compilation order:
# 1. Core first
pip-compile src/requirements-core.in \
--output-file src/requirements-core.txt
# 2. Then each service
for svc in auth_service payments_service database_service; do
pip-compile "src/services/${svc}/requirements.in" \
--output-file "src/services/${svc}/requirements.txt"
done
Verify the patched version appears in all affected .txt files:
grep -i "package-name" src/requirements-core.txt \
src/services/*/requirements.txt
If no newer version exists (e.g., inherent design risk like pickle deserialization),
document the advisory acknowledgement as a comment in the .in file and note mitigations.
Container / Dockerfile Constraints
- Dockerfiles only use
COPY requirements.txt + RUN pip install -r requirements.txt.
- No
RUN pip install <pkg> commands. No manual installs.
- Copy
requirements.txt before source code to preserve Docker layer caching.
Non-Negotiable Execution Rules
The agent MUST NOT:
- Run
pip install <pkg> directly to resolve dependency issues.
- Modify
.txt lockfiles manually.
- Bypass
pip-compile failures.
- Ignore missing tools (e.g.,
pip-compile not installed).
- Continue after dependency conflicts without resolution.
If any of the above occurs:
- HALT execution immediately.
- Classify using the self-evolution profile.
- Either:
- Fix within allowed directories, OR
- Log to
map-debt.md.
- Report explicitly to the user.
Workarounds are considered Tier 0 Friction and must be logged.
Self-Evolution Requirements
When this skill encounters friction, failure, ambiguity, or a workaround:
- Do not silently bypass the issue.
- Classify the issue using
references/self-evolution-profile.md.
- If fixed within allowed directories, update the relevant skill/reference file.
- Add an entry to
references/evolution-log.md.
- If not fixed, add an entry to
references/map-debt.md with severity, repeat risk, and recommended fix.
When to Record Map Debt
Log to map-debt.md when:
- Tooling is missing (e.g.
pip-compile is absent).
- Conflicts require human resolution.
- The dependency graph is ambiguous.
- Instructions in this plugin are unclear or contradictory.
Do not silently proceed.
Common Pitfalls
- Forgetting to recompile downstream services after a core
.in change.
- Pinning
== instead of >= for security floors — use >= so pip-compile can resolve freely.
- Adding dev tools to production
.in files — keep pytest, ruff, etc. in requirements-dev.in.
- Committing
.txt without .in — always commit them as a pair.
1---2name: dependency-management3plugin: dependency-management4description: >5 Python dependency and environment management for multi-service or monorepo python backends.6 Use when: (1) adding, upgrading, or removing a Python package, (2) responding to Dependabot7 or security vulnerability alerts (GHSA/CVE), (3) creating a new service that needs its8 own requirements files, (4) debugging pip install failures or Docker build issues related9 to dependencies, (5) reviewing or auditing the dependency tree, (6) running pip-compile.10 Enforces the pip-compile locked-file workflow and tiered dependency hierarchy.11allowed-tools: Bash, Read, Write12---1314## Dependencies1516This skill requires **Python 3.8+** and standard library only. No external packages needed.1718**To install this skill's dependencies:**19```bash20pip-compile ./requirements.in21pip install -r ./requirements.txt22```2324See `./requirements.txt` for the dependency lockfile (currently empty — standard library only).2526---27# Dependency Management28293. **One runtime per service.** Each isolated service owns its own `./requirements.txt` lockfile.3031## Script Architecture & Packaging3233For plugin packaging, DRY script distribution, and Windows symlink/junction compatibility rules, see the authoritative shared plugin packaging guidelines.3435## Repository Layout (Example)3637```38src/39├── requirements-core.in # Tier 1: shared baseline (fastapi, pydantic…)40├── requirements-core.txt # Lockfile for core41├── services/42│ ├── auth_service/43│ │ ├── requirements.in # Tier 2: inherits core + auth deps44│ │ └── requirements.txt45│ ├── payments_service/46│ │ ├── requirements.in47│ │ └── requirements.txt48│ └── database_service/49│ ├── requirements.in50│ └── requirements.txt51```5253## Tiered Hierarchy5455| Tier | Scope | File | Examples |56|------|-------|------|----------|57| **1 – Core** | Shared by >80% of services | `requirements-core.in` | `fastapi`, `pydantic`, `httpx` |58| **2 – Specialized** | Service-specific heavyweights | `<service>/requirements.in` | `stripe`, `redis`, `asyncpg` |59| **3 – Dev tools** | Never in production containers | `requirements-dev.in` | `pytest`, `black`, `ruff` |6061Each service `.in` file usually begins with `-r ../../requirements-core.in` to inherit the core dependencies.6263## Workflow: Adding or Upgrading a Package64651. **Declare** — Add or update the version constraint in the correct `.in` file.66 - If the package is needed by most services → `requirements-core.in`67 - If only one service → that service's `.in`68 - Security floor pins use `>=` syntax: `cryptography>=46.0.5`69702. **Lock** — Compile the lockfile:71 ```bash72 # Core73 pip-compile src/requirements-core.in \74 --output-file src/requirements-core.txt7576 # Individual service (example: auth)77 pip-compile src/services/auth_service/requirements.in \78 --output-file src/services/auth_service/requirements.txt79 ```80 Because services inherit core via `-r`, recompiling a service also picks up core changes.81823. **Sync** — Install locally to verify:83 Preferred (if available):84 ```bash85 pip-sync src/services/<service>/requirements.txt86 ```87 Fallback:88 ```bash89 pip install -r src/services/<service>/requirements.txt90 ```9192934. **Verify** — Rebuild the affected Docker/Podman container to confirm stable builds.94955. **Commit** — Stage and commit **both** `.in` and `.txt` files together.9697## Workflow: Responding to Dependabot / Security Alerts98991. **Identify the affected package and fixed version** from the advisory (GHSA/CVE).1001012. **Determine tier placement:**102 - Check if the package is a **direct** dependency (appears in an `.in` file).103 - If it only appears in `.txt` files, it's **transitive** — pinned by something upstream.1041053. **For direct dependencies:** Bump the version floor in the relevant `.in` file.106 ```107 # SECURITY PATCHES (Mon YYYY)108 package-name>=X.Y.Z109 ```1101114. **For transitive dependencies:** Add a version floor pin in the appropriate `.in` file112 to force the resolver to pull the patched version, even though it's not a direct dependency.1131145. **Recompile all affected lockfiles.** Since services inherit core, a core change means115 recompiling every service lockfile. Use this compilation order:116 ```bash117 # 1. Core first118 pip-compile src/requirements-core.in \119 --output-file src/requirements-core.txt120121 # 2. Then each service122 for svc in auth_service payments_service database_service; do123 pip-compile "src/services/${svc}/requirements.in" \124 --output-file "src/services/${svc}/requirements.txt"125 done126 ```1271286. **Verify the patched version appears** in all affected `.txt` files:129 ```bash130 grep -i "package-name" src/requirements-core.txt \131 src/services/*/requirements.txt132 ```1331347. **If no newer version exists** (e.g., inherent design risk like pickle deserialization),135 document the advisory acknowledgement as a comment in the `.in` file and note mitigations.136137## Container / Dockerfile Constraints138139- Dockerfiles **only** use `COPY requirements.txt` + `RUN pip install -r requirements.txt`.140- No `RUN pip install <pkg>` commands. No manual installs.141- Copy `requirements.txt` **before** source code to preserve Docker layer caching.142143## Non-Negotiable Execution Rules144145The agent MUST NOT:146- Run `pip install <pkg>` directly to resolve dependency issues.147- Modify `.txt` lockfiles manually.148- Bypass `pip-compile` failures.149- Ignore missing tools (e.g., `pip-compile` not installed).150- Continue after dependency conflicts without resolution.151152If any of the above occurs:1531. **HALT** execution immediately.1542. Classify using the self-evolution profile.1553. Either:156 - Fix within allowed directories, OR157 - Log to `map-debt.md`.1584. Report explicitly to the user.159160Workarounds are considered Tier 0 Friction and must be logged.161162163## Self-Evolution Requirements164165When this skill encounters friction, failure, ambiguity, or a workaround:1661. Do not silently bypass the issue.1672. Classify the issue using `references/self-evolution-profile.md`.1683. If fixed within allowed directories, update the relevant skill/reference file.1694. Add an entry to `references/evolution-log.md`.1705. If not fixed, add an entry to `references/map-debt.md` with severity, repeat risk, and recommended fix.171172173## When to Record Map Debt174175Log to `map-debt.md` when:176- Tooling is missing (e.g. `pip-compile` is absent).177- Conflicts require human resolution.178- The dependency graph is ambiguous.179- Instructions in this plugin are unclear or contradictory.180181Do not silently proceed.182183184## Common Pitfalls185186- **Forgetting to recompile downstream services** after a core `.in` change.187- **Pinning `==` instead of `>=`** for security floors — use `>=` so `pip-compile` can resolve freely.188- **Adding dev tools to production `.in` files** — keep `pytest`, `ruff`, etc. in `requirements-dev.in`.189- **Committing `.txt` without `.in`** — always commit them as a pair.190