一键导入
moai-alfred-clone-pattern
Master-Clone pattern implementation guide for complex multi-step tasks with full project context
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Master-Clone pattern implementation guide for complex multi-step tasks with full project context
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
19-agent team structure, decision trees for agent selection, Haiku vs Sonnet model selection, and agent collaboration principles. Use when deciding which sub-agent to invoke, understanding team responsibilities, or learning multi-agent orchestration.
Guide Alfred sub-agents to actively invoke AskUserQuestion for ambiguous decisions.
Systematic code review guidance and automation. Apply TRUST 5 principles, check code quality, validate SOLID principles, identify security issues, and ensure maintainability. Use when conducting code reviews, setting review standards, or implementing review automation.
.moai/config.json official schema documentation, structure validation, project metadata, language settings, and configuration migration guide. Use when setting up project configuration or understanding config.json structure.
Claude Code context window optimization strategies, JIT retrieval, progressive loading, memory file patterns, and cleanup practices. Use when optimizing context usage, managing large projects, or implementing efficient workflows.
Guides agents through SPEC-First TDD workflow with context engineering, TRUST principles, and @TAG traceability. Essential for /alfred:1-plan, /alfred:2-run, /alfred:3-sync commands. Covers EARS requirements, JIT context loading, TDD RED-GREEN-REFACTOR cycle, and TAG chain validation.
| name | moai-alfred-clone-pattern |
| version | 1.0.0 |
| created | "2025-11-05T00:00:00.000Z" |
| updated | "2025-11-05T00:00:00.000Z" |
| status | active |
| description | Master-Clone pattern implementation guide for complex multi-step tasks with full project context |
| keywords | ["clone-pattern","master-clone","delegation","multi-step","parallel-processing"] |
| allowed-tools | ["Read","Bash","Task"] |
| Field | Value |
|---|---|
| Skill Name | moai-alfred-clone-pattern |
| Version | 1.0.0 (2025-11-05) |
| Allowed tools | Read, Bash, Task |
| Auto-load | On demand when complex tasks detected |
| Tier | Alfred |
Provides comprehensive guidance for Alfred's Master-Clone pattern - a delegation mechanism where Alfred creates autonomous clones to handle complex multi-step tasks that don't require domain-specific expertise but benefit from full project context and parallel processing capabilities.
Use Clone Pattern when:
Examples:
Main Alfred Session
│
├─ Intent analysis
├─ Task classification (domain/complexity)
│
└─ Clone creation (if applicable)
│
└─ Clone Instance
├─ Full project context
├─ All tool access permissions
├─ All Skills loaded
├─ Specific task description only
└─ Autonomous execution & learning
| Decision Factor | Clone Pattern | Lead-Specialist Pattern |
|---|---|---|
| Domain expertise needed | ❌ No | ✅ Yes |
| Context scope | Full project | Domain only |
| Autonomy level | Complete autonomous | Follows instructions |
| Parallel execution | ✅ Possible | ❌ Sequential only |
| Learning capability | Self-memory storage | Feedback-based |
| Best for | Long multi-step tasks | Specialized tasks |
def should_create_clone(task) -> bool:
"""Determine if Clone pattern should be applied"""
return (
# No domain specialization needed AND
task.domain not in ["ui", "backend", "db", "security", "ml"]
# AND meets one of these criteria:
AND (
task.steps >= 5 # 5+ steps
or task.files >= 100 # 100+ files
or task.parallelizable # Can be parallelized
or task.uncertainty > 0.5 # High uncertainty
)
)
def create_clone(
task_description: str,
context_scope: str = "full",
learning_enabled: bool = True
) -> CloneInstance:
"""Create Alfred Clone instance
Args:
task_description: Specific task description (clear goals)
context_scope: Context range ("full" | "domain")
learning_enabled: Whether to save learning memory
Returns:
Independent executable Clone instance
"""
clone = Task(
subagent_type="general-purpose",
description=f"Clone: {task_description}",
prompt=f"""
You are an Alfred Clone with full MoAI-ADK capabilities.
TASK: {task_description}
CONTEXT:
- Full project context loaded
- All .moai/ configuration available
- All 55 Skills accessible
- Same tools as Main Alfred
- Same TRUST 5 principles enforced
EXECUTION:
1. Plan your approach
2. Execute with transparency
3. Document decisions via @TAG
4. Create PR if modifications needed
5. Log learnings to clone-memory
SUCCESS CRITERIA:
- TRUST 5 principles maintained
- @TAG chain integrity preserved
- All tests passing
- PR ready for review
You have full autonomy. Main Alfred will review your output only.
"""
)
return clone
# Alfred's analysis
task = UserRequest(
type="migration",
scope="large-scale",
steps=8, # > 5 steps
domains=["config", "hooks", "permissions"],
uncertainty="high" # New structure transition
)
# Apply Clone pattern
if should_create_clone(task):
clone = create_clone(
"Migrate v0.14.0 config structure to v0.15.2"
)
clone.execute()
# Alfred's analysis
task = UserRequest(
type="exploration_evaluation",
items=["UI/UX redesign", "Backend optimization", "DB migration"],
independence="high" # Each item independent
)
# Apply Clone pattern for parallel execution
if task.independence > 0.7:
clones = [
create_clone(f"Evaluate: {item}")
for item in task.items
]
results = parallel_execute(clones)
Clones save learnings to improve future similar tasks:
def save_learning(task_type: str, learnings: dict):
"""Save Clone learning to memory"""
memory_file = Path(".moai/memory/clone-learnings.json")
learnings_db = json.loads(memory_file.read_text())
learnings_db[task_type].append({
"timestamp": now(),
"success": True/False,
"approach_used": "...",
"pitfalls_discovered": [...],
"optimization_tips": [...]
})
memory_file.write_text(json.dumps(learnings_db, indent=2))