Communitygithub.com

TerminalSkills/skills

Python パッケージのインストール、仮想環境の作成、依存関係のロック、Python バージョン管理を、pip、pip-tools、pipx、poetry、pyenv、virtualenv を置き換える1つの高速なコマンドラインツールで行います。Python プロジェクトのセットアップ、依存関係の追加やアップグレード、ロックファイルの作成、requirements.txt からの移行、インライン依存関係を含むスクリプトの実行、Python バージョンのインストール、uvx を使ったツールの実行、CI や Docker でのインストール高速化をユーザーが依頼した場合に使用します。

skills とは?

uv は Astral 社が開発した単一バイナリの高速な Python パッケージ兼プロジェクトマネージャーです。プロジェクト管理、単一ファイルスクリプト、コマンドラインツール (uvx)、Python インタプリタのインストール、pip 互換インターフェースなど、Python ワークフロー全体をカバーします。主な特徴として、クロスプラットフォームなロックファイル (uv.lock)、インライン依存関係を持つスクリプト、高速な依存関係解決とインストール、そして uv 単体で Python 自体をダウンロードできる点が挙げられます。このスキルは、uv を使ったプロジェクトの初期化、依存関係の追加・削除、ロックファイルの管理、スクリプトの実行、Python バージョンの切り替え、CI/CD パイプラインへの組み込みなどを、具体的なコマンド例とともに解説します。ユーザーはこのスキルを通じて、従来複数のツールを組み合わせる必要があった Python 環境構築の作業を、uv だけで効率的に実行できるようになります。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/TerminalSkills/skills/tree/HEAD/skills/uv

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

uv — 高速なPythonパッケージ・プロジェクトマネージャー

概要

uv は Astral 社が提供する単一バイナリで、Python ワークフロー全体をカバーします。クロスプラットフォームなロックファイル (uv.lock) を備えたプロジェクト、インライン依存関係を持つ単一ファイルスクリプト、コマンドラインツール (uvx)、Python インタプリタのインストール、およびドロップイン (そのまま使える) の uv pip インターフェースを提供します。必要に応じて Python 自体もダウンロードするため、マシンに必要なものは uv だけです。

使用方法

インストール

# パッケージマネージャーを使用
pipx install uv
brew install uv
winget install --id=astral-sh.uv -e

Astral 社はパッケージマネージャーのないマシン向けにスタンドアロンインストーラーも公開しています。インストールページ https://docs.astral.sh/uv/getting-started/installation/ に現在のコマンドとチェックサムがあります。

uv --version
uv self update     # スタンドアロンインストーラーのみ。それ以外はパッケージマネージャーでアップグレード

特定のリリースに固定するには、インストーラーURLにバージョンを指定します: https://astral.sh/uv/0.12.21/install.sh

プロジェクトを作成する

uv init dispatch-api               # パッケージ化されたアプリ: src/dispatch_api/、uv_build バックエンド、コンソールスクリプト
uv init --no-package cron-jobs     # フラットレイアウト (main.py あり、ビルドシステムなし)
uv init --lib geo-utils            # py.typed マーカー付きライブラリ
uv init --bare --python 3.12       # カレントディレクトリに pyproject.toml のみ作成

uv init は .python-version、README.md、.gitignore も書き込み、git を初期化します。--bare は pyproject.toml だけを作成するため、既存のリポジトリ内で使用するのに適しています。

依存関係を管理する

uv add 'httpx>=0.27' 'pydantic>=2.7,<3'     # 実行時依存関係
uv add --dev pytest ruff                    # dev グループ (本番環境には含めない)
uv add --group docs mkdocs                  # 任意の名前付き依存関係グループ
uv add --optional postgres 'psycopg[binary]'   # オプション依存関係: pip install dispatch-api[postgres]
uv add -r requirements.txt                  # 既存の requirements ファイルをインポート
uv remove httpx

uv lock --upgrade-package pydantic          # 制約内で1つのパッケージをバンプ
uv lock --upgrade                           # すべてをバンプ
uv tree --outdated --depth 1                # 新しいリリースがあるものを表示

最初の uv add で .venv/ と uv.lock が作成されます。変更のたびに pyproject.toml、ロックファイル、環境が同時に更新されます。

実行と同期

uv run pytest                        # 必要に応じてロックと同期を行い、.venv 内で実行
uv run python -m dispatch_api
uv run --with rich python -c "import rich"   # このコマンドのみ追加パッケージを使用

uv sync                              # すべて (dev グループも含む) をインストール
uv sync --locked                     # CI: uv.lock が pyproject.toml と一致しない場合は失敗
uv sync --frozen --no-dev            # 本番: uv.lock をそのまま使用、dev グループはスキップ
uv sync --extra postgres
uv lock --check                      # ロックファイルが古い場合は非ゼロで終了

アクティベーションは不要です。uv run は自動的にプロジェクト環境を見つけます。

インライン依存関係を持つスクリプト

uv init --script fetch-rates.py --python 3.12
uv add --script fetch-rates.py 'httpx<1' rich
uv run fetch-rates.py
uv lock --script fetch-rates.py      # 再現可能な実行のために fetch-rates.py.lock を作成

uv add --script はファイルの先頭にメタデータブロックを維持します:

# /// script
# requires-python = ">=3.12"
# dependencies = [
#     "httpx<1",
#     "rich>=15.0.0",
# ]
# ///

最初の行に #!/usr/bin/env -S uv run --script を追加し、chmod +x で直接実行可能にします。

ツール

uvx ruff check .                         # インストールせずに実行。uvx = uv tool run
uvx [email protected] check .                  # 特定のバージョン
uvx --from 'markitdown[pdf]' markitdown q3-board-report.pdf   # コマンド名がパッケージ名と異なる場合
uv tool install ruff                     # 恒久的に、PATH 上に分離してインストール
uv tool upgrade --all
uv tool list
uv tool uninstall ruff

インストールされたツールは uv tool dir --bin で表示されるディレクトリに配置されます。そのディレクトリが PATH にない場合、uv が警告を表示します。

Python バージョン

uv python install 3.12 3.13
uv python list --only-installed
uv python pin 3.12              # .python-version に書き込み
uv run --python 3.13 pytest     # 別のインタプリタで一時的に実行
uv python upgrade 3.12          # 3.12 の最新パッチリリースにアップグレード
uv venv --python 3.12           # .venv にプレーンな仮想環境を作成

指定方法: 3.12、3.12.3、>=3.11,<3.13、[email protected]、3.13t (フリースレッド) が使用可能です。uv は不足しているインタプリタを自動的にダウンロードします。--no-python-downloads を指定するとダウンロードを禁止できます。

pip 互換インターフェース

uv venv
uv pip install -r requirements.txt
uv pip compile requirements.in -o requirements.txt --universal
uv pip sync requirements.txt        # リストにないものは削除
uv pip install --python .venv/bin/python 'rich>=13'

CI と Docker

name: ci
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      - uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
        with:
          version: "0.12.21"
          enable-cache: true
      - run: uv python install
      - run: uv sync --locked --all-extras --dev
      - run: uv run pytest
FROM python:3.12-slim
COPY --from=ghcr.io/astral-sh/uv:0.12.21 /uv /uvx /bin/
WORKDIR /app
ENV UV_NO_DEV=1 UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy

# 依存関係を先にコピー。uv.lock が変更されるまでこのレイヤーは再利用される
RUN --mount=type=cache,target=/root/.cache/uv \
    --mount=type=bind,source=uv.lock,target=uv.lock \
    --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
    uv sync --locked --no-install-project

COPY . /app
RUN --mount=type=cache,target=/root/.cache/uv uv sync --locked
ENV PATH="/app/.venv/bin:$PATH"
CMD ["python", "-m", "dispatch_api"]

.dockerignore に .venv を追加してください。ホスト環境はイメージ内では動作しません。

例

例1: requirements.txt を使用するサービスをロック付きの uv プロジェクトに移行

依頼: 「dispatch-api リポジトリに requirements.txt と requirements-dev.txt があります。uv に移行してロックファイルを作成し、テストを実行できるようにしてください。」

cd dispatch-api
uv init --bare --python 3.12
uv python pin 3.12
uv add -r requirements.txt
sed '/^-r /d' requirements-dev.txt | uv add --dev -r -
uv run python -m pytest -q
uv run ruff check .

結果: pyproject.toml に5つの実行時パッケージと dev グループがリストされ、uv.lock が30のパッケージを固定し、チェックに合格します。出力の抜粋:

Initialized project `dispatch-api`
Pinned `.python-version` to `3.12`
 + uvicorn==0.34.0
 + pytest==8.3.4
 + ruff==0.8.6
1 passed, 1 warning in 0.12s
All checks passed!

例2: 自己完結型スクリプト

依頼: 「環境を設定せずに任意のサーバーにコピーして実行できるディスク使用量レポートスクリプトを作成してください。」

#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.12"
# dependencies = ["rich>=13"]
# ///
import shutil

from rich.console import Console
from rich.table import Table

usage = shutil.disk_usage("/")
table = Table(title="Disk usage")
table.add_column("Total GB")
table.add_column("Free GB")
table.add_row(f"{usage.total / 1e9:.0f}", f"{usage.free / 1e9:.0f}")
Console().print(table)
chmod +x disk-report.py
./disk-report.py

結果: uv は初回実行時に rich を使用したキャッシュ環境を構築し、テーブルを表示します。2回目以降は即座に実行されます。

      Disk usage
┏━━━━━━━━━━┳━━━━━━━━━┓
┃ Total GB ┃ Free GB ┃
┡━━━━━━━━━━╇━━━━━━━━━┩
│ 3936     │ 2211    │
└──────────┴─────────┘

ガイドライン

  • uv.lock と .python-version をコミットしてください。 uv.lock を手動で編集しないでください。pyproject.toml を変更するか、uv add、uv remove、uv lock を使用してください。
  • --locked または --frozen: --locked はロックファイルを検証し、古い場合は失敗するため CI に適しています。--frozen はチェックをスキップし、ファイルの内容をそのままインストールします。
  • uv sync は正確で、uv run はそうではありません。 uv sync はロックファイルにないパッケージ ( uv pip install で追加したものを含む) を削除します。uv run は不足しているものだけを追加します。
  • uv pip は探索によってターゲットを決定します: アクティブな VIRTUAL_ENV、次にカレントディレクトリまたは最も近い親ディレクトリの .venv を使用します。間違ったフォルダから実行すると、別の環境にインストールしてしまう可能性があります。スクリプトでは --python に環境パスを指定してください。
  • フラットプロジェクトと pytest: --bare または --no-package の場合、プロジェクト自体はインストールされないため、uv run pytest は ModuleNotFoundError で失敗する可能性があります。uv run python -m pytest を使用するか、[tool.pytest.ini_options] に pythonpath = ["."] を設定してください。
  • uv init のデフォルトはパッケージ化された src/ レイアウトです。 main.py を使用するスクリプトスタイルのプロジェクトには --no-package を指定してください。
  • 実験的なコマンド: uv format、uv check、uv audit は変更される可能性があるという警告を表示します。これらに基づいたパイプラインはまだ構築しないでください。
  • プライベートインデックス: [[tool.uv.index]] で宣言し、インデックス名に基づいた環境変数 (例: インデックス名が internal の場合、UV_INDEX_INTERNAL_USERNAME と UV_INDEX_INTERNAL_PASSWORD) で認証情報を渡します。これらをコミットしないでください。デフォルトの first-index 戦略は依存関係の混乱を防ぎます。unsafe-best-match は避けてください。
  • サプライチェーン: uv run、uvx、およびインラインメタデータを含むスクリプトはパッケージをダウンロードして実行します。信頼できないソースからのスクリプトは、実行前に依存関係リストを確認してください。
  • uv self update はスタンドアロンインストーラーでインストールした場合のみ機能します。
  • CI キャッシュ: キャッシュを保存する前に uv cache prune --ci を実行して、キャッシュを小さく保ってください。
  • 使用すべきでない場合: uv は Python パッケージインデックス、git、ローカルパスからインストールします。conda パッケージやシステムライブラリはインストールしないため、それらに依存するスタックには conda を引き続き使用してください。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

TerminalSkills/skills

>- Run GitHub Actions locally with act. Use when a user asks to test GitHub Actions workflows locally, debug CI pipelines without pushing, or run workflows offline.

TerminalSkills/skills

>- You are an expert in AG2 (formerly AutoGen), the open-source multi-agent conversation framework. You help developers build systems where multiple AI agents collaborate through structured conversations — with tool use, human-in-the-loop, code execution, group chat orchestration, and nested conversations — for complex tasks like software development, research, and data analysis.

TerminalSkills/skills

>- Generate short-form videos with AI — script writing, text-to-speech narration, stock footage selection, subtitle generation, and video assembly. Use when: creating TikTok/YouTube Shorts/Reels content, automating video production, building content pipelines.

TerminalSkills/skills

>- Animate 3D objects and characters in Blender with Python. Use when the user wants to keyframe properties, create armatures and rigs, set up IK/FK chains, animate shape keys for facial animation, edit F-Curves, use the NLA editor to blend actions, add drivers for expression-based animation, or script any animation workflow in Blender.

TerminalSkills/skills

>- Automate motion capture and tracking workflows in Blender with Python. Use when the user wants to import BVH or FBX mocap data, retarget motion to armatures, track camera or object motion from video, solve camera motion, clean up motion capture data, or script any tracking pipeline in Blender.

TerminalSkills/skills

>- You are an expert in Bolt.new by StackBlitz, the AI-powered full-stack development environment that runs entirely in the browser. You help developers go from idea to deployed app in minutes using natural language prompts — Bolt generates complete applications with frontend, backend, database, and deployment, all running in a WebContainer without local setup.

TerminalSkills/skills

>- Assists with using Bun as an all-in-one JavaScript/TypeScript runtime, package manager, bundler, and test runner. Use when building HTTP servers, managing packages, running tests, or migrating from Node.js. Trigger words: bun, bun serve, bun install, bun test, bun build, javascript runtime, bun runtime.

TerminalSkills/skills

>- Self-host customer support with Chatwoot. Use when a user asks to set up open-source customer support, add live chat without SaaS costs, build a multi-channel inbox, or deploy a free Intercom alternative.

TerminalSkills/skills

>- You are an expert in Chi, the lightweight, idiomatic Go HTTP router built on `net/http`. You help developers build composable HTTP services using Chi's middleware stack, route groups, URL parameters, sub-routers, and context-based request scoping — providing Express-like ergonomics while staying 100% compatible with Go's standard library.

TerminalSkills/skills

When the user wants to edit, review, or improve existing marketing copy. Also use when the user mentions 'edit this copy,' 'review my copy,' 'copy feedback,' 'proofread,' 'polish this,' 'make this better,' or 'copy sweep.' This skill provides a systematic approach to editing marketing copy through multiple focused passes.

TerminalSkills/skills

>- Add live chat and customer support with Crisp. Use when a user asks to add a chat widget, implement live customer support, set up a help desk, create a knowledge base, or add a chatbot to a website.

TerminalSkills/skills

>- Assists with building custom interactive data visualizations using D3.js. Use when creating charts, graphs, maps, force layouts, or hierarchical diagrams that require fine-grained control beyond what charting libraries provide. Trigger words: d3, data visualization, chart, svg, scales, force graph, treemap, choropleth.

TerminalSkills/skills

dbt (data build tool) transforms data in your warehouse using SQL SELECT statements. Learn project setup, models, tests, documentation, incremental materializations, and integration with data warehouses like PostgreSQL, BigQuery, and Snowflake.

TerminalSkills/skills

>- You are an expert in dlt, the open-source Python library for building data pipelines. You help developers load data from any API, file, or database into warehouses and lakes using simple Python decorators — with automatic schema inference, incremental loading, and built-in data contracts. dlt is the "requests library for data pipelines.

TerminalSkills/skills

Data Version Control for ML projects. Track large datasets and models alongside Git, build reproducible ML pipelines, and run experiments with metric comparison. Works with any storage backend including S3, GCS, Azure, and local filesystems.

TerminalSkills/skills

>- You are an expert in E2B, the cloud platform for running AI-generated code in secure sandboxes. You help developers give AI agents the ability to execute code, install packages, read/write files, and run long processes in isolated cloud environments — each sandbox is a lightweight VM that boots in ~150ms with full Linux, filesystem, and networking.

TerminalSkills/skills

>- Transcode, convert, edit, and process audio and video with FFmpeg. Use when a user asks to convert video formats (webm to mp4, mkv to mp4), extract audio from video, compress video files, trim or cut clips, concatenate videos, add subtitles, create thumbnails, apply filters, change resolution or bitrate, re-encode media, create GIFs from video, add watermarks, normalize audio, stream media, or build automated media processing pipelines.

TerminalSkills/skills

>- Create advanced animations with GSAP. Use when building complex timelines, scroll-driven animations, SVG morphing, text animations, or high-performance web animations beyond CSS capabilities.

TerminalSkills/skills

>- Generate deterministic MP4 videos from HTML, CSS, media, and seekable animations using HeyGen's HyperFrames framework. Use when someone asks to "render HTML to video", "make a video with HyperFrames", "create a programmatic video", "turn an animation into MP4", "build a launch/product video from HTML", "render GSAP/Lottie/Three.js to video", or set up an agent-driven video pipeline. Covers init/preview/render/add/lint/inspect commands, data-* timing attributes, animation adapters, and the component catalog.

TerminalSkills/skills

When the user wants to perform load testing, stress testing, or performance testing of APIs and websites using k6. Also use when the user mentions "k6," "load test," "performance test," "stress test," "spike test," "soak test," "thresholds," "virtual users," or "VUs." For browser-based testing, see selenium.

関連スキル