jpskill.com
🛠️ 開発・MCP コミュニティ

component-model-analysis

Evaluate extensibility patterns, abstraction layers, and configuration approaches in frameworks. Use when (1) assessing base class/protocol design, (2) understanding dependency injection patterns, (3) evaluating plugin/extension systems, (4) comparing code-first vs config-first approaches, or (5) determining framework flexibility for customization.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o component-model-analysis.zip https://jpskill.com/download/18853.zip && unzip -o component-model-analysis.zip && rm component-model-analysis.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/18853.zip -OutFile "$d\component-model-analysis.zip"; Expand-Archive "$d\component-model-analysis.zip" -DestinationPath $d -Force; ri "$d\component-model-analysis.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して component-model-analysis.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → component-model-analysis フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

コンポーネントモデル分析

拡張性パターンと設定アプローチを評価します。

プロセス

  1. 基底クラスの特定 — BaseLLM、BaseTool、BaseAgent などを見つけます。
  2. 抽象化深度の分類 — 厚い(多くのロジック)か薄い(インターフェース)か。
  3. DI パターンの分析 — コンストラクタ、ファクトリ、レジストリ、コンテナ。
  4. 設定の文書化 — コードファースト、設定ファースト、またはハイブリッド。

抽象化レイヤーの評価

厚い抽象化

class BaseLLM(ABC):
    """Many methods, lots of inherited behavior"""

    def __init__(self, model: str, temperature: float = 0.7):
        self.model = model
        self.temperature = temperature
        self._cache = {}

    def generate(self, prompt: str) -> str:
        cached = self._check_cache(prompt)
        if cached:
            return cached
        result = self._generate_impl(prompt)
        self._update_cache(prompt, result)
        return self._postprocess(result)

    @abstractmethod
    def _generate_impl(self, prompt: str) -> str: ...

    def _check_cache(self, prompt): ...
    def _update_cache(self, prompt, result): ...
    def _postprocess(self, result): ...
    def stream(self, prompt): ...
    def batch(self, prompts): ...
    # ... 15+ more methods

特徴:

  • 深い継承ツリー(3レベル以上)
  • 多くの非抽象メソッド
  • 共有状態/キャッシュロジック
  • 全体的な動作を理解するのが難しい

薄い抽象化(プロトコル)

from typing import Protocol

class LLM(Protocol):
    """Minimal interface contract"""

    def generate(self, messages: list[Message]) -> str: ...

class StreamingLLM(Protocol):
    def stream(self, messages: list[Message]) -> Iterator[str]: ...

特徴:

  • 純粋なインターフェース
  • 継承された動作なし
  • ダックタイピング互換
  • モック/テストが容易

混合アプローチ

class LLMBase(ABC):
    """Some shared logic, but minimal"""

    @abstractmethod
    def generate(self, messages: list) -> str: ...

    def generate_with_retry(self, messages: list, retries: int = 3) -> str:
        """Optional convenience method"""
        for i in range(retries):
            try:
                return self.generate(messages)
            except RateLimitError:
                time.sleep(2 ** i)
        raise

依存性注入パターン

コンストラクタインジェクション

class Agent:
    def __init__(
        self,
        llm: LLM,
        tools: list[Tool],
        memory: Memory | None = None
    ):
        self.llm = llm
        self.tools = tools
        self.memory = memory or InMemoryStore()

長所: 明示的、テスト可能、IDEサポート 短所: 冗長な構築、手動での配線

ファクトリパターン

class Agent:
    @classmethod
    def from_config(cls, config: AgentConfig) -> "Agent":
        llm = LLMFactory.create(config.llm)
        tools = [ToolFactory.create(t) for t in config.tools]
        return cls(llm=llm, tools=tools)

    @classmethod
    def from_yaml(cls, path: str) -> "Agent":
        config = yaml.safe_load(open(path))
        return cls.from_config(AgentConfig(**config))

長所: 柔軟な構築、設定駆動 短所: 隠れた依存関係、マジック

グローバルレジストリ

TOOL_REGISTRY: dict[str, type[Tool]] = {}

def register_tool(name: str):
    def decorator(cls):
        TOOL_REGISTRY[name] = cls
        return cls
    return decorator

@register_tool("search")
class SearchTool(Tool): ...

# Usage
tool = TOOL_REGISTRY["search"]()

長所: プラグインフレンドリー、発見可能 短所: グローバル状態、テストが難しい、暗黙的

コンテナベースのDI

from dependency_injector import containers, providers

class Container(containers.DeclarativeContainer):
    config = providers.Configuration()

    llm = providers.Singleton(
        OpenAI,
        api_key=config.openai.api_key
    )

    agent = providers.Factory(
        Agent,
        llm=llm
    )

長所: 完全なライフサイクル制御、スコープ 短所: 複雑、学習曲線

設定戦略

コードファースト

agent = Agent(
    llm=OpenAI(model="gpt-4", temperature=0.7),
    tools=[SearchTool(), CalculatorTool()],
    max_steps=10
)

特徴: 型安全、IDE補完、リファクタリング可能

設定ファースト

# agent.yaml
llm:
  provider: openai
  model: gpt-4
  temperature: 0.7
tools:
  - search
  - calculator
max_steps: 10
agent = Agent.from_yaml("agent.yaml")

特徴: 非開発者向け、実行時変更、型安全性が低い

ハイブリッド

# Base config from file
base = AgentConfig.from_yaml("agent.yaml")

# Code overrides
agent = Agent(
    **base.dict(),
    llm=CustomLLM()  # Override specific component
)

出力テンプレート

## Component Model Analysis: [Framework Name]

### Abstraction Assessment

| Component | Base Class | Depth | Type |
|-----------|-----------|-------|------|
| LLM | BaseLLM | 3 levels | Thick |
| Tool | BaseTool | 2 levels | Mixed |
| Memory | Protocol | 0 levels | Thin |

### Dependency Injection
- **Primary Pattern**: [Constructor/Factory/Registry/Container]
- **Testability**: [Easy/Medium/Hard]
- **Configuration**: [Code/Config/Hybrid]

### Extension Points

| Extension | Mechanism | Difficulty |
|-----------|-----------|------------|
| Custom LLM | Inherit BaseLLM | Medium |
| Custom Tool | @register_tool | Easy |
| Custom Memory | Implement Protocol | Easy |

### Configuration
- **Strategy**: [Code-first/Config-first/Hybrid]
- **Formats**: [Python/YAML/JSON/TOML]
- **Validation**: [Pydantic/Manual/None]

### Recommendations
- [List any concerns or suggestions]

統合

  • 前提条件: 基底クラスを特定するための codebase-mapping
  • 入力元: 拡張性に関する決定のための comparative-matrix
  • 関連: 継承の問題に関する antipattern-catalog
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Component Model Analysis

Evaluates extensibility patterns and configuration approaches.

Process

  1. Identify base classes — Find BaseLLM, BaseTool, BaseAgent, etc.
  2. Classify abstraction depth — Thick (lots of logic) vs thin (interfaces)
  3. Analyze DI patterns — Constructor, factory, registry, container
  4. Document configuration — Code-first, config-first, or hybrid

Abstraction Layer Assessment

Thick Abstractions

class BaseLLM(ABC):
    """Many methods, lots of inherited behavior"""

    def __init__(self, model: str, temperature: float = 0.7):
        self.model = model
        self.temperature = temperature
        self._cache = {}

    def generate(self, prompt: str) -> str:
        cached = self._check_cache(prompt)
        if cached:
            return cached
        result = self._generate_impl(prompt)
        self._update_cache(prompt, result)
        return self._postprocess(result)

    @abstractmethod
    def _generate_impl(self, prompt: str) -> str: ...

    def _check_cache(self, prompt): ...
    def _update_cache(self, prompt, result): ...
    def _postprocess(self, result): ...
    def stream(self, prompt): ...
    def batch(self, prompts): ...
    # ... 15+ more methods

Characteristics:

  • Deep inheritance trees (3+ levels)
  • Many non-abstract methods
  • Shared state/caching logic
  • Hard to understand full behavior

Thin Abstractions (Protocols)

from typing import Protocol

class LLM(Protocol):
    """Minimal interface contract"""

    def generate(self, messages: list[Message]) -> str: ...

class StreamingLLM(Protocol):
    def stream(self, messages: list[Message]) -> Iterator[str]: ...

Characteristics:

  • Pure interfaces
  • No inherited behavior
  • Duck typing compatible
  • Easy to mock/test

Mixed Approach

class LLMBase(ABC):
    """Some shared logic, but minimal"""

    @abstractmethod
    def generate(self, messages: list) -> str: ...

    def generate_with_retry(self, messages: list, retries: int = 3) -> str:
        """Optional convenience method"""
        for i in range(retries):
            try:
                return self.generate(messages)
            except RateLimitError:
                time.sleep(2 ** i)
        raise

Dependency Injection Patterns

Constructor Injection

class Agent:
    def __init__(
        self,
        llm: LLM,
        tools: list[Tool],
        memory: Memory | None = None
    ):
        self.llm = llm
        self.tools = tools
        self.memory = memory or InMemoryStore()

Pros: Explicit, testable, IDE support Cons: Verbose construction, manual wiring

Factory Pattern

class Agent:
    @classmethod
    def from_config(cls, config: AgentConfig) -> "Agent":
        llm = LLMFactory.create(config.llm)
        tools = [ToolFactory.create(t) for t in config.tools]
        return cls(llm=llm, tools=tools)

    @classmethod
    def from_yaml(cls, path: str) -> "Agent":
        config = yaml.safe_load(open(path))
        return cls.from_config(AgentConfig(**config))

Pros: Flexible construction, config-driven Cons: Hidden dependencies, magic

Global Registry

TOOL_REGISTRY: dict[str, type[Tool]] = {}

def register_tool(name: str):
    def decorator(cls):
        TOOL_REGISTRY[name] = cls
        return cls
    return decorator

@register_tool("search")
class SearchTool(Tool): ...

# Usage
tool = TOOL_REGISTRY["search"]()

Pros: Plugin-friendly, discoverable Cons: Global state, harder to test, implicit

Container-Based DI

from dependency_injector import containers, providers

class Container(containers.DeclarativeContainer):
    config = providers.Configuration()

    llm = providers.Singleton(
        OpenAI,
        api_key=config.openai.api_key
    )

    agent = providers.Factory(
        Agent,
        llm=llm
    )

Pros: Full lifecycle control, scopes Cons: Complex, learning curve

Configuration Strategy

Code-First

agent = Agent(
    llm=OpenAI(model="gpt-4", temperature=0.7),
    tools=[SearchTool(), CalculatorTool()],
    max_steps=10
)

Characteristics: Type-safe, IDE completion, refactorable

Config-First

# agent.yaml
llm:
  provider: openai
  model: gpt-4
  temperature: 0.7
tools:
  - search
  - calculator
max_steps: 10
agent = Agent.from_yaml("agent.yaml")

Characteristics: Non-developer friendly, runtime changes, less type safety

Hybrid

# Base config from file
base = AgentConfig.from_yaml("agent.yaml")

# Code overrides
agent = Agent(
    **base.dict(),
    llm=CustomLLM()  # Override specific component
)

Output Template

## Component Model Analysis: [Framework Name]

### Abstraction Assessment

| Component | Base Class | Depth | Type |
|-----------|-----------|-------|------|
| LLM | BaseLLM | 3 levels | Thick |
| Tool | BaseTool | 2 levels | Mixed |
| Memory | Protocol | 0 levels | Thin |

### Dependency Injection
- **Primary Pattern**: [Constructor/Factory/Registry/Container]
- **Testability**: [Easy/Medium/Hard]
- **Configuration**: [Code/Config/Hybrid]

### Extension Points

| Extension | Mechanism | Difficulty |
|-----------|-----------|------------|
| Custom LLM | Inherit BaseLLM | Medium |
| Custom Tool | @register_tool | Easy |
| Custom Memory | Implement Protocol | Easy |

### Configuration
- **Strategy**: [Code-first/Config-first/Hybrid]
- **Formats**: [Python/YAML/JSON/TOML]
- **Validation**: [Pydantic/Manual/None]

### Recommendations
- [List any concerns or suggestions]

Integration

  • Prerequisite: codebase-mapping to identify base classes
  • Feeds into: comparative-matrix for extensibility decisions
  • Related: antipattern-catalog for inheritance issues