home / skills / benchflow-ai / skillsbench / setup-env
This skill sets up Python project environments using uv, installing dependencies and running scripts for pyproject.toml or requirements.txt projects.
npx playbooks add skill benchflow-ai/skillsbench --skill setup-envReview the files below or copy the command above to add this skill to your agents.
---
name: setup-env
description: "When given a Python project codebase, this skill helps the agent to set up virtual environments, install dependencies, and run scripts."
---
# Skill: Use uv to manage Python environments
## Scope
1. Create a virtual environment
2. Install dependencies
3. Run Python scripts/commands
Assume `uv` is already available on PATH.
---
## Workflow selection
- If `pyproject.toml` exists: use **project workflow** (`uv sync`, `uv run`)
- Else if `requirements.txt` exists: use **pip workflow** (`uv venv`, `uv pip install -r ...`, `.venv/bin/python ...`)
- Else: stop with an error ("No pyproject.toml or requirements.txt found.")
---
## Project workflow (pyproject.toml)
### Create venv + install dependencies
From the repo root (where `pyproject.toml` is):
- `uv sync`
Notes:
- uv maintains a persistent project environment at `.venv` and installs deps there.
### Run scripts / commands (preferred)
Always run within the project environment:
- `uv run -- python <script.py> [args...]`
- `uv run -- python -m <module> [args...]`
Notes:
- `uv run` executes inside the project environment and ensures it is up-to-date.
---
## Pip workflow (requirements.txt)
### Create venv
From the repo root:
- `uv venv` # creates `.venv` by default
### Install dependencies
- `uv pip install -r requirements.txt`
### Run scripts / commands
Run using the venv interpreter directly (no activation required):
- `.venv/bin/python <script.py> [args...]`
- `.venv/bin/python -m <module> [args...]`
(uv will also automatically find and use the default `.venv` in subsequent invocations when you use `uv pip ...` commands.)
---
## Minimal sanity checks (optional)
- `test -x .venv/bin/python`
- `uv pip list` (verify packages installed)
This skill helps an agent set up Python project environments, install dependencies, and run scripts using the uv tool. It detects project layout and chooses the correct workflow for pyproject.toml or requirements.txt. The goal is to produce a reproducible .venv and run commands inside that environment reliably.
The skill inspects the repository root for pyproject.toml or requirements.txt and selects a workflow. For pyproject.toml it uses uv sync and uv run to manage a persistent project environment at .venv. For requirements.txt it creates a venv with uv venv, installs packages with uv pip install, and runs scripts with the .venv interpreter.
What if neither pyproject.toml nor requirements.txt exists?
The skill stops with an error: no detectable dependency file. Add one of these files or provide explicit install instructions.
Do I need to activate the virtualenv manually?
No. Prefer uv run -- ... or call .venv/bin/python directly. uv manages and uses .venv automatically for its commands.