uv-worktree-venv-fallthrough

Diagnoses uv run PYTHONPATH fallthrough issues in fresh git worktrees with empty virtual environments.

Updated Nov 18, 2025
One-click install
npx skills add https://github.com/cajias/claude-skills --skill uv-worktree-venv-fallthrough
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: uv-worktree-venv-fallthrough
Source: https://github.com/cajias/claude-skills/tree/main/plugins/python-tooling/skills/uv-worktree-venv-fallthrough
Command: npx skills add https://github.com/cajias/claude-skills --skill uv-worktree-venv-fallthrough

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill fixes confusing Python test and tooling failures that happen in fresh git worktrees when uv run silently falls back to a system-installed command instead of the project virtual environment.

Core Features & Use Cases

  • Diagnose environment bugs: Identify cases where pytest, ruff, mypy, or similar tools resolve to the wrong Python interpreter.
  • Repair fresh worktrees: Restore the expected virtual environment in uv-managed repositories with a single sync step before running tests.
  • Worktree and agent workflows: Prevent parallel agents and isolated worktrees from reporting phantom import errors, version mismatches, or collection failures.
  • Use Case: A newly created worktree shows ModuleNotFoundError or old-Python errors during uv run pytest, and this Skill guides the fix so the correct local venv is used.

Quick Start

Tell Claude to diagnose the worktree Python environment, run uv sync with dev dependencies first, and verify that uv run resolves pytest from the worktree’s .venv instead of the system PATH.

Frequently Asked Questions about uv-worktree-venv-fallthrough

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does uv run pytest fail with ModuleNotFoundError in a fresh git worktree?

uv run pytest fails in a fresh git worktree because the virtual environment is empty, causing uv to fall through to the system PATH and resolve the wrong Python interpreter. Running uv sync first restores the local .venv with pinned dependencies to fix the phantom failures.

How do I fix uv run resolving the wrong Python interpreter in isolated worktrees?

To fix uv run resolving the wrong Python interpreter in isolated worktrees, run uv sync with dev dependencies to populate the worktree's .venv. This ensures pytest, ruff, and mypy resolve from the local virtual environment instead of falling back to system PATH.

Do I need to run uv sync before executing pytest in a new git worktree?

Yes, you need to run uv sync before executing pytest in a new git worktree. A completed uv sync populates the empty virtual environment with the project's pinned Python and dependencies, preventing uv run from falling through to the system PATH and causing phantom test failures.

What causes phantom Python test failures in parallel agent worktree setups?

Phantom Python test failures in parallel agent setups happen when fresh git worktrees have empty virtual environments, causing uv run to fall back to system-installed commands. This leads to import errors, version mismatches, and collection failures from resolving the wrong Python interpreter.

Can I use this approach to fix ruff and mypy resolution errors in uv-managed repositories?

Yes, this approach fixes ruff and mypy resolution errors in uv-managed repositories. By running uv sync to populate the worktree's .venv, uv run resolves ruff and mypy from the local virtual environment with the project's pinned Python and dependencies instead of the system PATH.

What are the limitations of fixing uv worktree fallthrough with uv sync?

The limitation of fixing uv worktree fallthrough is that it requires a completed uv sync in the worktree first. If the virtual environment is not fully populated with dev dependencies, uv run will continue falling through to the system PATH and resolving the wrong Python interpreter.