Skip to content
Back to skills

Collection

ASecurity

マーティン・ファウラーのPofEAAに基づくトランザクションスクリプトパターンを専門とするスキル。 📚 リソース参照: このスキルには以下のリソースが含まれています。 必要に応じて該当するリソースを参照してください: - `.claude/skills/transaction-script/resources/domain-model-comparison.md`: Domain Model Comparisonリソース - `.claude/skills/transaction-script/resources/executor-pattern.md`: Executor Patternリソース - `.claude/skills/transaction-script/resources/pattern-overview.md`: Pattern Overviewリソース - `.claude/skills/transaction-script/templates/executor-template.md`: Executorテンプレート - `.claude/ski...

  • 24 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 8, 2026
code-qualitytypescriptbashnoderefactoring

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add mattnigh/skills_collection --skill collection --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Collection?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Collection
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mattnigh-collection-42ad5d0d/badge)](https://www.skillsdirectory.com/skills/mattnigh-collection-42ad5d0d)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: .claude/skills/transaction-script/SKILL.md
description: |
  マーティン・ファウラーのPofEAAに基づくトランザクションスクリプトパターンを専門とするスキル。

  📚 リソース参照:
  このスキルには以下のリソースが含まれています。
  必要に応じて該当するリソースを参照してください:

  - `.claude/skills/transaction-script/resources/domain-model-comparison.md`: Domain Model Comparisonリソース
  - `.claude/skills/transaction-script/resources/executor-pattern.md`: Executor Patternリソース
  - `.claude/skills/transaction-script/resources/pattern-overview.md`: Pattern Overviewリソース

  - `.claude/skills/transaction-script/templates/executor-template.md`: Executorテンプレート

  - `.claude/skills/transaction-script/scripts/analyze-executor.mjs`: Analyze Executorスクリプト

version: 1.0.0
---

# Transaction Script

## 概要

トランザクションスクリプトは、マーティン・ファウラーが『Patterns of Enterprise Application Architecture (PofEAA)』で
解説したビジネスロジック組織化パターンです。一つのスクリプト(手続き)で一つのビジネストランザクションを実現します。

**核心原則**:

- 一つのリクエストに対して一つのスクリプト
- 手続き型のシンプルなロジック
- 理解しやすく変更しやすい

**対象ユーザー**:

- ビジネスロジック実装エージェント(.claude/agents/logic-dev.md)
- シンプルな CRUD 操作を実装する開発者
- 既存の手続き型コードを整理したい開発者

## リソース構造

```
transaction-script/
├── SKILL.md                              # 本ファイル
├── resources/
│   ├── pattern-overview.md               # パターンの詳細解説
│   ├── domain-model-comparison.md        # ドメインモデルとの比較
│   └── executor-pattern.md               # Executorパターンの実装
├── scripts/
│   └── analyze-executor.mjs              # Executor分析スクリプト
└── templates/
    └── executor-template.md              # Executor実装テンプレート
```

## コマンドリファレンス

### リソース読み取り

```bash
# パターン詳細
cat .claude/skills/transaction-script/resources/pattern-overview.md

# ドメインモデルとの比較
cat .claude/skills/transaction-script/resources/domain-model-comparison.md

# Executorパターン
cat .claude/skills/transaction-script/resources/executor-pattern.md
```

### スクリプト実行

```bash
# Executor分析(実装の品質チェック)
node .claude/skills/transaction-script/scripts/analyze-executor.mjs src/features/
```

### テンプレート参照

```bash
# Executor実装テンプレート
cat .claude/skills/transaction-script/templates/executor-template.md
```

## パターンの特徴

### 構造

各トランザクションは独立したスクリプト(関数/メソッド)として実装されます。

**典型的な流れ**:

1. 入力の検証
2. データの取得(リポジトリ経由)
3. ビジネスロジックの実行
4. データの永続化
5. 結果の返却

### 利点

- **シンプル**: 理解しやすい手続き型
- **直接的**: リクエストと処理の 1 対 1 対応
- **変更容易**: 影響範囲が限定的
- **デバッグ容易**: 処理フローが明確

### 欠点

- **重複**: 類似ロジックが各スクリプトに重複しやすい
- **スケール困難**: ロジックが複雑になると管理が困難
- **ドメイン知識分散**: ビジネスルールが散在しやすい

## 適用条件

### トランザクションスクリプトが適切な場合

- [ ] ビジネスロジックがシンプル
- [ ] CRUD 操作が中心
- [ ] ドメインモデルが不要または過剰
- [ ] チームが手続き型に慣れている
- [ ] 短期プロジェクト

### ドメインモデルを検討すべき場合

- [ ] ビジネスルールが複雑
- [ ] 同じルールが複数箇所で必要
- [ ] エンティティ間の関係が複雑
- [ ] 長期的な保守が必要

**詳細**: `resources/domain-model-comparison.md`

## Executor パターン

### 概要

プロジェクト固有のトランザクションスクリプト実装パターンです。
各機能のビジネスロジックを Executor クラスとして実装します。

### 構造

```
features/
└── [機能名]/
    ├── schema.ts      # 入出力スキーマ(Zod)
    ├── executor.ts    # ビジネスロジック(Transaction Script)
    └── __tests__/     # テスト
```

### インターフェース

```typescript
interface IWorkflowExecutor {
  execute(input: Input): Promise<Output>;
}
```

**詳細**: `resources/executor-pattern.md`

## ワークフロー

### トランザクションスクリプト実装

```
1. 要件の理解
   ↓
2. 入出力の定義(スキーマ)
   ↓
3. テストの作成(TDD)
   ↓
4. スクリプトの実装
   - 入力検証
   - データ取得
   - ロジック実行
   - 永続化
   - 結果返却
   ↓
5. リファクタリング
   ↓
6. 検証
```

### 判断フロー

```
ビジネスロジック実装
  ↓
[質問] ロジックはシンプルか?
  ├─ Yes → Transaction Script
  └─ No  → Domain Modelを検討
  ↓
[質問] 同じルールが複数箇所で必要か?
  ├─ Yes → 共通関数に抽出、またはDomain Model
  └─ No  → Transaction Scriptを継続
```

## ベストプラクティス

### すべきこと

1. **一つのスクリプトは一つのトランザクション**:
   - 責任を明確に
   - 関数名でトランザクションを表現

2. **共通ロジックの抽出**:
   - 重複を発見したら共通関数に
   - ただし早すぎる抽象化は避ける

3. **テスト駆動**:
   - スクリプトごとにテストを作成
   - エッジケースをカバー

### 避けるべきこと

1. **巨大なスクリプト**:
   - ❌ 100 行を超えるスクリプト
   - ✅ 適切に分割して呼び出し

2. **過度な抽象化**:
   - ❌ シンプルなロジックに複雑なパターンを適用
   - ✅ シンプルさを維持

3. **ビジネスルールの散在**:
   - ❌ 同じルールが複数スクリプトに重複
   - ✅ 共通関数に抽出

## 関連スキル

- **.claude/skills/refactoring-techniques/SKILL.md** (`.claude/skills/refactoring-techniques/SKILL.md`): コードの改善
- **.claude/skills/tdd-red-green-refactor/SKILL.md** (`.claude/skills/tdd-red-green-refactor/SKILL.md`): テスト駆動開発
- **.claude/skills/domain-driven-design/SKILL.md** (`.claude/skills/domain-driven-design/SKILL.md`): 複雑なドメインの場合

## 参考文献

- **『Patterns of Enterprise Application Architecture』** マーティン・ファウラー著
  - 第 9 章: Domain Logic Patterns
  - Transaction Script (110-115 ページ)

## 変更履歴

| バージョン | 日付       | 変更内容                                       |
| ---------- | ---------- | ---------------------------------------------- |
| 1.0.0      | 2025-11-25 | 初版作成 - PofEAA のトランザクションスクリプト |

Files in this skill

  • 0Chan-smc__claude-code-workflow-lab__claude__skills__frontend-dev-guidelines__SKILL.md15.1 KB
  • 17hz__nextjs-template__claude__skills__example-skill__SKILL.md316 B
  • 1ambda__dataops-platform__claude__skills__context-synthesis__SKILL.md3.5 KB
  • 1natsu172__dotfiles__claude__skills__git-analysis__SKILL.md5.4 KB
  • 1natsu172__dotfiles__claude__skills__github-pr-best-practices__SKILL.md7.7 KB
  • 23Maestro__prospect-pipeline__claude__skills__npid-fastapi-skill.md26.1 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-code-javascript__SKILL.md15.7 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-code-python__SKILL.md17.5 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-expression-syntax__SKILL.md9.4 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-mcp-tools-expert__SKILL.md12.5 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-node-configuration__SKILL.md16.6 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-workflow-patterns__SKILL.md11.2 KB
  • 3x-Projetos__claude-memory-framework__claude__skills__scientist__SKILL.md14.8 KB
  • 5MinFutures__futures-arena__claude__skills__migration-tracker__SKILL.md16.2 KB
  • 5MinFutures__futures-arena__claude__skills__planning-guidelines__SKILL.md11.8 KB
  • 92Bilal26__TaskPilotAI__claude__skills__assessment-builder__SKILL.md17.5 KB
  • 92Bilal26__TaskPilotAI__claude__skills__book-scaffolding__SKILL.md19.1 KB
  • 92Bilal26__TaskPilotAI__claude__skills__code-validation-sandbox__SKILL.md6.2 KB
  • 92Bilal26__TaskPilotAI__claude__skills__exercise-designer__SKILL.md18.1 KB
  • 92Bilal26__TaskPilotAI__claude__skills__learning-objectives__SKILL.md24.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in code-quality →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.