agentleFS
SwastikPandey1024SwastikPandey1024/agentic-engineering-os/.agents/skills/environment-guardrails/SKILL.md

environment-guardrails

Skill1 starsChanged 3 months agoMITView on GitHub

Hard environment isolation, Python version pinning, uv package management, and migration/fallback strategies for pip, venv, conda, poetry, and pipenv.

  • Installs packages

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 2 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 10
  2. Very specific:

    Look for uv.lock, poetry.lock, Pipfile.lock, environment.yml, requirements.txt, pyproject.toml.

    line 24
  3. Very specific:

    Run python -c "import sys.

    line 26
  4. Very specific:

    Detect Version: Read target Python version (3.11, 3.12).

    line 57
  5. Very specific:

    Detect Toolchain: Check for existing lockfiles (uv.lock, poetry.lock).

    line 58
  6. Distinctive:

    Respect Mature Projects: If a project heavily relies on Poetry or Conda, use that toolchain unless requested to migrate.

    line 59
  7. Very specific:

    Create Project-Local .venv: Always create .venv directly in the project root.

    line 61
  8. Very specific:

    Pin Python Version: Write exact minor version to .python-version (e.g.

    line 63
  9. Very specific:

    Maintain Lockfile: Keep uv.lock synchronized and committed to version control.

    line 64
  10. Very specific:

    Separate Dependencies: Put testing, linting, and formatting tools under [project.optional-dependencies] dev = [...].

    line 65
  11. Very specific:

    Never Use Unmanaged pip: Use uv add or .venv/bin/pip.

    line 68
  12. Very specific:

    Exclude .venv from Git: Ensure .venv is in .gitignore.

    line 72

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Environment Guardrails Skill

1. When Should I Use This?

Use this skill when:

  • Bootstrapping any new Python project or working in an existing repository.
  • Setting up, verifying, or repairing virtual environment isolation (.venv/).
  • Enforcing package management standards (uv by default; preserving conda/poetry/pip when mature).
  • Diagnosing global package pollution, interpreter mismatches, or lockfile desynchronization.
  • Migrating legacy requirements.txt or Pipfile projects to modern pyproject.toml + uv.lock.

2. What Should I Inspect First?

  1. Python Version Requirements:
    • Inspect .python-version, pyproject.toml (requires-python = ">=3.11"), or runtime.txt.
  2. Existing Package Manager & Toolchain:
    • Look for uv.lock, poetry.lock, Pipfile.lock, environment.yml, requirements.txt, pyproject.toml.
  3. Active Interpreter Location:
    • Run python -c "import sys; print(sys.executable)" to confirm if it points inside .venv/ or system Python.
  4. IDE Interpreter Settings:
    • Inspect .vscode/settings.json for "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python" (or Scripts/python.exe).

3. What Workflow Should I Follow?

Detect Python Version Requirements (.python-version, pyproject.toml)
                       ↓
Detect Existing Package Manager:
 ├── New Project / Modern Setup   → Modern uv Workflow
 ├── Mature Poetry / Conda / Venv → Preserve Existing Toolchain
 └── Legacy requirements.txt      → Isolate with venv/uv without breaking
                       ↓
Create Project-Local Virtual Environment (.venv/) BEFORE Dependency Installs
                       ↓
Pin Python Version (.python-version & pyproject.toml)
                       ↓
Synchronize Dependencies via Lockfile (uv sync / uv.lock)
                       ↓
Separate Runtime Dependencies from Dev Dependencies ([project.optional-dependencies])
                       ↓
Configure IDE & Git (.gitignore contains .venv, IDE points to .venv)
                       ↓
Verify Environment Isolation

The 18-Step Standard Environment Protocol

  1. Detect Version: Read target Python version (3.11, 3.12).
  2. Detect Toolchain: Check for existing lockfiles (uv.lock, poetry.lock).
  3. Respect Mature Projects: If a project heavily relies on Poetry or Conda, use that toolchain unless requested to migrate.
  4. Default to uv for New Projects: uv is the standard modern fast package manager.
  5. Create Project-Local .venv: Always create .venv directly in the project root.
  6. Create or Maintain pyproject.toml: Single source of truth for build backend, metadata, and dependencies.
  7. Pin Python Version: Write exact minor version to .python-version (e.g. 3.12).
  8. Maintain Lockfile: Keep uv.lock synchronized and committed to version control.
  9. Separate Dependencies: Put testing, linting, and formatting tools under [project.optional-dependencies] dev = [...].
  10. Never Install Globally: Reject any bare pip install targeting /usr/bin/python or global AppData.
  11. Never Mix Project Dependencies: Each project must have its own dedicated .venv.
  12. Never Use Unmanaged pip: Use uv add or .venv/bin/pip.
  13. Use uv add for Project Dependencies: Automatically updates pyproject.toml and uv.lock.
  14. Use uv sync for Synchronization: Synchronizes environment state cleanly to match lockfile.
  15. Use uv run for Command Execution: Runs test runners and scripts inside the managed environment automatically.
  16. Exclude .venv from Git: Ensure .venv is in .gitignore.
  17. Verify IDE Interpreter: Configure .vscode/settings.json to point to .venv.
  18. Document Setup in README: Provide copy-pasteable environment initialization commands in README.md.

Migration & Fallback Protocols

Protocol A: Modern uv Workflow (Recommended)

# 1. Pin version
echo "3.12" > .python-version

# 2. Create isolated venv
uv venv .venv --python 3.12

# 3. Add dependencies
uv add "fastapi>=0.110.0" "pydantic>=2.7.0"
uv add --dev "pytest>=8.0.0" "ruff>=0.3.0"

# 4. Synchronize environment
uv sync

# 5. Run commands in environment
uv run pytest -v

Protocol B: Existing requirements.txt / Standard venv

# 1. Create standard venv
python -m venv .venv

# 2. Activate
# Linux/macOS:
source .venv/bin/activate
# Windows PowerShell:
.venv\Scripts\Activate.ps1

# 3. Install requirements
pip install --upgrade pip
pip install -r requirements.txt
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi

Protocol C: Existing Conda Environment

# 1. Create environment from environment.yml or version
conda env create -f environment.yml -p ./.conda_env || conda create -n my_env python=3.11 -y

# 2. Activate
conda activate my_env

Protocol D: Existing Poetry Project

# 1. Configure poetry to create .venv inside project root
poetry config virtualenvs.in-project true

# 2. Install and lock
poetry install
poetry run pytest

4. What Decisions Should I Make?

ScenarioDecision Rule
New Python ProjectAlways use uv + pyproject.toml + uv.lock.
Existing Stable Poetry / CondaKeep existing toolchain. Do not force-migrate without user request.
Legacy requirements.txtIf simple, keep requirements.txt or migrate to pyproject.toml if adding modern tooling like Ruff/Pytest.
Docker Container BuildUse uv pip install --system -r requirements.txt or multi-stage build with .venv.

5. What Should I Avoid?

  • NEVER run pip install without an active .venv: This pollutes system libraries.
  • NEVER delete an existing poetry.lock or Pipfile.lock to force uv without user consent.
  • NEVER commit .venv/ or .conda/ folders to Git.
  • NEVER use unpinned dependencies without bounds (e.g. use pydantic>=2.7.0,<3.0.0, not pydantic).

6. How Should I Verify Success?

# 1. Verify python points to local .venv
python -c "import sys; print(sys.executable); assert '.venv' in sys.executable or 'conda' in sys.executable, 'CRITICAL: Running in Global Python!'"

# 2. Verify dependency resolution and lockfile consistency
uv lock --check || pip check

# 3. Verify tool execution inside environment
uv run pytest --version || .venv/bin/pytest --version

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.