Awesome-omni-skill python-setup-dev-environment
Set up and run a reproducible Python dev environment with uv, ruff, mypy, and VSCode.
git clone https://github.com/diegosouzapw/awesome-omni-skill
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/development/python-setup-dev-environment" ~/.claude/skills/diegosouzapw-awesome-omni-skill-python-setup-dev-environment && rm -rf "$T"
skills/development/python-setup-dev-environment/SKILL.mdSet Up a Python Dev Environment
Single-workflow guide for setting up and operating a reproducible Python development environment with
uv, ruff, mypy, and VSCode save-time guardrails.
When to Use This Skill
Use this skill when:
- Setting up a new Python project and standardizing execution with
uv run - Running lint/format/type-check in a consistent order before commit
- Troubleshooting VSCode save-time formatting behavior with Ruff
- Reproducing the same Python environment across team members and machines
- Migrating from ad-hoc
execution to explicitpython
-based workflowsuv
Related Skills
— Validate this skill document after editsskills-validate-skill
— Commit environment changes as atomic, reviewable unitsgit-commit-practices
— Ship setup changes through PR workflowgithub-pr-workflow
Dependencies
(required)uv
andruff
as dev dependenciesmypy- VSCode + Ruff extension (recommended)
Core Principles
- Single runtime entrypoint — Execute Python-related tasks through
to reduce environment drift (基礎と型)uv run - Fast feedback before commit — Run
andruff
in a repeatable sequence (成長の複利)mypy - Reproducible dependency state — Track environment state via
andpyproject.toml
(温故知新)uv.lock - Safe editor automation — Use explicit save-time actions to avoid destructive auto-fixes (ニュートラル)
- Incremental adoption — Start minimal (
) and add tools only when necessary (継続は力)uv + ruff + mypy
Workflow: Set Up and Operate Python Dev Environment
Step 1: Initialize and Pin Environment
Create project metadata and lock reproducible dependencies.
# Initialize (run at repository/project root) uv init . # Verify managed Python runtime uv run python --version # Install dependencies uv add --dev ruff mypy
Use when starting new Python work or normalizing an existing project.
Values: 基礎と型 / 継続は力
Step 2: Standardize Daily Command Entry
Use
uv run as the default command prefix for Python tooling.
# ✅ CORRECT - Run commands through uv-managed environment # Python execution uv run python path\to\script.py # Lint check uv run ruff check . # Format uv run ruff format . # Type check uv run mypy . # ❌ WRONG - Bypasses uv-managed runtime/dependencies python path\to\script.py
Use when avoiding local interpreter/version mismatch.
Values: ニュートラル / 基礎と型
Step 3: Run Quality Checks in a Safe Order
Follow a predictable order that minimizes churn and review noise. The order matters because it explains why each step comes next.
Why this sequence works:
- It clarifies why formatting must happen before lint checks.
- It clarifies why lint checks should run before type checks.
- It clarifies why type checks are the final gate before review.
| Phase | Command | Why |
|---|---|---|
| 1 | | Normalize formatting first |
| 2 | | Catch lint issues after formatting |
| 3 | | Validate type-level correctness last |
Use when preparing changes for commit or pull request.
Values: 継続は力 / 成長の複利
Step 4: Configure VSCode Save-Time Guardrails
Use Ruff formatter with explicit code actions to prevent unexpected rewrite behavior, and document why explicit actions are safer in mixed environments.
{ "[python]": { "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll": "explicit", "source.organizeImports": "explicit" }, "editor.defaultFormatter": "charliermarsh.ruff" } }
Use when save-time behavior causes unstable or surprising diffs.
Values: ニュートラル / 継続は力
Step 5: Verify Reproducibility
Confirm that another machine/session can recreate the same environment.
# Recreate environment from lock file uv sync # Re-run baseline checks uv run ruff check . uv run mypy .
Use when onboarding collaborators or validating CI parity.
Values: 温故知新 / 基礎と型
Step 6: Define Terms Before Team Rollout
Use explicit definitions so everyone reads commands and settings the same way.
- UV: A fast Python package and project manager used as the runtime entrypoint.
- LSP (Language Server Protocol): Editor protocol used for diagnostics and code actions.
- CI: Continuous Integration pipeline that should reproduce local checks.
Use when writing onboarding docs or handing off to another contributor.
Values: ニュートラル / 成長の複利
Best Practices
- Use
for every Python-related command in docs and scripts.uv run - Define dependency changes as atomic commits with
andpyproject.toml
.uv.lock - Apply
before lint and type checks to reduce noisy diffs.ruff format - Avoid automatic broad save-time fixes; keep save-time actions explicit.
- Consider adding project-specific exceptions only after baseline rules stabilize.
Common Pitfalls
-
Running bare
instead ofpythonuv run python
Fix: Replace command examples and scripts with
consistently.uv run ... -
Using aggressive save-time auto-fixes
Fix: Keep
andsource.fixAll
assource.organizeImports
.explicit -
Skipping lockfile updates after dependency changes
Fix: Use
/uv add
and commit resultinguv remove
changes.uv.lock
Anti-Patterns
- Adding convenience tools before team baseline is stable (e.g., early task-runner sprawl)
- Mixing multiple formatters for Python in the same repository
- Treating type checks as optional after lint passes
- Using
as a default workflow command without documentationuv pip install
Quick Reference
Setup
uv init . uv add --dev ruff mypy uv run python --version
Daily checks
uv run ruff format . uv run ruff check . uv run mypy .
Reproducibility
uv sync
Decision Table
| Situation | Action | Why |
|---|---|---|
| Need quick local check | | Catch style/lint issues fast |
| Need commit-ready diff | then | Format first, then enforce rules |
| Need confidence before PR | | Catch type-level regressions early |
FAQ
Q: Should we include poethepoet in this skill?
A: No. This workflow intentionally stays minimal; add task runners in a separate issue if needed.
Q: Why keep
as codeActionsOnSave
?explicit
A: It prevents unintended broad rewrites while still allowing controlled fixes.
Q: Is
allowed?uv pip install
A: As a rule, avoid it for normal workflow; prefer
uv add / uv remove to keep project state reproducible. If an exception is unavoidable, document the reason and command in README.md (or equivalent project docs).
Resources
Changelog
Version 1.0.0 (2026-02-14)
- Initial release for Issue #29