mcpField
P
python-coder

python-coder

github.com/majesticlabs-dev開発5052 回インストール7 週間前に更新
リポジトリ

python-coder について

python-coderは、Python 3.12以降を使う開発者向けのスキルです。最新のツール、言語パターン、型付け、コード品質の実践方法を案内します。

主な機能

  1. 01uvによるパッケージ管理例
  2. 02ruffのフォーマットとLint設定
  3. 03pyrightとmypyの型チェック設定
  4. 04パターンマッチと非同期処理の例
  5. 05テストとエラー処理の基準

活用シーン

  1. 01uvでPython 3.12プロジェクトを開始
  2. 02Lintと型チェックの設定
  3. 03非同期Pythonコードの作成
  4. 04型付けとテストの規約の適用

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/majesticlabs-dev/majestic-marketplace --skill python-coder

インストール後、Claude Code で/python-coderを入力して読み込まれたか確認します。

詳細

Python-Coder

モダンな Python 3.12 以降の開発パターン。

関連スキル(特定のニーズに応じて使用)

スキル使用する場面
fastapi-coderFastAPI サービスを構築するとき
django-coderDjango の Web アプリケーションを開発するとき
pytest-coder包括的なテストを作成するとき
python-debuggerPython コードをデバッグするとき

モダンなツールのクイックリファレンス

パッケージ管理(uv)
# Project setup
uv init my-project
uv add fastapi pydantic
uv add --dev pytest ruff mypy

# Run commands
uv run python main.py
uv run pytest
コード品質(ruff)
# pyproject.toml
[tool.ruff]
line-length = 100
target-version = "py312"

[tool.ruff.lint]
select = ["E", "F", "I", "UP", "B"]

[tool.ruff.format]
quote-style = "double"
型チェック(pyright/mypy)
[tool.pyright]
pythonVersion = "3.12"
typeCheckingMode = "strict"

Python 3.12 以降のパターン

パターンマッチング
match command:
    case {"action": "create", "item": item}:
        create(item)
    case {"action": "delete", "id": int(id)}:
        delete(id)
    case _:
        raise ValueError("Unknown command")
モダンな非同期処理
async def fetch_all(urls: list[str]) -> list[dict]:
    async with aiohttp.ClientSession() as session:
        tasks = [fetch(session, url) for url in urls]
        return await asyncio.gather(*tasks)
型ヒント
from typing import TypeVar, Protocol

T = TypeVar("T")

class Repository(Protocol[T]):
    def get(self, id: int) -> T | None: ...
    def save(self, entity: T) -> T: ...

動作基準

  • PEP 8 と ruff のフォーマットに準拠
  • コード全体に型ヒントを付与
  • pytest でテストを実施(カバレッジ目標:90% 超)
  • 外部依存関係より標準ライブラリを優先
  • カスタム例外を使用した包括的なエラー処理

コメント