Skills: Skill Composition & Orchestration
Last updated: 2026-08-31
A single Skill solves a single problem — composed Skills solve complex problems.
1. Composition Patterns
(1) Skill Chain (Pipeline)
Execute multiple Skills sequentially, where one's output is the next's input:
Skill Chain Example: Code Commit Full Process
Code Review → Auto Fix → Run Tests → Update Docs → Commit Code
↓ ↓ ↓ ↓ ↓
Review Report Fix Patch Test Report Doc Update commit ID
(2) Skill Matrix (Matrix)
Multiple Skills execute in parallel, results aggregated:
Skill Matrix Example: Comprehensive Quality Check
┌→ Security Scan ─┐
Code Change ──┤→ Performance Analysis ─┤→ Quality Report
└→ Style Check ─┘
(3) Conditional Orchestration
Select execution path based on conditions:
Conditional Orchestration Example: Smart Deploy
Change type determination:
├── Doc change → Only update docs
├── Test change → Only run tests
├── Code change → Full process (review→test→deploy)
└── Config change → Review + confirm then deploy
2. Composition Implementation
(1) Prompt Orchestration
Describe composition logic in the Skill prompt:
## Execution Strategy
1. First execute code-review Skill
2. If 🔴 issues found:
- Execute auto-fix Skill
- Re-execute code-review to confirm fix
3. After review passes, execute test-runner Skill
4. After tests pass, output summary report
(2) Context Passing
Skills pass data through context:
Skill A output → Write to context variable → Skill B reads
Example:
code-review finds 3 issues →
context: { review_issues: [...], fix_targets: [...] }
→ auto-fix reads fix_targets and executes fixes
(3) Result Aggregation
## Summary Report Template
### Skill Chain Execution Results
| Step | Skill | Status | Duration | Key Output |
|:-----|:------|:-------|:---------|:-----------|
| 1 | code-review | ✅ | 30s | 5 issues |
| 2 | auto-fix | ✅ | 45s | Fixed 4 |
| 3 | test-runner | ✅ | 2m | All pass |
3. Composition Design Principles
(1) Loose Coupling
Each Skill is independently usable, not depending on other Skills' internal implementation:
Loose Coupling Design:
├── Skill A doesn't directly call Skill B's internal functions
├── Skills pass data via standard formats (e.g., JSON, Markdown)
├── Single Skill failure doesn't affect other Skills' basic functionality
└── Each Skill can be tested independently
(2) Single Responsibility
Each Skill does one thing and does it well:
| ✅ Correct | ❌ Wrong |
|---|---|
| code-review only reviews | code-review reviews+fixes+tests |
| auto-fix only fixes | auto-fix fixes+reviews+deploys |
| deploy only deploys | deploy deploys+monitors+alerts |
(3) Idempotency
Repeated execution produces consistent results, supporting safe retries:
## Idempotency Requirements
- Multiple runs of review Skill produce the same results
- Fix Skill checks if issue is already fixed, skips if so
- Deploy Skill checks current state, confirms rather than re-deploys if already deployed
4. Composition Orchestration Practice
▶ Example: PR Quality Gate
Alice designed a PR auto-review composition:
---
name: pr-gate
description: "PR quality gate: review+test+security three-in-one"
triggers:
- keyword: "pr-gate|quality gate"
---
## Execution Flow
1. Call code-review (code review)
2. Call test-runner (run tests)
3. Call security-scan (security scan)
4. Aggregate results from all three
5. Output merge recommendation:
- All three pass → ✅ Recommend merge
- Any 🔴 → ❌ Do not recommend merge
- Only 🟡 → ⚠️ Merge after fixes
Bob commented: "A single Skill is a tool, composed Skills are a pipeline — the power of a pipeline far exceeds the simple sum of individual tools."
❓ FAQ
📖 Summary
- Three composition types: Skill chain (sequential), Skill matrix (parallel), conditional orchestration
- Implementation: Prompt orchestration, context passing, result aggregation
- Design principles: Loose coupling, single responsibility, idempotency
- Practical advice: Nesting ≤2, composition ≤5, critical path failure stops
📝 Exercises
- Basic (⭐): Create a simple skill chain connecting code-review and test-runner Skills.
- Intermediate (⭐⭐): Create a PR quality gate Skill that runs review, test, and security scan in parallel, then aggregates results.
- Advanced (⭐⭐⭐): Design a smart orchestration system that auto-selects which Skills to execute based on change type, handling mid-step failures and retries.