From code-quality
PROACTIVE skill - Use for ANY task involving Python execution or bash/shell scripts that might run Python. Triggers include creating .py files, writing bash scripts, running terminal commands, automation scripts, CI/CD configs, Makefiles, dependency management, or ANY mention of python/pip/python3. Enforces uv CLI to replace ALL python/pip usage. CRITICAL - Activate BEFORE writing scripts or commands that could invoke Python.
npx claudepluginhub wgordon17/personal-claude-marketplace --plugin code-qualityThis skill is limited to using the following tools:
This skill ensures that all Python interactions utilize the `uv` CLI tool, a high-performance Python package and project manager that replaces pip, pipx, pyenv, and other tools.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
This skill ensures that all Python interactions utilize the uv CLI tool, a high-performance Python package and project manager that replaces pip, pipx, pyenv, and other tools.
YOU MUST FOLLOW THESE RULES FOR ALL PYTHON OPERATIONS:
python, python3, or python3.x directly - Always use uv runpip install - Use uv add (in projects) or uv pip install#!/usr/bin/env python3 - Use #!/usr/bin/env -S uv run or omit shebang entirely (uv run handles it)cat script.py | python3) - Use uv run script.pyThese rules apply to:
Requires uv. If not installed, check which uv and offer installation:
brew install uv or curl -LsSf https://astral.sh/uv/install.sh | shcurl -LsSf https://astral.sh/uv/install.sh | shpowershell -c "irm https://astral.sh/uv/install.ps1 | iex"Verify: uv --version. If user declines, fall back to legacy Python commands silently.
Step 7: Inform user of success "✓ uv has been successfully installed (version X.Y.Z). Proceeding with uv-based Python operations."
Replace all raw python/python3 invocations with uv run:
Legacy:
python script.py
python3 -m module
With uv:
uv run script.py
uv run python -m module
Replace pip commands with uv equivalents:
In projects (with pyproject.toml):
# Legacy: pip install requests
uv add requests
# Legacy: pip install -r requirements.txt
uv sync
Standalone installations:
# Legacy: pip install package
uv pip install package
Replace tool invocations with uvx for ephemeral execution:
Legacy:
black .
ruff check .
pytest
mypy src/
With uv:
uvx black .
uvx ruff check .
uvx pytest
uvx mypy src/
When creating Python scripts that require dependencies, use PEP 723 inline metadata to make them self-contained and portable:
# /// script
# dependencies = [
# "requests>=2.31.0",
# "rich>=13.0.0"
# ]
# ///
import requests
from rich.pretty import pprint
# Script code here...
Running uv run script.py automatically creates an isolated environment with the declared dependencies.
When to use PEP 723:
See references/pep723-examples.md for practical examples.
Replace pyenv or manual Python installations:
# Install Python 3.12
uv python install 3.12
# List installed versions
uv python list
# Pin project to specific version
uv python pin 3.12
When creating new Python projects:
# Legacy: mkdir project && cd project && python -m venv .venv
uv init my-project
cd my-project
This creates:
pyproject.toml with project metadata.python-version pinning Python versionCRITICAL: When writing bash scripts, automation scripts, or any shell commands that execute Python, use uv run:
❌ WRONG - Legacy bash script:
#!/bin/bash
python3 script.py
python3 -c "print('hello')"
cat script.py | python3
./script.py # with #!/usr/bin/env python3 shebang
pip install requests
✅ CORRECT - With uv:
#!/bin/bash
uv run script.py
uv run python -c "print('hello')"
uv run script.py
uv run script.py # No shebang needed, or use #!/usr/bin/env -S uv run
uv pip install requests # or uv add requests in projects
Examples of contexts where this applies:
When writing these scripts, ALWAYS think:
"Am I about to type
pythonorpip? Replace withuv runoruv add/uv pip install"
For a comprehensive mapping of legacy commands to uv equivalents, consult references/command-mappings.md.
Quick reference:
python script.py → uv run script.pypip install package → uv add package (projects) or uv pip install packagepip freeze > requirements.txt → uv lock (generates uv.lock)python -m venv .venv → uv venvpipx install tool → uv tool install toolpipx run tool → uvx tool# Create script with inline dependencies
cat > analyze.py << 'EOF'
# /// script
# dependencies = ["pandas", "matplotlib"]
# ///
import pandas as pd
import matplotlib.pyplot as plt
# Analysis code...
EOF
# Run it (uv handles dependencies automatically)
uv run analyze.py
# Initialize project
uv init data-pipeline
# Add dependencies
cd data-pipeline
uv add pandas numpy
uv add --dev pytest black
# Run the project
uv run python -m data_pipeline
# Run tests
uvx pytest
# One-time tool execution (no installation)
uvx ruff check .
# Permanent tool installation
uv tool install black
black . # Now available globally
CRITICAL: For comprehensive test execution guidance, see /test-runner skill
Quick reference for pytest with uv:
# Run tests in project environment
uv run pytest
# Re-run only failures (efficient!)
uv run pytest --lf -vv
# Run specific test
uv run pytest path/to/test.py::test_function -vv
# Run with ephemeral execution (no project)
uvx pytest
Quick reference for pre-commit with uv:
# Run all hooks
uv run pre-commit run --all-files
# Run specific hook
uv run pre-commit run ruff-format
# Run on specific files
uv run pre-commit run --files file1.py file2.py
Key principles:
pytest --lf for efficient failure re-runspytest -k "pattern" for targeted test selectionSee /test-runner skill for detailed patterns and workflows.
If uv commands fail:
uv --versionuv self updateIf a specific operation is not supported by uv, fall back to legacy commands with a clear explanation to the user.
uv is installedrequirements.txt can be migrated: uv add --requirements requirements.txtuv respects existing virtual environments but creates isolated ones for scriptsuvx caches tools for fast subsequent runsThe pyright language server for Python runs via uvx, using the same infrastructure as other Python tools. This powers Claude Code's LSP features for Python files.
How it works:
uvx --from pyright pyright-langserver --stdio~/.cache/uv/Clear pyright cache if issues occur:
uv cache clean pyright
LSP Operations for Python:
goToDefinition - Jump to function/class definitionsfindReferences - Find all usages of a symbolhover - Get type info and docstringsdocumentSymbol - List all functions/classes in fileworkspaceSymbol - Search for symbols by nameSee the lsp-navigation skill (/lsp-navigation skill) for comprehensive LSP usage guidance.
references/command-mappings.md - Comprehensive legacy → uv command tablereferences/pep723-examples.md - Practical inline dependency examples/lsp-navigation skill - LSP tool usage guide