Skip to content
Back to skills

Collection

ASecurity

Master-Clone pattern implementation guide for complex multi-step tasks with full project context

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

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-56590b09/badge)](https://www.skillsdirectory.com/skills/mattnigh-collection-56590b09)

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: moai-alfred-clone-pattern
version: 1.0.0
created: 2025-11-05
updated: 2025-11-05
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
---

# Clone Pattern Skill

## Skill Metadata

| 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 |

---

## What It Does

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.

## When to Use

**Use Clone Pattern when:**
- Task requires 5+ steps OR affects 100+ files
- No domain-specific expertise needed (UI, Backend, DB, Security, ML)
- Task is complex with high uncertainty
- Parallel processing would be beneficial
- Full project context is required for optimal decisions

**Examples:**
- Large-scale migrations (v0.14.0 → v0.15.2)
- Refactoring across many files (100+ imports changes)
- Parallel exploration/evaluation tasks
- Complex architecture restructuring

## Key Concepts

### Master-Clone Architecture
```
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
```

### Clone vs Specialist Selection

| 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 |

## Implementation Rules

### Rule 1: Clone Creation Conditions
```python
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
        )
    )
```

### Rule 2: Clone Creation Method
```python
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
```

## Usage Examples

### Example 1: Large-Scale Migration
```python
# 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()
```

### Example 2: Parallel Processing Task
```python
# 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)
```

## Learning System

Clones save learnings to improve future similar tasks:

```python
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))
```

## Benefits

1. **Context Preservation**: Full project context vs domain-only
2. **Maximum Autonomy**: Goal-oriented vs instruction-oriented
3. **Parallel Scalability**: Multiple clones can run simultaneously
4. **Self-Learning**: Accumulated experience for future tasks

## Integration with Alfred Workflow

- Activated during 4-Step Workflow Logic (Step 1: Intent Understanding)
- Integrates with TRUST 5 principles
- Maintains @TAG chain integrity
- Works seamlessly with existing GitFlow

## References

- CLAUDE.md: Alfred's Hybrid Architecture
- Skill("moai-alfred-workflow"): 4-Step Workflow Logic
- Skill("moai-alfred-agent-guide"): 19 team members details

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.