Synthèse automatique
Ce skill guide l'agent dans l'utilisation d'uv, le gestionnaire de paquets et de projets Python, en particulier la commande `uv run` pour exécuter du code dans un environnement de projet isolé.
Points forts
- Explique clairement pourquoi et quand préférer `uv run` à un `python` nu dans un projet disposant d'un pyproject.toml.
- Couvre les dépendances ponctuelles avec `--with` et les scripts à métadonnées inline (bloc `# /// script`).
- Fournit des commandes concrètes pour créer un projet, une bibliothèque ou initialiser un script avec une version de Python donnée.
- Rappelle le comportement important : un script à métadonnées inline ignore les dépendances du projet.
Limites
- Le document est tronqué : la liste complète des fichiers générés par `uv init` et la suite des workflows ne sont pas visibles.
- Ne traite pas en détail la migration depuis pip, poetry ou pipx, ni le verrouillage (lock) et la CI.
- Suppose que uv est déjà installé et ne décrit pas son installation.
À utiliser dès qu'un projet Python contient un pyproject.toml ou que l'on veut exécuter un script ou un outil CLI avec ses dépendances dans un environnement isolé.
À éviter sur des projets Python gérés par poetry, pip ou conda sans intention explicite de migrer vers uv.
Analyse de sécurité
SûrThe skill provides standard documentation and usage examples for the uv Python package manager. It does not instruct destructive actions, exfiltration, obfuscation, or disabling safety. Commands like 'uv run bash scripts/deploy.sh' are normal project workflows and not inherently risky.
Aucun point d'attention détecté
Comment cette analyse est faiteExemples
This repo has a pyproject.toml — run the test suite and the linter the right way instead of calling python directly.Run a quick Python one-liner that calls the GitHub API using httpx, but don't add httpx to the project's dependencies.Create a standalone script called fetch_data.py for Python 3.12 that uses requests and rich, with its dependencies declared inline, then run it.name: uv
description: This skill should be used when working with Python projects that use uv for package and project management. Use this skill for running Python scripts and CLI tools with uv run, managing dependencies, creating projects, handling virtual environments, and executing commands within isolated project environments. Essential for projects with pyproject.toml files.
uv - Fast Python Package and Project Manager
Overview
This skill provides guidance for using uv, an extremely fast Python package and project manager written in Rust. uv replaces pip, pip-tools, pipx, poetry, pyenv, virtualenv, and more while being 10-100x faster. The skill focuses particularly on uv run for executing code within isolated project environments.
When to Use This Skill
Use this skill when:
- Working in a Python project with a
pyproject.tomlfile - Running Python scripts or CLI tools that require dependencies
- Managing project dependencies and virtual environments
- Executing commands within an isolated project environment
- Creating new Python projects or initializing scripts
- Converting from pip, poetry, or other Python tooling to uv
Core Concept: uv run
The most important command in uv is uv run, which executes commands within an isolated project environment.
Why Use uv run
ALWAYS use uv run instead of bare python or direct script execution when:
- Running Python scripts that depend on project dependencies
- Executing Python CLI tools installed in the project
- Working within a uv-managed project (has
pyproject.toml) - Running commands that need access to the project's virtual environment
Key behavior: uv run automatically ensures the project environment is current before executing the command. It installs the project into .venv and keeps it isolated from the system Python.
Basic Usage
# Run a Python script
uv run example.py
# Run a Python module
uv run python -m mymodule
# Run a CLI tool from project dependencies
uv run pytest
uv run ruff check
uv run black .
# Run external commands that need project access
uv run bash scripts/deploy.sh
Adding Dependencies Per-Invocation
Use --with to include or override dependencies for a single execution without modifying pyproject.toml:
# Add a dependency temporarily
uv run --with httpx python -c "import httpx; print(httpx.__version__)"
# Specify version constraints
uv run --with 'httpx==0.26.0' python script.py
# Multiple dependencies
uv run --with httpx --with rich python script.py
This is useful for:
- Testing code with different dependency versions
- One-off operations requiring special packages
- Running scripts without permanently adding dependencies
Running Scripts with Inline Dependencies
Python scripts can declare their own dependencies using inline metadata. This creates isolated environments separate from the project:
# /// script
# dependencies = [
# "requests<3",
# "rich",
# ]
# requires-python = ">=3.12"
# ///
import requests
import rich
# Script code here...
Important: When a script has inline metadata, uv run uses ONLY those dependencies and ignores the project's dependencies, even when run inside a project directory.
Initialize a script with metadata:
# Create script with inline metadata
uv init --script example.py --python 3.12
# Add dependencies to script
uv add --script example.py 'requests<3' 'rich'
# Run the script (uses its own dependencies)
uv run example.py
Common Tasks and Workflows
Creating a New Project
# Create a new application project
uv init my-project
cd my-project
# Create a library project
uv init --lib my-library
# Create project in current directory
uv init
# Specify Python version
uv init --python 3.12
This creates:
pyproject.toml- Project configuration and dependencies.python-version- Python version specificationREADME.md- Basic documentationsrc/my_project/- Source code directory (for apps)
Managing Dependencies
# Add a dependency
uv add requests
# Add with version constraint
uv add 'httpx>=0.25,<0.27'
# Add development dependency
uv add --dev pytest
# Add optional dependency group
uv add --optional docs sphinx
# Remove a dependency
uv remove requests
# Update all dependencies
uv lock --upgrade
# Sync environment to match lockfile
uv sync
Virtual Environment Management
# uv automatically creates and manages .venv/
# Most operations don't require manual venv activation
# To manually create a venv (rarely needed)
uv venv
# To activate manually (usually unnecessary)
source .venv/bin/activate # Linux/Mac
.venv\Scripts\activate # Windows
Best practice: Use uv run instead of manually activating virtual environments. This ensures environment consistency and automatic updates.
Python Version Management
# Install a specific Python version
uv python install 3.12
# List available Python versions
uv python list
# Find Python installations
uv python find
# Pin project to specific Python version
uv python pin 3.12
Running Tools Without Installation
# Run a tool ephemerally (like pipx)
uvx ruff check .
uvx black --check .
# Equivalent to:
uv tool run ruff check .
# Install tool globally
uv tool install ruff
pip-Compatible Commands
uv provides drop-in pip replacements:
# Install packages (like pip install)
uv pip install requests
# Generate requirements.txt (like pip freeze)
uv pip freeze > requirements.txt
# Install from requirements.txt
uv pip install -r requirements.txt
# Compile dependencies (like pip-compile)
uv pip compile pyproject.toml -o requirements.txt
# Show dependency tree
uv pip tree
Decision Tree: Which Command to Use
Need to run code in this project?
→ Use uv run <command>
Need to add a package to this project?
→ Use uv add <package>
Need to run a tool once without installing?
→ Use uvx <tool> or uv tool run <tool>
Need to create a new project?
→ Use uv init [project-name]
Need to update dependencies to latest versions?
→ Use uv lock --upgrade
Need to sync environment after pulling changes?
→ Use uv sync
Need to install a specific Python version?
→ Use uv python install <version>
Working with legacy pip workflows?
→ Use uv pip commands as drop-in replacements
Key Differences from Other Tools
vs pip
- 10-100x faster due to Rust implementation
- Automatic virtual environment management
- Built-in lockfile support
- No need for pip-tools or virtualenv
vs poetry
- Faster dependency resolution
- Compatible with standard
pyproject.toml - Simpler command structure
- No separate
poetry.lockformat (usesuv.lock)
vs pipx
uvxprovides same functionality- Faster execution
- Better caching and deduplication
vs pyenv
uv pythonmanages Python versions- Integrated with project management
- Faster installation and switching
Best Practices
-
Always use
uv runin projects - Don't manually activate virtual environments; let uv handle environment management automatically. -
Commit lockfiles - Include
uv.lockin version control for reproducible builds. -
Pin Python versions - Use
uv python pinto specify project Python requirements. -
Use
--withfor experiments - Test dependencies temporarily without modifyingpyproject.toml. -
Leverage inline metadata for scripts - Single-file scripts should declare dependencies inline for portability.
-
Use
uvxfor one-off tools - Don't pollute project dependencies with tools you run occasionally. -
Let uv manage environments - Trust
uv syncto keep environments in sync; avoid manual pip installs in uv projects. -
Check
.python-versionfiles - Respect project Python version specifications.
Common Patterns
Running Tests
# Add pytest as dev dependency
uv add --dev pytest pytest-cov
# Run tests
uv run pytest
# Run with coverage
uv run pytest --cov
Linting and Formatting
# Add dev tools
uv add --dev ruff black mypy
# Run tools
uv run ruff check .
uv run black .
uv run mypy src/
Building and Publishing
# Build distributions
uv build
# Publish to PyPI
uv publish
# Publish to test PyPI
uv publish --index-url https://test.pypi.org/legacy/
Working with Scripts
# Create standalone script with dependencies
uv init --script analyze.py
uv add --script analyze.py pandas numpy
# Run script (uses its inline dependencies)
uv run analyze.py
# Lock script dependencies for reproducibility
uv lock --script analyze.py
Troubleshooting
Command not found after uv add
Problem: Added a package with a CLI tool, but command doesn't work.
Solution: Use uv run <command> to execute within project environment:
uv add ruff
uv run ruff check . # Not just "ruff check ."
Environment out of sync
Problem: Dependencies changed but environment hasn't updated.
Solution: Run uv sync to synchronize:
uv sync
Wrong Python version
Problem: Project requires different Python version.
Solution: Install and pin correct version:
uv python install 3.12
uv python pin 3.12
Script ignores project dependencies
Problem: Script with inline metadata doesn't use project packages.
Solution: This is intentional. Scripts with inline metadata are isolated. Either:
- Remove inline metadata to use project dependencies
- Add needed dependencies to script's inline metadata
References
For detailed command options and advanced usage, see references/cli_reference.md.
Du fichier au premier essai
Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.
Consulter la source et ses fichiers annexesCe téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.
1. Télécharger le fichier
Télécharger SKILL.mdDepuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/uv-fast-python-package-manager-msih95fo/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.
Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.
mkdir -p '.skill-downloads/uv-fast-python-package-manager-msih95fo' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/uv-fast-python-package-manager-msih95fo/download' --output '.skill-downloads/uv-fast-python-package-manager-msih95fo/SKILL.md.part' && mv '.skill-downloads/uv-fast-python-package-manager-msih95fo/SKILL.md.part' '.skill-downloads/uv-fast-python-package-manager-msih95fo/SKILL.md'2. Vérifier les prérequis
Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.
Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.
Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.
3. Charger la skill
Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.
Claude Code
test -f '.skill-downloads/uv-fast-python-package-manager-msih95fo/SKILL.md' && test -s '.skill-downloads/uv-fast-python-package-manager-msih95fo/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/uv' && cp -R '.skill-downloads/uv-fast-python-package-manager-msih95fo' '.claude/skills/uv'Cursor
test -f '.skill-downloads/uv-fast-python-package-manager-msih95fo/SKILL.md' && test -s '.skill-downloads/uv-fast-python-package-manager-msih95fo/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/uv' && cp -R '.skill-downloads/uv-fast-python-package-manager-msih95fo' '.cursor/skills/uv'Codex
test -f '.skill-downloads/uv-fast-python-package-manager-msih95fo/SKILL.md' && test -s '.skill-downloads/uv-fast-python-package-manager-msih95fo/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/uv' && cp -R '.skill-downloads/uv-fast-python-package-manager-msih95fo' '.agents/skills/uv'OpenSkills
OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.
Installation officielle d’OpenSkillsopenskills install './.skill-downloads/uv-fast-python-package-manager-msih95fo'openskills read 'uv-fast-python-package-manager-msih95fo'La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.
Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.
openskills syncMode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.
4. Faire un premier essai
Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :
Lis .skill-downloads/uv-fast-python-package-manager-msih95fo/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.
Bonnes pratiques React Hook Form
Developpement
Maîtrisez React Hook Form : évitez les anti-patterns, gérez les abonnements, et traitez correctement reset, dirty state et entrées contrôlées.
Migration Emotion vers Mantine
Developpement
Migrer les styled-components Emotion vers des composants Mantine avec style props et modules CSS. Pour convertir .styled.tsx ou supprimer les imports @emotion.
Détecteur de dérive de périmètre
Developpement
Analyse les diffs git par rapport à une intention pour détecter la dérive de périmètre, fichiers non liés et PR trop larges, puis suggère de garder, diviser ou justifier.