Scaffold python tool
Skill turntuptechnologies-ai/skills/skills/scaffold-python-tool
Python の CLI ツールやバックエンドサービスを新規に作るとき。「Python のツールを作る」「uv でプロジェクト初期化」等で使う。uv + ruff + mypy(strict) + pytest の構成で雛形を用意する(任意で FastAPI / SQLAlchemy / click)。土台は new-project-init を先に使う。From its SKILL.md
npx -y skills add turntuptechnologies-ai/skills --skill scaffold-python-toolAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.1 KB, ~1.0k tokens by cl100k_base, as published. Nobody here has run it
Python ツール scaffold(uv + ruff + mypy + pytest)
src レイアウトの Python プロジェクトを雛形生成する。
stack
- Python 3.12+、パッケージ管理 uv、ビルド hatchling
- レイアウト: src/(
src/<pkg>/) - lint/format: ruff、型チェック: mypy(strict)、テスト: pytest(+
pytest-asyncio) - よく足すもの:
click(CLI) /pydantic/fastapi+uvicorn/sqlalchemy(async)+alembic/httpx/pyyaml
手順
- 初期化
uv init --package --name <pkg> . # src レイアウトのパッケージとして初期化 - 依存を追加(必要なものだけ)
uv add pydantic click pyyaml httpx # 例 uv add fastapi "uvicorn[standard]" # API を作るなら uv add sqlalchemy aiosqlite alembic # DB を使うなら(PostgreSQL は asyncpg) uv add --dev ruff mypy pytest pytest-asyncio pyproject.tomlに設定を足す[project.scripts] <pkg> = "<pkg>.cli:main" # CLI なら [tool.ruff] target-version = "py312" src = ["src", "tests"] [tool.ruff.lint] select = ["E", "F", "W", "I", "UP", "B", "SIM", "TCH"] [tool.mypy] python_version = "3.12" strict = true packages = ["<pkg>"] mypy_path = "src" [tool.pytest.ini_options] testpaths = ["tests"]- ディレクトリ:
src/<pkg>/(cli.py,__init__.py等)、tests/。 - 動作確認
(uv run ruff format . && uv run ruff check . && uv run mypy src/ && uv run pytestpre-pr-checksSkill がこの一括実行を担う)
ルール・コツ
- mypy は strict 前提で書く。型注釈を最初から付ける。
- async コードのテストは
pytest-asyncio。設定はasyncio_mode = "auto"が楽。 - DB マイグレーションは alembic(
alembic init→alembic.iniのsqlalchemy.urlを設定/環境変数化)。 - 秘密情報は
.env+python-dotenv、コミットするのは.env.exampleのみ。 - ランタイムは mise で固定、sudo は使わない。
補足
- ライセンスは permissive(MIT 等)前提。GPL 系依存は避ける。
完了条件
以下を全て満たしたら完了。満たせない項目があれば、黙って省略せず理由を報告する。
- src レイアウト(
src/<pkg>/,tests/)でuv syncが通る - pyproject に ruff / mypy(strict) / pytest の設定が入っている
-
uv run ruff format . && uv run ruff check . && uv run mypy src/ && uv run pytestが通る - CLI がある場合
[project.scripts]が定義されている -
.envはコミット対象外、.env.exampleのみ(実値なし)
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.