How amelnagdy/delegate-skills works
Purpose and Distribution
delegate-skills is a Skills CLI package for delegating coding tasks from an orchestrating agent to locally installed AI implementer CLIs. Its product boundary is a reviewed working-tree diff plus a normalized result report; relays never commit. Package installation and skill selection are documented in README.md; each installed skill is invoked by an orchestrator rather than through a central application binary.
Primary Entry Points
• Per-implementer instructions and CLI-specific policy live in skills/*-delegate/SKILL.md, e.g. skills/codex-delegate/SKILL.md and skills/claude-delegate/SKILL.md.
• Each implementer dispatches through its own Node relay, e.g. skills/codex-delegate/scripts/relay.mjs and skills/warp-delegate/scripts/relay.mjs.
• Fleet setup is a separate, non-dispatching entry point: skills/delegate-setup/SKILL.md.
• CI exercises relay behavior via .github/workflows/relays.yml.
Fleet Setup and Configuration Boundary
delegate-setup discovers installed implementer CLIs, proposes named lanes, obtains explicit approval, and writes global or project-scoped fleet configuration. It is intentionally isolated from task execution:
• Discovery/probing: skills/delegate-setup/scripts/discover.mjs
• Config validation, persistence, and overlays: skills/delegate-setup/scripts/config.mjs
• Lane resolution and wrong-implementer enforcement: skills/delegate-setup/scripts/lane.mjs
• Shared supported-implementer registry: skills/delegate-setup/scripts/implementers.mjs
Project lane configuration is approval/content-bound and fails closed when copied or edited without reapproval. A lane selects an implementer and optional dials; explicit relay flags override permitted lane dials.
Delegation Relay Contract
Every *-delegate relay has the same lifecycle: validate arguments and lane state, preflight the local CLI, provide a self-contained brief, launch the implementer in a target worktree, await/process output, inspect Git-visible changes, and atomically publish result.json. The uniform delegate-relay.result.v1 result includes status, exit/signal information, implementer report, touched files, and session data where available.
Representative implementations are skills/aider-delegate/scripts/relay.mjs, skills/claude-delegate/scripts/relay.mjs, and skills/zcode-delegate/scripts/relay.mjs. Relays use Node 18+ built-ins, local git, and the selected installed CLI; they make no independent network, credential, or telemetry calls.
Implementer Adapters and Safety Policy
Each relay is an adapter for a distinct external CLI and translates the shared concepts—write mode, read-only mode, models/effort, resume, structured output, timeout, and process termination—to vendor-specific flags and event formats. Supported external runtimes include Claude Code, Codex, Cursor Agent, OpenCode, Aider, Cline, Copilot CLI, Warp, and others, represented as parallel skill directories such as skills/cursor-delegate/, skills/opencode-delegate/, and skills/copilot-delegate/.
Safety is necessarily adapter-specific: some CLIs provide sandboxes or plan modes, while others only offer best-effort/read-only tripwires or full local-tool access. The universal hard boundary is that the relay does not issue commits; the reviewer runs project gates and lands changes.
Operational Flow and Human Boundary
The orchestrator writes a bounded brief, invokes either a direct implementer skill or a lane, then polls/reads the relay result. The implementer operates in a real local working tree. The orchestrator/reviewer subsequently inspects the diff, runs repository-specific validation, and commits if acceptable. Reusable orchestration guidance is packaged beside each adapter, for example skills/codex-delegate/references/dispatch-and-poll.md and skills/codex-delegate/references/review-and-land.md.
Verification Architecture
The repository uses Node-based contract, parity, isolated-process, timeout, abort, and smoke tests around the relay contract and platform launch behavior. Shared harness infrastructure is in test/harness/create-harness.mjs and test/harness/install-shim.mjs; broad relay coverage is organized through test/relay/index.mjs, with cross-adapter parity in test/relay-parity.mjs. This test structure is central because duplicated adapter scripts must preserve a common observable contract despite incompatible vendor CLIs.
Main entry points: relay.mjs Relay lifecycle · lane.mjs Lane resolution · index.mjs Relay contract suite · SKILL.md Setup skill
Components 19
Fleet setup
Separate configuration path; it does not dispatch tasks.
- Setup skill
skills/delegate-setup/SKILL.md - CLI discovery · Probes locally installed implementer CLIs.
skills/delegate-setup/scripts/discover.mjs - Fleet config · Validates, persists, and overlays approved fleet configuration.
skills/delegate-setup/scripts/config.mjs - Lane resolution · Resolves lanes and rejects the wrong implementer.
skills/delegate-setup/scripts/lane.mjs - Implementer registry
skills/delegate-setup/scripts/implementers.mjs
Delegation relays
Parallel adapter skills share one observable lifecycle.
- Implementer skills · Per-CLI policy and dispatch guidance.
skills/codex-delegate/SKILL.md - Relay lifecycle · Validates, preflights, launches, processes output, inspects Git, and publishes a normalized result.
skills/codex-delegate/scripts/relay.mjs - CLI adapter variants · Vendor-specific flag, event, safety, and termination translations preserve the shared contract.
skills/aider-delegate/scripts/relay.mjs - Dispatch guidance
skills/codex-delegate/references/dispatch-and-poll.md - Review guidance
skills/codex-delegate/references/review-and-land.md
Local execution and review
- Installed implementer CLI · Claude, Codex, Cursor, OpenCode, Aider, Copilot, Warp, or another supported CLI.
- Target working tree · Implementer modifies local files; relays never commit.
- Normalized result · Atomically published status, process outcome, report, changed files, and session data.
- Reviewer and project gates · Inspects the diff, runs repository validation, and decides whether to commit.
Contract verification
Tests enforce parity across duplicated adapter relays.
- Relay contract suite · Exercises contract, isolated-process, timeout, abort, and smoke behavior.
test/relay/index.mjs - Test harness
test/harness/create-harness.mjs - Cross-adapter parity · Checks that incompatible CLIs retain a common observable relay contract.
test/relay-parity.mjs - Relay CI
.github/workflows/relays.yml
Other components
- Orchestrator · Writes a bounded brief and invokes a direct skill or lane.
Connections 22
- Setup skill → CLI discovery: discovers
- CLI discovery → Implementer registry: matches
- Setup skill → Fleet config: writes after approval
- Implementer registry → Lane resolution: defines supported CLIs
- Fleet config → Lane resolution: provides approved lanes
- Orchestrator → Lane resolution: may select lane
- Orchestrator → Implementer skills: selects direct skill
- Dispatch guidance → Orchestrator: guides dispatch and polling
- Implementer skills → Relay lifecycle: dispatches
- Lane resolution → Relay lifecycle: resolves implementer and dials
- CLI adapter variants → Relay lifecycle: implements shared lifecycle
- Relay lifecycle → Installed implementer CLI: launches and controls
- Installed implementer CLI → Target working tree: edits
- Relay lifecycle → Target working tree: inspects Git-visible changes
- Relay lifecycle → Normalized result: atomically publishes
- Normalized result → Orchestrator: reports outcome
- Target working tree → Reviewer and project gates: diff for inspection
- Review guidance → Reviewer and project gates: guides review and landing
- Test harness → Relay contract suite: supports
- Relay contract suite → Cross-adapter parity: feeds shared cases
- Cross-adapter parity → CLI adapter variants: verifies contract parity
- Relay CI → Relay contract suite: runs