python-design-modularity
Pythonのコード設計において、モジュール分割やリファクタリング、アーキテクチャレビューを行う際に、複雑な依存関係や巨大なクラス、深い継承構造などの問題を解決し、安全な構造変更を計画・実行するSkill。
📜 元の英語説明(参考)
Use when designing module boundaries, planning refactors, or reviewing architecture in Python codebases. Also use when facing tangled dependencies, god classes, deep inheritance hierarchies, unclear ownership, or risky structural changes.
🇯🇵 日本人クリエイター向け解説
Pythonのコード設計において、モジュール分割やリファクタリング、アーキテクチャレビューを行う際に、複雑な依存関係や巨大なクラス、深い継承構造などの問題を解決し、安全な構造変更を計画・実行するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o python-design-modularity.zip https://jpskill.com/download/10635.zip && unzip -o python-design-modularity.zip && rm python-design-modularity.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/10635.zip -OutFile "$d\python-design-modularity.zip"; Expand-Archive "$d\python-design-modularity.zip" -DestinationPath $d -Force; ri "$d\python-design-modularity.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
python-design-modularity.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
python-design-modularityフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Python の設計とモジュール性
概要
読みやすさを第一に考えた設計と、明示的なモジュール契約。 制御フロー、データの移動、および所有権の境界を可視化し、コードの保守性と変更の安全性を維持します。
これらの推奨事項は、推奨されるデフォルトとして扱ってください。 デフォルトがプロジェクトの制約と矛盾する場合は、より適切な代替案を提案し、トレードオフと補償的な制御(テスト、可観測性、移行、ロールバック)を明示してください。
使用場面
- モジュール、パッケージ、または所有権の境界の再構築
- ゴッドクラスや深くネストされた階層の分割
- コンポジションと継承の選択
- Functional Core / Imperative Shell の分離の適用
- 複数のモジュールに影響を与えるリファクタリングの計画
- コードの読みやすさまたはアーキテクチャの明確さのレビュー
使用しない場面:
- 純粋なパフォーマンス最適化 —
python-concurrency-performanceを参照 - エラー処理と回復力パターン —
python-errors-reliabilityを参照 - 型契約とプロトコル設計 —
python-types-contractsを参照 - メンテナンス期間のない、使い捨てのスクリプトまたは一時的なコード
クイックリファレンス
- 制御フローとデータの移動を明示的に保ちます。
- モジュールの所有権と不変条件を明示的に保ちます。
- デフォルトではコンポジションを優先します。
- テスト容易性と関心の分離が向上する場合は、Functional Core / Imperative Shell を適用します。
- 動作の変更と構造のリファクタリングを分離します — 同じコミットに混在させないでください。
よくある間違い
- 動作と構造の同時リファクタリング — 2種類のリスクを混同し、ロールバックを困難にし、レビューを不明瞭にします。 一方を行ってから、もう一方を行います。
- 最初に継承に手を伸ばす — 深い階層は無関係な関心を結合し、推論を非ローカルにします。 デフォルトでコンポジションを使用します。「is-a」の関係が本当に安定している場合にのみ継承します。
- 隠れたモジュールの結合 — 境界を越えて実装の詳細をインポートすると、目に見えない契約が作成されます。 明示的なパブリック API を公開し、内部をプライベートに保ちます。
- 時期尚早な抽象化 — 2回目または3回目の具体的な使用の前に共有インターフェースを抽出すると、元に戻すのにコストがかかる誤った抽象化につながります。 重複が発生して実際の継ぎ目が明らかになるまで待ちます。
- Functional Core / Imperative Shell の分割の無視 — I/O とビジネスロジックを混在させると、単体テストが困難になり、変更の影響範囲が拡大します。 副作用をエッジにプッシュします。
スコープに関する注意
- これらの推奨事項は、普遍的なルールではなく、一般的なケースに対する推奨されるデフォルトとして扱ってください。
- デフォルトがプロジェクトの制約と矛盾する場合、または結果を悪化させる場合は、より適切な代替案を提案し、このケースでそれが優れている理由を説明してください。
- 逸脱する場合は、トレードオフと補償的な制御(テスト、可観測性、移行、ロールバック)を明示してください。
呼び出し通知
- このスキルが名前
python-design-modularityで呼び出されていることをユーザーに通知します。
参考文献
references/design-rules.mdreferences/readability-and-complexity.mdreferences/module-boundaries.mdreferences/functional-core-shell.mdreferences/refactor-guidelines.md
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Python Design and Modularity
Overview
Readability-first design with explicit module contracts. Keep control flow, data movement, and ownership boundaries visible so code stays maintainable and safe to change.
Treat these recommendations as preferred defaults. When a default conflicts with project constraints, suggest a better-fit alternative and call out tradeoffs and compensating controls (tests, observability, migration, rollback).
When to Use
- Restructuring modules, packages, or ownership boundaries
- Breaking apart god classes or deeply nested hierarchies
- Choosing between composition and inheritance
- Applying Functional Core / Imperative Shell separation
- Planning a refactor that touches multiple modules
- Reviewing code for readability or architectural clarity
When NOT to use:
- Pure performance optimization — see
python-concurrency-performance - Error handling and resilience patterns — see
python-errors-reliability - Type contracts and protocol design — see
python-types-contracts - One-off script or throwaway code with no maintenance horizon
Quick Reference
- Keep control flow and data movement explicit.
- Keep module ownership and invariants explicit.
- Prefer composition by default.
- Apply Functional Core / Imperative Shell where it improves testability and separation of concerns.
- Separate behavior changes from structural refactors — never mix in the same commit.
Common Mistakes
- Refactoring behavior and structure simultaneously — conflates two kinds of risk, makes rollback harder, and obscures review. Do one, then the other.
- Reaching for inheritance first — deep hierarchies couple unrelated concerns and make reasoning non-local. Default to composition; inherit only when the "is-a" relationship is genuinely stable.
- Hidden module coupling — importing implementation details across boundaries creates invisible contracts. Expose explicit public APIs and keep internals private.
- Premature abstraction — extracting a shared interface before the second or third concrete use leads to wrong abstractions that are expensive to undo. Wait for duplication to reveal the real seam.
- Ignoring the Functional Core / Imperative Shell split — mixing I/O with business logic makes unit testing painful and increases the blast radius of changes. Push side effects to the edges.
Scope Note
- Treat these recommendations as preferred defaults for common cases, not universal rules.
- If a default conflicts with project constraints or worsens the outcome, suggest a better-fit alternative and explain why it is better for this case.
- When deviating, call out tradeoffs and compensating controls (tests, observability, migration, rollback).
Invocation Notice
- Inform the user when this skill is being invoked by name:
python-design-modularity.
References
references/design-rules.mdreferences/readability-and-complexity.mdreferences/module-boundaries.mdreferences/functional-core-shell.mdreferences/refactor-guidelines.md