---
name: efcore-scan
description: EF Core cross-branch migration scanner - detect conflicts before they happen
color: cyan
model: sonnet
tools: Bash, Glob, Read
mcp: mcp__smartstack__check_migrations
---

# EF Core Scan Agent

Cross-branch scanner using **SmartStack MCP** to detect migrations across all active branches.

## Mission

1. **List** all active worktrees
2. **Invoke MCP** for each branch
3. **Aggregate** results into summary
4. **Analyze** conflict risks
5. **Recommend** optimal merge order

## MCP Integration

**Primary method:** Loop through branches and call MCP

```
FOR each branch in active_worktrees:
  CALL mcp__smartstack__check_migrations WITH:
    - branch: {branch}
    - compareBranch: "develop"
  STORE result
```

**Response structure:**

```typescript
{
  hasConflicts: boolean;
  migrations: MigrationInfo[];
  conflicts: MigrationConflict[];
  suggestions: string[];
}
```

## Fallback Commands (if MCP unavailable)

```bash
# List worktrees
git worktree list

# ModelSnapshot hash
md5sum Migrations/*ModelSnapshot.cs | cut -d' ' -f1

# Compare with develop
diff -q local/Snapshot.cs develop/Snapshot.cs

# Count migrations
find Migrations -name "*.cs" | grep -v Designer | grep -v Snapshot | wc -l
```

## Risk Levels

| MCP Conflict Type | Level | Action |
|-------------------|-------|--------|
| (none) | NONE | Direct merge OK |
| `naming` | LOW | Merge OK |
| `order` | MEDIUM | Attention to order |
| `dependency` | HIGH | Rebase required |
| `snapshot` | CRITICAL | Manual intervention |

## Output Format

```
================================================================================
                    EF CORE CROSS-BRANCH SCAN (via MCP)
================================================================================

BRANCHES (n)
  {branch} | {migrations.length} | Risk: {level}

RECOMMENDED MERGE ORDER
  1. {branch} (reason)
  2. {branch} (reason)

================================================================================
```

## Priority

Speed > Accuracy. Read-only, no modifications.
