Loading...
Loading...
Modern Python development with uv (10-100x faster package manager) and ruff (extremely fast linter/formatter). Use when managing Python projects, dependencies, virtual environments, installing packages, linting code, or formatting Python files. Triggers on phrases like "uv install", "ruff check", "python package manager", "format python code", or working with pyproject.toml files.
npx skill4agent add tenequm/claude-plugins uv-ruff-python-tools# macOS/Linux - standalone installer
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows - PowerShell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# With Homebrew
brew install uv
# With pipx
pipx install uv
# Verify installation
uv version# With uv (recommended)
uv tool install ruff
# With pip
pip install ruff
# With Homebrew
brew install ruff
# Verify installation
ruff version# Create a new project
uv init my-project
cd my-project
# Add dependencies
uv add requests pandas numpy
# Add development dependencies
uv add --dev pytest black ruff
# Install all dependencies
uv sync
# Run a script in the project environment
uv run python main.py
# Run a tool (like pytest)
uv run pytest
# Update dependencies
uv lock --upgrade
uv sync# Check for linting errors
ruff check .
# Auto-fix linting errors
ruff check --fix .
# Format code
ruff format .
# Check formatting without changes
ruff format --check .
# Watch mode (continuous linting)
ruff check --watch
# Lint and format in one command
ruff check --fix . && ruff format .# Install Python versions
uv python install 3.11 3.12 3.13
# List installed Python versions
uv python list
# Pin Python version for project
uv python pin 3.12
# Use specific Python version
uv run --python 3.11 python script.pypippip-toolspipxpoetrypyenvvirtualenvuv.lockFlake8Blackisortpyupgradeautoflake# Quick tool execution (like npx or pipx)
uvx ruff check .
uvx black .
uvx pytest
# Build and publish packages
uv build
uv publish
# Pip-compatible interface (drop-in replacement)
uv pip install requests
uv pip freeze > requirements.txt
uv pip compile requirements.in
uv pip sync requirements.txt
# Create virtual environment
uv venv
source .venv/bin/activate # Linux/macOS
.venv\Scripts\activate # Windows
# Run scripts with inline dependencies
uv add --script my_script.py requests
uv run my_script.py# Enable specific rule sets
ruff check --select E,W,F,I .
# Ignore specific rules
ruff check --ignore E501 .
# Show fixes that will be applied
ruff check --diff .
# Format with preview features
ruff format --preview .
# Check specific files
ruff check src/main.py tests/test_main.py
# Output formats
ruff check --output-format json .
ruff check --output-format github .[project]
name = "my-project"
version = "0.1.0"
description = "My Python project"
requires-python = ">=3.11"
dependencies = [
"requests>=2.31.0",
"pandas>=2.0.0",
]
[project.optional-dependencies]
dev = [
"pytest>=7.0.0",
"ruff>=0.1.0",
]
[tool.uv]
dev-dependencies = [
"pytest>=7.0.0",
"ruff>=0.1.0",
]
[tool.uv.sources]
# Use specific package sources if needed[tool.ruff]
# Set line length
line-length = 88
indent-width = 4
target-version = "py311"
# Exclude directories
exclude = [
".git",
".venv",
"__pycache__",
"build",
"dist",
]
[tool.ruff.lint]
# Enable rule sets
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # Pyflakes
"I", # isort
"B", # flake8-bugbear
"UP", # pyupgrade
]
# Ignore specific rules
ignore = [
"E501", # line too long (handled by formatter)
]
# Allow auto-fix for all enabled rules
fixable = ["ALL"]
unfixable = []
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"] # Allow unused imports
"tests/*" = ["S101"] # Allow assert statements
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
line-ending = "auto"# .pre-commit-config.yaml
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.8
hooks:
- id: ruff
args: [--fix]
- id: ruff-formatname: Lint and Test
on: [push, pull_request]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install dependencies
run: uv sync
- name: Lint with ruff
run: uv run ruff check .
- name: Format check with ruff
run: uv run ruff format --check .
- name: Run tests
run: uv run pytest# Clear cache
uv cache clean
# Reinstall Python
rm -r "$(uv python dir)"
uv python install 3.12
# Reset lockfile
rm uv.lock
uv lock# Clear cache
ruff clean
# Show current settings
ruff check --show-settings
# List all available rules
ruff rule --all
# Explain a specific rule
ruff rule E501