Pair Programming について
Pair Programming は、AI と構造化された共同開発を行うための Ruflo CLI スキルです。役割別のモード、検証、テスト、コードレビュー、セッション保存に対応します。
主な機能
- 01ドライバーとナビゲーターの役割管理
- 027種類の協業モード
- 03品質スコアと失敗時のロールバック
- 04テスト生成とカバレッジ追跡
- 05セッションの保存と復元
活用シーン
- 01TDD で機能を実装
- 02変更内容のセキュリティと性能をレビュー
- 03ガイド付き分析で問題をデバッグ
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ ruvnet/ ruflo --skill pair-programmingインストール後、Claude Code で/pair-programmingを入力して読み込まれたか確認します。
詳細
ペアプログラミング
インテリジェントな役割管理、リアルタイムの品質モニタリング、包括的な開発ワークフローを備えた、AI による協調型ペアプログラミングです。
このスキルでできること
このスキルは、AI の支援によるプロフェッショナルなペアプログラミング機能を提供し、複数の協業モード、継続的な検証、統合テストに対応します。driver$navigator の役割を管理し、リアルタイムのコードレビューを実施し、品質指標を追跡し、truth-score による検証を通じて高い基準を確保します。
主な機能:
- 複数のモード:Driver、Navigator、Switch、TDD、Review、Mentor、Debug
- リアルタイム検証:失敗時のロールバック機能を備えた自動品質スコアリング
- 役割管理:driver$navigator の役割をシームレスに切り替え
- テスト統合:テストの自動生成、カバレッジの追跡、継続的なテスト
- コードレビュー:セキュリティスキャン、パフォーマンス分析、ベストプラクティスの徹底
- セッションの永続化:自動保存、復元、エクスポート、共有
Claude Code での使用方法
CLI がセッション状態を保持し、Claude Code がそれを読み取ります。入力用の REPL はありません。
- 各ターンの開始時に
ruflo pair status --jsonを実行します。activeがfalseの場合、このスキルは休止状態です。 modeとaiRoleに従います。driver の場合はコードを記述し、人間がレビューします。navigator の場合はレビューと提案を行い、依頼されない限り編集しません。tdd、review、mentor、debugは、以下の説明に従って動作を調整します。switchDueがtrueの場合は、ruflo pair switchを実行して役割の交代を伝え、新しい役割で続行します。ruflo pair mode <mode>を使って、セッション中にモードを変更します。人間もシェルから同じコマンドを実行できます。
状態は .claude-flow/sessions/pair/current.json に保存されます。ruflo pair end を実行すると、その隣にある history.jsonl にアーカイブされます。
前提条件
必須:
- Ruflo CLI がインストールされていること(
npm install -g ruflo)。ruflo pairコマンドが提供されます - Git リポジトリ(任意ですが、推奨)
推奨:
- テストフレームワーク(Jest、pytest など)
- リンターの設定(ESLint、pylint など)
- コードフォーマッター(Prettier、Black など)
クイックスタート
基本セッション
# Start simple pair programming
ruflo pair start
TDD セッション
# Test-driven development
ruflo pair start \
--mode tdd \
--test-first \
--coverage 90
完全ガイド
セッション制御コマンド
セッションの開始
# Basic start
ruflo pair start
# Expert refactoring session
ruflo pair start \
--agent senior-dev \
--focus refactor \
--verify \
--threshold 0.98
# Debugging session
ruflo pair start \
--agent debugger-expert \
--focus debug \
--review
# Learning session
ruflo pair start \
--mode mentor \
--pace slow \
--examples
セッション管理
# Check status
ruflo pair status
# View history
ruflo pair history
# Pause session
$pause [--reason <reason>]
# Resume session
$resume
# End session
ruflo pair end [--save] [--report]
利用可能なモード
Driver モード
AI のガイダンスを受けながら、あなたがコードを記述します。
ruflo pair start --mode driver
あなたの役割:
- 実際のコードを記述する
- ソリューションを実装する
- その場で判断する
- 構文と構造に対処する
AI Navigator:
- 戦略的なガイダンスを提供する
- 潜在的な問題を見つける
- 改善案を提案する
- リアルタイムでレビューする
- 全体の方向性を追跡する
おすすめの用途:
- 新しいパターンを学ぶ
- 慣れ親しんだ機能を実装する
- 素早く反復する
- 実践的にデバッグする
コマンド:
$suggest - Get implementation suggestions
$review - Request code review
$explain - Ask for explanations
$optimize - Request optimization ideas
$patterns - Get pattern recommendations
Navigator モード
あなたが方向性を示し、AI がコードを記述します。
ruflo pair start --mode navigator
あなたの役割:
- 大まかな方向性を示す
- 生成されたコードをレビューする
- アーキテクチャ上の判断を下す
- ビジネス要件を満たしていることを確認する
AI Driver:
- 実装コードを記述する
- 構文の詳細に対処する
- あなたの指示を実装する
- 定型コードを管理する
- リファクタリングを実行する
おすすめの用途:
- 迅速なプロトタイピング
- 定型コードの生成
- AI のパターンから学ぶ
- ソリューションを探る
コマンド:
$implement - Direct implementation
$refactor - Request refactoring
$test - Generate tests
$document - Add documentation
$alternate - See alternative approaches
Switch モード
一定の間隔で役割を自動的に交代します。
# Default 10-minute intervals
ruflo pair start --mode switch
# 5-minute intervals (rapid)
ruflo pair start --mode switch --interval 5m
# 15-minute intervals (deep focus)
ruflo pair start --mode switch --interval 15m
引き継ぎの手順:
- 切り替えの30秒前に警告する
- 現在のdriverが作業中の考えをまとめる
- コンテキストの概要を生成する
- 役割をスムーズに交代する
- 新しいdriverが続ける
おすすめの用途:
- バランスの取れた協業
- 知識の共有
- 複雑な機能
- 長時間のセッション
特化モード
TDD モード - テスト駆動開発:
ruflo pair start \
--mode tdd \
--test-first \
--coverage 100
ワークフロー:失敗するテストを作成 → 実装 → リファクタリング → 繰り返し
レビュー モード - 継続的なコードレビュー:
ruflo pair start \
--mode review \
--strict \
--security
機能:リアルタイムのフィードバック、セキュリティスキャン、パフォーマンス分析
メンター モード - 学習を重視:
ruflo pair start \
--mode mentor \
--explain-all \
--pace slow
機能:詳細な説明、段階的なガイダンス、パターンの指導
デバッグ モード - 問題解決:
ruflo pair start \
--mode debug \
--verbose \
--trace
機能:問題の特定、根本原因の分析、修正案の提示
セッション中のコマンド
コードコマンド
$explain [--level basic|detailed|expert]
Explain the current code or selection
$suggest [--type refactor|optimize|security|style]
Get improvement suggestions
$implement <description>
Request implementation (navigator mode)
$refactor [--pattern <pattern>] [--scope function|file|module]
Refactor selected code
$optimize [--target speed|memory|both]
Optimize code for performance
$document [--format jsdoc|markdown|inline]
Add documentation to code
$comment [--verbose]
Add inline comments
$pattern <pattern-name> [--example]
Apply a design pattern
テストコマンド
$test [--watch] [--coverage] [--only <pattern>]
Run test suite
$test-gen [--type unit|integration|e2e]
Generate tests for current code
$coverage [--report html|json|terminal]
Check test coverage
$mock <target> [--realistic]
Generate mock data or functions
$test-watch [--on-save]
Enable test watching
$snapshot [--update]
Create test snapshots
レビューコマンド
$review [--scope current|file|changes] [--strict]
Perform code review
$security [--deep] [--fix]
Security analysis
$perf [--profile] [--suggestions]
Performance analysis
$quality [--detailed]
Check code quality metrics
$lint [--fix] [--config <config>]
Run linters
$complexity [--threshold <value>]
Analyze code complexity
ナビゲーションコマンド
$goto <file>[:line[:column]]
Navigate to file or location
$find <pattern> [--regex] [--case-sensitive]
Search in project
$recent [--limit <n>]
Show recent files
$bookmark [add|list|goto|remove] [<name>]
Manage bookmarks
$history [--limit <n>] [--filter <pattern>]
Show command history
$tree [--depth <n>] [--filter <pattern>]
Show project structure
Git コマンド
$diff [--staged] [--file <file>]
Show git diff
$commit [--message <msg>] [--amend]
Commit with verification
$branch [create|switch|delete|list] [<name>]
Branch operations
$stash [save|pop|list|apply] [<message>]
Stash operations
$log [--oneline] [--limit <n>]
View git log
$blame [<file>]
Show git blame
AI パートナーコマンド
$agent [switch|info|config] [<agent-name>]
Manage AI agent
$teach <preference>
Teach the AI your preferences
$feedback [positive|negative] <message>
Provide feedback to AI
$personality [professional|friendly|concise|verbose]
Adjust AI personality
$expertise [add|remove|list] [<domain>]
Set AI expertise focus
メトリクスコマンド
$metrics [--period today|session|week|all]
Show session metrics
$score [--breakdown]
Show quality scores
$productivity [--chart]
Show productivity metrics
$leaderboard [--personal|team]
Show improvement leaderboard
ロールとモードのコマンド
$switch [--immediate]
Switch driver$navigator roles
$mode <type>
Change mode (driver|navigator|switch|tdd|review|mentor|debug)
$role
Show current role
$handoff
Prepare role handoff
コマンドのショートカット
| エイリアス | 完全なコマンド |
|---|---|
$s | $suggest |
$e | $explain |
$t | $test |
$r | $review |
$c | $commit |
$g | $goto |
$f | $find |
$h | $help |
$sw | $switch |
$st | $status |
設定
基本設定
.claude-flow$pair-config.json を作成します:
{
"pair": {
"enabled": true,
"defaultMode": "switch",
"defaultAgent": "auto",
"autoStart": false,
"theme": "professional"
}
}
完全な設定
{
"pair": {
"general": {
"enabled": true,
"defaultMode": "switch",
"defaultAgent": "senior-dev",
"language": "javascript",
"timezone": "UTC"
},
"modes": {
"driver": {
"enabled": true,
"suggestions": true,
"realTimeReview": true,
"autoComplete": false
},
"navigator": {
"enabled": true,
"codeGeneration": true,
"explanations": true,
"alternatives": true
},
"switch": {
"enabled": true,
"interval": "10m",
"warning": "30s",
"autoSwitch": true,
"pauseOnIdle": true
}
},
"verification": {
"enabled": true,
"threshold": 0.95,
"autoRollback": true,
"preCommitCheck": true,
"continuousMonitoring": true,
"blockOnFailure": true
},
"testing": {
"enabled": true,
"autoRun": true,
"framework": "jest",
"onSave": true,
"coverage": {
"enabled": true,
"minimum": 80,
"enforce": true,
"reportFormat": "html"
}
},
"review": {
"enabled": true,
"continuous": true,
"preCommit": true,
"security": true,
"performance": true,
"style": true,
"complexity": {
"maxComplexity": 10,
"maxDepth": 4,
"maxLines": 100
}
},
"git": {
"enabled": true,
"autoCommit": false,
"commitTemplate": "feat: {message}",
"signCommits": false,
"pushOnEnd": false,
"branchProtection": true
},
"session": {
"autoSave": true,
"saveInterval": "5m",
"maxDuration": "4h",
"idleTimeout": "15m",
"breakReminder": "45m",
"metricsInterval": "1m"
},
"ai": {
"model": "advanced",
"temperature": 0.7,
"maxTokens": 4000,
"personality": "professional",
"expertise": ["backend", "testing", "security"],
"learningEnabled": true
}
}
}
組み込みエージェント
{
"agents": {
"senior-dev": {
"expertise": ["architecture", "patterns", "optimization"],
"style": "thorough",
"reviewLevel": "strict"
},
"tdd-specialist": {
"expertise": ["testing", "mocks", "coverage"],
"style": "test-first",
"reviewLevel": "comprehensive"
},
"debugger-expert": {
"expertise": ["debugging", "profiling", "tracing"],
"style": "analytical",
"reviewLevel": "focused"
},
"junior-dev": {
"expertise": ["learning", "basics", "documentation"],
"style": "questioning",
"reviewLevel": "educational"
}
}
}
CLI 設定
# Set configuration
ruflo pair config set defaultMode switch
ruflo pair config set verification.threshold 0.98
# Get configuration
ruflo pair config get
ruflo pair config get defaultMode
# Export/Import
ruflo pair config export > config.json
ruflo pair config import config.json
# Reset
ruflo pair config reset
プロファイル管理
再利用可能なプロファイルを作成します:
# Create profile
ruflo pair profile create refactoring \
--mode driver \
--verify true \
--threshold 0.98 \
--focus refactor
# Use profile
ruflo pair start --profile refactoring
# List profiles
ruflo pair profile list
プロファイル設定:
{
"profiles": {
"refactoring": {
"mode": "driver",
"verification": {
"enabled": true,
"threshold": 0.98
},
"focus": "refactor"
},
"debugging": {
"mode": "navigator",
"agent": "debugger-expert",
"trace": true,
"verbose": true
},
"learning": {
"mode": "mentor",
"pace": "slow",
"explanations": "detailed",
"examples": true
}
}
}
実際の使用例
例 1:機能の実装
JWT トークンを使用したユーザー認証の実装:
# Session setup
ruflo pair start \
--mode switch \
--agent senior-dev \
--focus implement \
--verify \
--test
セッションの流れ:
👥 Starting pair programming for authentication feature...
[DRIVER: You - 10 minutes]
$explain JWT authentication flow
> AI explains JWT concepts and best practices
$suggest implementation approach
> AI suggests using middleware pattern with refresh tokens
# You write the basic auth middleware structure
[SWITCH TO NAVIGATOR]
[NAVIGATOR: AI - 10 minutes]
$implement JWT token generation with refresh tokens
> AI generates secure token implementation
$test-gen
> AI creates comprehensive test suite
[SWITCH TO DRIVER]
[DRIVER: You - 10 minutes]
# You refine the implementation
$review --security
> AI performs security review, suggests improvements
$commit --message "feat: JWT authentication with refresh tokens"
✅ Truth Score: 0.98 - Committed successfully
例 2:バグ修正
Node.js のメモリリークをデバッグする:
# Session setup
ruflo pair start \
--mode navigator \
--agent debugger-expert \
--focus debug \
--trace
セッションの流れ:
👥 Starting debugging session...
$status
> Analyzing application for memory issues...
$perf --profile
> Memory usage growing: 150MB → 450MB over 10 minutes
$find "new EventEmitter" --regex
> Found 3 instances of EventEmitter creation
$inspect eventEmitters --deep
> Discovering listeners not being removed
$suggest fix for memory leak
> AI suggests: "Add removeListener in cleanup functions"
$implement cleanup functions for all event emitters
> AI generates proper cleanup code
$test
> Memory stable at 150MB ✅
$commit --message "fix: memory leak in event emitters"
例 3:TDD セッション
テスト駆動開発でショッピングカートを構築する:
# Session setup
ruflo pair start \
--mode tdd \
--agent tdd-specialist \
--test-first
セッションの流れ:
👥 TDD Session: Shopping Cart Feature
[RED PHASE]
$test-gen "add item to cart"
> AI writes failing test:
✗ should add item to cart
✗ should update quantity for existing item
✗ should calculate total price
[GREEN PHASE]
$implement minimal cart functionality
> You write just enough code to pass tests
$test
> Tests passing: 3/3 ✅
[REFACTOR PHASE]
$refactor --pattern repository
> AI refactors to repository pattern
$test
> Tests still passing: 3/3 ✅
[NEXT CYCLE]
$test-gen "remove item from cart"
> AI writes new failing tests...
例 4:コードのリファクタリング
レガシーコードを最新化する:
# Session setup
ruflo pair start \
--mode driver \
--focus refactor \
--verify \
--threshold 0.98
セッションの流れ:
👥 Refactoring Session: Modernizing UserService
$analyze UserService.js
> AI identifies:
- Callback hell (5 levels deep)
- No error handling
- Tight coupling
- No tests
$suggest refactoring plan
> AI suggests:
1. Convert callbacks to async$await
2. Add error boundaries
3. Extract dependencies
4. Add unit tests
$test-gen --before-refactor
> AI generates tests for current behavior
$refactor callbacks to async$await
# You refactor with AI guidance
$test
> All tests passing ✅
$review --compare
> AI shows before$after comparison
> Code complexity: 35 → 12
> Truth score: 0.99 ✅
$commit --message "refactor: modernize UserService with async$await"
例 5:パフォーマンスの最適化
低速な React アプリケーションを最適化する:
# Session setup
ruflo pair start \
--mode switch \
--agent performance-expert \
--focus optimize \
--profile
セッションの流れ:
👥 Performance Optimization Session
$perf --profile
> React DevTools Profiler Results:
- ProductList: 450ms render
- CartSummary: 200ms render
- Unnecessary re-renders: 15
$suggest optimizations for ProductList
> AI suggests:
1. Add React.memo
2. Use useMemo for expensive calculations
3. Implement virtualization for long lists
$implement React.memo and useMemo
# You implement with AI guidance
$perf --profile
> ProductList: 45ms render (90% improvement!) ✅
$implement virtualization with react-window
> AI implements virtual scrolling
$perf --profile
> ProductList: 12ms render (97% improvement!) ✅
> FPS: 60 stable ✅
$commit --message "perf: optimize ProductList with memoization and virtualization"
例 6:API 開発
Express で RESTful API を構築する:
# Session setup
ruflo pair start \
--mode navigator \
--agent backend-expert \
--focus implement \
--test
セッションの流れ:
👥 API Development Session
$design REST API for blog platform
> AI designs endpoints:
POST $api$posts
GET $api$posts
GET $api$posts/:id
PUT $api$posts/:id
DELETE $api$posts/:id
$implement CRUD endpoints with validation
> AI implements with Express + Joi validation
$test-gen --integration
> AI generates integration tests
$security --api
> AI adds:
- Rate limiting
- Input sanitization
- JWT authentication
- CORS configuration
$document --openapi
> AI generates OpenAPI documentation
$test --integration
> All endpoints tested: 15/15 ✅
セッションテンプレート
クイックスタートテンプレート
# Refactoring template
ruflo pair --template refactor
# Focus: Code improvement
# Verification: High (0.98)
# Testing: After each change
# Review: Continuous
# Feature template
ruflo pair --template feature
# Focus: Implementation
# Verification: Standard (0.95)
# Testing: On completion
# Review: Pre-commit
# Debug template
ruflo pair --template debug
# Focus: Problem solving
# Verification: Moderate (0.90)
# Testing: Regression tests
# Review: Root cause
# Learning template
ruflo pair --template learn
# Mode: Mentor
# Pace: Slow
# Explanations: Detailed
# Examples: Many
セッション管理
セッションのステータス
ruflo pair status
出力:
👥 Pair Programming Session
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Session ID: pair_1755021234567
Duration: 45 minutes
Status: Active
Partner: senior-dev
Current Role: DRIVER (you)
Mode: Switch (10m intervals)
Next Switch: in 3 minutes
📊 Metrics:
├── Truth Score: 0.982 ✅
├── Lines Changed: 234
├── Files Modified: 5
├── Tests Added: 12
├── Coverage: 87% ↑3%
└── Commits: 3
🎯 Focus: Implementation
📝 Current File: src$auth$login.js
セッション履歴
ruflo pair history
出力:
📚 Session History
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1. 2024-01-15 14:30 - 16:45 (2h 15m)
Partner: expert-coder
Focus: Refactoring
Truth Score: 0.975
Changes: +340 -125 lines
2. 2024-01-14 10:00 - 11:30 (1h 30m)
Partner: tdd-specialist
Focus: Testing
Truth Score: 0.991
Tests Added: 24
3. 2024-01-13 15:00 - 17:00 (2h)
Partner: debugger-expert
Focus: Bug Fixing
Truth Score: 0.968
Issues Fixed: 5
セッションの永続化
# Save session
ruflo pair --save [--name <name>]
# Load session
ruflo pair --load <session-id>
# Export session
ruflo pair --export <session-id> [--format json|md]
# Generate report
ruflo pair --report <session-id>
バックグラウンドセッション
# Start in background
ruflo pair start --background
# Monitor background session
ruflo pair --monitor
# Attach to background session
ruflo pair --attach <session-id>
# End background session
ruflo pair end <session-id>
高度な機能
カスタムコマンド
設定で定義します:
{
"customCommands": {
"tdd": "$test-gen && $test --watch",
"full-review": "$lint --fix && $test && $review --strict",
"quick-fix": "$suggest --type fix && $implement && $test"
}
}
カスタムコマンドを使用します:
$custom tdd
$custom full-review
コマンドの連結
$test && $commit && $push
$lint --fix && $test && $review --strict
セッションの記録
# Start with recording
ruflo pair start --record
# Replay session
ruflo pair --replay <session-id>
# Session analytics
ruflo pair --analytics <session-id>
統合オプション
Git との連携:
ruflo pair start --git --auto-commit
CI/CD との連携:
ruflo pair start --ci --non-interactive
IDE との連携:
ruflo pair start --ide vscode
ベストプラクティス
セッションの進め方
- 明確な目標 - セッションの目的を事前に定義します
- 適切なモード - タスクの種類に応じて選択します
- 検証を有効化 - 重要なコードパスで有効にします
- 定期的なテスト - 継続的に品質を維持します
- セッションメモ - 重要な決定事項を記録します
- 定期的な休憩 - 45〜60 分ごとに休憩します
コードの進め方
- 早めにテスト - 変更のたびにテストを実行します
- コミット前に検証 - 真実性スコアを確認します
- セキュリティをレビュー - 機密性の高いコードでは必ず実施します
- パフォーマンスをプロファイル - 最適化には
$perfを使用します - セッションを保存 - 複雑な作業では保存します
- AI から学ぶ - 頻繁に質問します
モードの選択
- ドライバーモード:学習中や、実装を自分で制御するとき
- ナビゲーターモード:迅速なプロトタイピングや生成向け
- スイッチモード:長時間のセッションや、バランスの取れた協業向け
- TDD モード:テストを使って構築するとき
- レビューモード:品質を重視するとき
- メンターモード:学習を優先するとき
- デバッグモード:問題を修正するとき
トラブルシューティング
セッションが開始しない
- エージェントが利用可能か確認します
- 設定ファイルの構文を確認します
- ワークスペースがクリーンな状態であることを確認します
- ログファイルを確認します
セッションが切断された
--recoverを使用して復元します- ネットワーク接続を確認します
- バックグラウンドプロセスを確認します
- 自動保存ファイルを確認します
パフォーマンスの低下
- 検証のしきい値を下げます
- 継続的なテストを無効にします
- システムリソースを確認します
- より軽量な AI モデルを使用します
設定の問題
- JSON の構文を検証します
- ファイルのアクセス権を確認します
- 優先順位を確認します(CLI > env > project > user > global)
ruflo pair config validateを実行します
品質メトリクス
Truth Score のしきい値
Error: < 0.90 ❌
Warning: 0.90 - 0.95 ⚠️
Good: 0.95 - 0.98 ✅
Excellent: > 0.98 🌟
カバレッジのしきい値
Error: < 70% ❌
Warning: 70% - 80% ⚠️
Good: 80% - 90% ✅
Excellent: > 90% 🌟
複雑度のしきい値
Error: > 15 ❌
Warning: 10 - 15 ⚠️
Good: 5 - 10 ✅
Excellent: < 5 🌟
環境変数
環境変数を使って設定を上書きします。
export CLAUDE_PAIR_MODE=driver
export CLAUDE_PAIR_VERIFY=true
export CLAUDE_PAIR_THRESHOLD=0.98
export CLAUDE_PAIR_AGENT=senior-dev
export CLAUDE_PAIR_AUTO_TEST=true
コマンド履歴
履歴を操作します。
↑/↓- コマンド履歴を移動しますCtrl+R- コマンド履歴を検索します!!- 直前のコマンドを再実行します!<n>- 履歴の n 番目のコマンドを実行します
キーボードショートカット(設定可能)
デフォルトのショートカット:
{
"shortcuts": {
"switch": "ctrl+shift+s",
"suggest": "ctrl+space",
"review": "ctrl+r",
"test": "ctrl+t"
}
}
関連コマンド
ruflo pair --help- ヘルプを表示しますruflo pair config- 設定を管理しますruflo pair profile- プロファイルを管理しますruflo pair templates- テンプレートを一覧表示しますruflo pair agents- 利用可能なエージェントを一覧表示します