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
In this repository30 other files it gives its agents.
- AGENTS.mdAGENTS.md
- adr-managementSkill
- agentic-developmentSkill
- ci-cdSkill
- code-architectureSkill
- database-postgresqlSkill
- data-engineeringSkill
- debuggingSkill
- deep-learningSkill
- dependency-managementSkill
- deploymentSkill
- dockerSkill
- documentation-orchestratorSkill
- documentationSkill
- frontend-react-typescriptSkill
- git-githubSkill
- machine-learningSkill
- observabilitySkill
- performance-optimizationSkill
- portfolio-readinessSkill
- project-bootstrapSkill
- project-knowledgeSkill
- python-apiSkill
- python-environmentSkill
- rag-ocr-llmSkill
- release-engineeringSkill
- reusable-componentsSkill
- security-secretsSkill
- supply-chain-securitySkill
- testing-qualitySkill
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
- Distinctive: line 10
Use this skill when:
- Very specific: line 24
Look for uv.lock, poetry.lock, Pipfile.lock, environment.yml, requirements.txt, pyproject.toml.
- Very specific: line 26
Run python -c "import sys.
- Very specific: line 57
Detect Version: Read target Python version (3.11, 3.12).
- Very specific: line 58
Detect Toolchain: Check for existing lockfiles (uv.lock, poetry.lock).
- Distinctive: line 59
Respect Mature Projects: If a project heavily relies on Poetry or Conda, use that toolchain unless requested to migrate.
- Very specific: line 61
Create Project-Local
.venv: Always create .venv directly in the project root. - Very specific: line 63
Pin Python Version: Write exact minor version to .python-version (e.g.
- Very specific: line 64
Maintain Lockfile: Keep uv.lock synchronized and committed to version control.
- Very specific: line 65
Separate Dependencies: Put testing, linting, and formatting tools under [project.optional-dependencies] dev = [...].
- Very specific: line 68
Never Use Unmanaged
pip: Use uv add or .venv/bin/pip. - Very specific: line 72
Exclude
.venvfrom Git: Ensure .venv is in .gitignore.
≈ “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.
Files
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 (
uvby default; preservingconda/poetry/pipwhen mature). - Diagnosing global package pollution, interpreter mismatches, or lockfile desynchronization.
- Migrating legacy
requirements.txtorPipfileprojects to modernpyproject.toml+uv.lock.
2. What Should I Inspect First?
- Python Version Requirements:
- Inspect
.python-version,pyproject.toml(requires-python = ">=3.11"), orruntime.txt.
- Inspect
- Existing Package Manager & Toolchain:
- Look for
uv.lock,poetry.lock,Pipfile.lock,environment.yml,requirements.txt,pyproject.toml.
- Look for
- Active Interpreter Location:
- Run
python -c "import sys; print(sys.executable)"to confirm if it points inside.venv/or system Python.
- Run
- IDE Interpreter Settings:
- Inspect
.vscode/settings.jsonfor"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python"(orScripts/python.exe).
- Inspect
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 IsolationThe 18-Step Standard Environment Protocol
- Detect Version: Read target Python version (
3.11,3.12). - Detect Toolchain: Check for existing lockfiles (
uv.lock,poetry.lock). - Respect Mature Projects: If a project heavily relies on Poetry or Conda, use that toolchain unless requested to migrate.
- Default to
uvfor New Projects:uvis the standard modern fast package manager. - Create Project-Local
.venv: Always create.venvdirectly in the project root. - Create or Maintain
pyproject.toml: Single source of truth for build backend, metadata, and dependencies. - Pin Python Version: Write exact minor version to
.python-version(e.g.3.12). - Maintain Lockfile: Keep
uv.locksynchronized and committed to version control. - Separate Dependencies: Put testing, linting, and formatting tools under
[project.optional-dependencies] dev = [...]. - Never Install Globally: Reject any bare
pip installtargeting/usr/bin/pythonor global AppData. - Never Mix Project Dependencies: Each project must have its own dedicated
.venv. - Never Use Unmanaged
pip: Useuv addor.venv/bin/pip. - Use
uv addfor Project Dependencies: Automatically updatespyproject.tomlanduv.lock. - Use
uv syncfor Synchronization: Synchronizes environment state cleanly to match lockfile. - Use
uv runfor Command Execution: Runs test runners and scripts inside the managed environment automatically. - Exclude
.venvfrom Git: Ensure.venvis in.gitignore. - Verify IDE Interpreter: Configure
.vscode/settings.jsonto point to.venv. - 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 -vProtocol 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; fiProtocol 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_envProtocol 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 pytest4. What Decisions Should I Make?
| Scenario | Decision Rule |
| New Python Project | Always use uv + pyproject.toml + uv.lock. |
| Existing Stable Poetry / Conda | Keep existing toolchain. Do not force-migrate without user request. |
Legacy requirements.txt | If simple, keep requirements.txt or migrate to pyproject.toml if adding modern tooling like Ruff/Pytest. |
| Docker Container Build | Use uv pip install --system -r requirements.txt or multi-stage build with .venv. |
5. What Should I Avoid?
- NEVER run
pip installwithout an active.venv: This pollutes system libraries. - NEVER delete an existing
poetry.lockorPipfile.lockto forceuvwithout 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, notpydantic).
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 --versionDoes 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
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.

