| name | megacode-implementation |
| description | Focused code implementation in an assigned worktree. Keep diffs small, run targeted local tests, and report changed files. Enabled via implementer profile skills_allow. |
MegaCode Implementation
Role skill for the implementer profile. Execute approved plans inside an isolated worktree with minimal scope and auditable output.
Preconditions
- Operate only in the assigned worktree (
cwd injected by supervisor or workflow phase).
- Read the approved plan artifact or phase prompt before editing.
- Confirm worktree branch and run ID when reporting results.
Procedure
- Scope — implement exactly what the plan assigns; do not expand into refactors, docs, or unrelated fixes.
- Read first — inspect surrounding code and tests; match naming, types, and patterns already in the package.
- Edit minimally — prefer extending existing functions over new abstractions; keep the diff reviewable.
- Test incrementally — run targeted package tests after each logical chunk (see
megacode-testing).
- Stop on blockers — report missing dependencies, ambiguous requirements, or policy blocks instead of guessing.
Output contract
Return implementation_result JSON:
{
"status": "done | blocked | failed | needs_review",
"summary": "One paragraph on what changed and why",
"changed_files": ["packages/foo/src/bar.ts"],
"commands_run": ["pnpm test packages/foo"],
"tests_run": ["pnpm test packages/foo"],
"risks": [{"severity": "low", "description": "..."}],
"next_actions": []
}
Quality gates
| Gate | Requirement |
|---|
tests-run | At least one relevant local test command executed with exit code captured |
diff-summary | Every changed path listed with one-line intent |
Worktree rules
worktree_policy: required — never write in the main working tree.
- Refuse foldback if local verify fails; leave the worktree intact for inspection.
- Record branch name and worktree path in the summary.
Pairing
- Use
megacode-testing before claiming done.
- Escalate verify failures to
megacode-ci-fix with local terminal output only.
- After implementation, reviewer or
foldback_gate phases own merge approval.
Constraints
- Local CI only (
pnpm verify, npm test, npm run typecheck) — no GitHub Actions assumptions.
- No Agents SDK, no Linear, no remote CI polling.
- Do not force-push, hard-reset, or delete worktrees unless the user explicitly requests discard.