Use when porting code, features, or capabilities from one codebase/project to another — extracts exhaustive feature inventory, analyzes gaps against target, designs porting plan through adversarial critique loops, then implements via explore-critique-implement.
Port code between codebases through exhaustive extraction, adversarial critique, and gated implementation. Every step is a separate subagent. Main thread orchestrates only.
| Use | Skip |
|---|---|
| Porting features/capabilities between projects | Copy-pasting a single function |
| Migrating subsystems to new architecture | Trivial config transplant |
| Adopting patterns from a concrete source codebase | Rewriting from scratch (no source to port from) |
| Backporting fixes across forks | Mechanical file copy with no adaptation |
Every numbered phase below runs as a separate subagent. No agent serves dual roles. Main thread never implements — it spawns, reviews, and routes.
Propagate original user requirements verbatim to every subagent prompt.
When combined phase outputs exceed 6000 words, main thread summarizes before spawning the next agent. Preserve: all feature names, all verdicts with one-line reasoning, all MISSING/OVERTURN entries in full. Never silently drop features.
| Phase | Actor | Input | Output |
|---|---|---|---|
| 0 | Main thread | User request | Plan mode entered |
| 1 | Extraction agent | Source codebase + user scope | Feature inventory |
| 2 | Gap agent | Feature inventory + target codebase | Gap analysis |
| 3 | Critique agent | Inventory + gap analysis | Pruned/corrected list |
| 4 | Meta-critique agent | Inventory + gap analysis + critique | Validated critique |
| 5a | Plan designer agent | All prior outputs | Porting plan |
| 5b | Plan critic agent | Porting plan + all prior outputs | Approved/rejected plan |
| 5 | Loop 5a→5b | Until plan critic passes or 3 iterations | Final plan |
| 6 | Main thread | Final plan → user | User-approved plan |
| 7 | Per-task | explore-critique-implement per porting task | Landed changes |
Main thread enters plan mode before any work begins. All phases 1–5 execute within plan mode. Exit plan mode at Phase 6 for user review.
Spawn extraction agent. Prompt must include:
Extract the full semantic hierarchy from project root to modified parts:
Project: what it is, who it serves, core purpose
└── Module: what this module does within the project
└── Component: what this component does within the module
└── Modified parts: what changed and how it affects the component/module/project semantics
Every feature in the inventory must be anchored to its branch in this tree. Reviewers need to understand not just WHAT was changed but HOW it affects the system's meaning at every level.
| Field | Content |
|---|---|
| Feature | Name/identifier |
| Semantic path | Project → Module → Component (branch from tree above) |
| What | What it does |
| Why | Why it exists (user-facing purpose) |
| Semantic impact | How this feature affects the meaning/behavior of its parent module and the project |
| Dependencies | Internal and external deps |
| Complexity | S/M/L estimate with justification |
| Source files | Exact paths read |
Spawn a DIFFERENT agent — not the extraction agent.
Prompt must include:
Required output per feature:
| Field | Content |
|---|---|
| Feature | From inventory |
| Status | Present / Absent / Partial |
| Evidence | File paths and line references in target |
| If Absent | Why useful, what it enables |
| If Partial | What's missing, what exists |
| Porting cost | S/M/L estimate |
Word cap: 2000 words.
Spawn a DIFFERENT agent — not the extractor or gap analyzer.
Prompt must include:
Required output:
Word cap: 2000 words.
Spawn a DIFFERENT agent — not any prior agent.
Purpose: prevent single-critic bias. The Phase 3 critic may be too aggressive (pruning real features) or too lenient (rubber-stamping).
Prompt must include:
Required output:
Word cap: 1500 words.
Iterative loop, max 3 iterations.
Spawn plan designer agent. Prompt must include:
Required output:
| Field | Content |
|---|---|
| Task ID | Sequential |
| Feature(s) | Which features this task ports |
| Order | Execution order (respects dependencies) |
| Files | Create / modify / delete in target |
| Dependencies | Which prior tasks must complete first |
| Approach | How to port (adapt, rewrite, translate) |
| Risk | What could go wrong |
Word cap: 3000 words.
Spawn a DIFFERENT agent — not the plan designer.
Prompt must include:
Checks:
explore-critique-implement?Verdict: PASS (with NITs) or FAIL (with mandatory fixes). On FAIL, loop back to 5a with critic's feedback. Word cap: 1500 words.
Exit plan mode. Present the final plan to the user:
User may: approve all, approve subset, modify tasks, reject and restart.
Proceed only with user-approved tasks.
For each approved task, invoke explore-critique-implement. Each task goes through the full explore→critique→implement→review gate loop independently.
Per-task prompt must include:
explore-critique-implement handles coding-style loading per its own prerequisites.
Task ordering from Phase 5 is mandatory — do not parallelize tasks with dependencies.
Independent tasks (no dependency relationship) may run in parallel via agent-teams-execution.
| Trigger | Action |
|---|---|
| Phase 5 loop exhausted (3 iterations) | Present best plan + unresolved issues to user |
explore-critique-implement hard escalation | Report to user per that skill's escalation protocol |
| Feature extraction agent produces empty list | Verify scope with user before proceeding |
| Gap analysis finds all features already present | Report to user — nothing to port |
| Symptom | Fix |
|---|---|
| Main thread implementing instead of spawning agents | Stop. Main thread orchestrates only |
| Same agent doing extraction + gap analysis | Banned. Separate agents per phase |
| Feature list suspiciously short (<5 entries for non-trivial source) | Re-spawn extractor with "you are under-listing" |
| Critique agrees with everything | Re-spawn with harsher prompt: "zero survivors is valid" |
| Meta-critique rubber-stamps the critique | Re-spawn: "the critic may be wrong — prove it or prove they're right" |
| Skipping Phase 4 (meta-critique) | Never skip. Single-critic bias is the failure mode this prevents |
| Plan designer ignoring critic feedback in loop | Include critic feedback verbatim in 5a re-prompt |
Implementation skipping explore-critique-implement | Every porting task uses the full skill. No raw implementation |
| User requirements lost in subagent prompts | Propagate original requirements verbatim to every agent |
| Skill | Relationship |
|---|---|
explore-critique-implement | Phase 7 delegates each porting task to this skill. Full review gate per change. |
agent-teams-execution | Use for parallel independent porting tasks in Phase 7. |
harness-tuning | Apply when the porting target is a skill file, system prompt, or CLAUDE.md. |
superpowers:brainstorming | Use before this skill if user intent is unclear (what to port, why). |
proof-driven-development | Invoked inside explore-critique-implement for logic-bearing ported code. |