基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/bobmatnyc/claude-mpm-agents --skill python-di-soa-patterns命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
Production-readiness process checklist covering the code-production pipeline — research, architecture, implementation, tests, critic review, and security gates
Severity-tagged code review rubric (CRITICAL/HIGH/MEDIUM/LOW) used by the code-critic agent to produce APPROVE/WARN/BLOCK verdicts with evidence-backed findings
Audit whether a test suite actually detects regressions (not just whether it runs) by introducing small code mutations and measuring how many your tests catch. Advisory and on-demand — not a blocking CI gate.
| name | python-di-soa-patterns |
| description | DI/SOA decision tree with full code examples for Python architecture decisions |
| version | 1.0.0 |
| category | toolchain |
| author | Claude MPM Team |
| license | MIT |
| progressive_disclosure | {"entry_point":{"summary":"Decision tree and code examples for choosing between DI/SOA and lightweight script patterns in Python","when_to_use":"When deciding on architecture patterns for a new Python project or module","quick_start":"Use the decision tree to determine if DI/SOA or lightweight patterns fit your use case"}} |
| context_limit | 700 |
| tags | ["python","architecture","dependency-injection","service-oriented","design-patterns","decision-tree"] |
| requires_tools | [] |
Benefits: Testability (mock dependencies), maintainability (clear separation), extensibility (swap implementations)
Benefits: Less boilerplate, faster development, easier to understand
Is this a long-lived service or multi-step process?
YES -> Use DI/SOA (testability, maintainability matter)
NO |
Does it need mock testing or swappable dependencies?
YES -> Use DI/SOA (dependency injection enables testing)
NO |
Is it a one-off script or simple automation?
YES -> Skip DI/SOA (keep it simple, minimize boilerplate)
NO |
Will it grow in complexity over time?
YES -> Use DI/SOA (invest in architecture upfront)
NO -> Skip DI/SOA (don't over-engineer)
Lightweight Script Pattern:
# Simple CSV processing script - NO DI needed
import pandas as pd
from pathlib import Path
def process_sales_data() -> :
df = pd.read_csv(input_path)
df[] = df[] * df[]
summary = df.groupby().agg({
: ,
:
}).reset_index()
summary.to_csv(output_path, index=)
()
__name__ == :
process_sales_data(
Path(),
Path()
)
Same Task with Unnecessary DI/SOA (Over-Engineering):
# DON'T DO THIS for simple scripts!
from abc import ABC, abstractmethod
from dataclasses import dataclass
import pandas as pd
from pathlib import Path
class IDataReader(ABC):
@abstractmethod
def read(self, path: Path) -> pd.DataFrame: ...
class IDataWriter(ABC):
@abstractmethod
def write(self, df: pd.DataFrame, path: Path) -> None: ...
class CSVReader(IDataReader):
def read(self, path: Path) -> pd.DataFrame:
return pd.read_csv(path)
class CSVWriter(IDataWriter):
def write(self, df: pd.DataFrame, path: Path) -> None:
df.to_csv(path, index=False)
@dataclass
class SalesProcessor:
reader: IDataReader
writer: IDataWriter
def process(self, input_path: Path, output_path: Path) -> None:
df = self.reader.read(input_path)
df['total'] = df['quantity'] * df['price']
summary = df.groupby('category').agg({
'total': 'sum',
'quantity': 'sum'
}).reset_index()
self.writer.write(summary, output_path)
# Too much boilerplate for a simple script!
if __name__ == "__main__":
processor = SalesProcessor(
reader=CSVReader(),
writer=CSVWriter()
)
processor.process(
Path("data/sales.csv"),
Path("data/summary.csv")
)
Key Principle: Use DI/SOA when you need testability, maintainability, or extensibility. For simple scripts, direct calls and minimal abstraction are perfectly fine.