agentleFS
Google CloudKnown publisherGoogleCloudPlatform/data-agent-kit-plugin/skills/managing-python-dependencies/SKILL.md

managing-python-dependencies

Skill240 starsChanged 5 months agoApache-2.0View on GitHub

Ensures proper Python dependency management, avoiding global `pip install` and adhering to project-specific tooling.

  • Installs packages

3 other projects use a version of this, 3 of them edited.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. 1 is common, 0 are distinctive, and 5 are very specific to this project.

  • 1

    Common

    Most of the 3 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Only run dependency manager detection when a package actually needs to be installed (e.g., on ModuleNotFoundError / ImportError or when …

    line 58
  2. Common:

    If no dependency manager is detected, use venv + pip + requirements.txt as the default:

    line 91
  3. Very specific:

    Always use .venv/bin/pip or .venv/bin/python (explicit path).

    line 107
  4. Very specific:

    After installing, run: .venv/bin/pip freeze > requirements.txt.

    line 108
  5. Very specific:

    When setting up: .venv/bin/pip install -r requirements.txt.

    line 109
  6. Very specific:

    NEVER: run pip install globally

    line 113

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Python Dependency Management Rule

[!CAUTION]

BEFORE any pip install: You MUST first detect the project's existing dependency manager and use it correctly. Do NOT override the project's established tooling.

[!NOTE]

Reactive Environment Check Bundling (Only When Installing): Do NOT run environment or package availability checks (importlib.util.find_spec, pip list, ls uv.lock...) proactively before writing code or creating a notebook. Only probe the environment when a package actually needs to be installed (for example, on ModuleNotFoundError / ImportError or an explicit user request to install dependencies).

  • In Notebooks: When a notebook cell execution tool (execute_cell / notebook_execute_cell) is available, check package availability (import <pkg> or %pip list) and install missing packages (%pip install) inside notebook cells, never via python3 -c or pip in the shell.
  • In the Shell (Only When Installing): When a shell check is required before installing a missing package for a local script or project, you MUST NOT run multiple sequential 1-line shell check commands. Combine all environment and package availability probes into a single composite python one-liner or shell check step:
python3 -c "import sys, importlib.util; print(f'Python {sys.version.split()[0]}'); [(print(f'{pkg}: {__import__(pkg).__version__}') if importlib.util.find_spec(pkg) else print(f'{pkg}: not found')) for pkg in ['pyspark', 'google.cloud.bigquery']]"

This bundling also applies to dependency manager detection; when an install is needed, use a single ls or find command to check for all potential dependency manager configuration and lock files at once (e.g. ls uv.lock poetry.lock Pipfile.lock requirements.txt pyproject.toml).

Dependency Manager Detection (Only When Installing)

Only run dependency manager detection when a package actually needs to be installed (e.g., on ModuleNotFoundError / ImportError or when setting up a missing local project environment)—never as an upfront pre-flight check before creating or running a notebook. Before installing ANY Python package, check the workspace for these files in priority order:

  1. Signal: uv.lock or pyproject.toml with [tool.uv]
    • Tool: uv
    • Install: uv add <package>
    • Setup: uv sync
  2. Signal: pyproject.toml with [tool.poetry]
    • Tool: Poetry
    • Install: poetry add <package>
    • Setup: poetry install
  3. Signal: Pipfile
    • Tool: Pipenv
    • Install: pipenv install <package>
    • Setup: pipenv install
  4. Signal: environment.yml
    • Tool: Conda
    • Install: conda install <package>
    • Setup: conda env create -f environment.yml
  5. Signal: requirements.txt only
    • Tool: venv + pip
    • Install: .venv/bin/pip install <package>
    • Setup: .venv/bin/pip install -r requirements.txt
  6. Signal: None of the above
    • Tool: venv + pip (default)
    • Install: .venv/bin/pip install <package>
    • Setup: .venv/bin/pip install -r requirements.txt

Default: venv + pip

If no dependency manager is detected, use venv + pip + requirements.txt as the default:

# Initialize environment
python3 -m venv .venv

# Add dependencies
.venv/bin/pip install <package>

# Preserve state
.venv/bin/pip freeze > requirements.txt

Rules for venv + pip workflow:

  • Always use .venv/bin/pip or .venv/bin/python (explicit path).
  • After installing, run: .venv/bin/pip freeze > requirements.txt.
  • When setting up: .venv/bin/pip install -r requirements.txt.

Prohibited

  • NEVER run pip install globally
  • NEVER override an existing dependency manager with a different one

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.