Delegate coding tasks to agy-task from Claude Code

AI coding orchestrators such as Claude Code, Antigravity, and Gemini CLI can delegate implementation and exploration tasks to agy as a subagent. Using the agy skill and agyr, the orchestrator plans and reviews while agy executes in headless mode. This guide covers the reviewer/coder role split, agy-run vs agy-task, the worktree workflow, configuration options, scope checks, exit codes, and skill setup.

Role Split and Execution: Orchestrator vs Sub-Agent

The orchestrator configuration in skills/agy/ enforces a strict separation of concerns: the orchestrator agent acts as planner and reviewer, while agy operates as the sub-agent coder. The main agent does not edit project code directly, except when it has already traced the exact lines to change during investigation (where delegating would cost more than the fix). Otherwise, implementation tasks are dispatched through agy-task run, and read-only exploration through agy-run.

The orchestrator plans without over-specifying: it determines the goal, suspected area, relevant files, pattern to mirror, and acceptance criteria. Tasks run in dedicated git worktrees, launched individually in the background, and are verified with diffs and tests before integration.

The agy-task Workflow Step by Step

A typical implementation task follows six sequential stages:

  1. Task specification: Write the prompt body to a session file (e.g. .agy-sessions/auth-fix.task.txt).
  2. Launch task: Run agy-task run in the background:
    agy-task run --name auth-fix --task .agy-sessions/auth-fix.task.txt --scope 'src/auth/**' --model gemini-4-hydrogen-high
  3. Inspect diff: Read .agy-sessions/auth-fix.summary.txt and inspect git diff in .worktrees/agy-auth-fix.
  4. Correction rounds: Write follow-up prompt fix.txt and resume the session:
    agy-task run --name auth-fix --resume --task fix.txt --scope 'src/auth/**' --model gemini-4-hydrogen-high
    The --resume flag continues from the last init event in .agy-sessions/auth-fix.jsonl (implies --reuse-worktree --no-setup).
  5. Integrate: Review code changes, run project tests, and commit verified changes.
  6. Clean up: Remove the worktree and branch:
    agy-task rm auth-fix -f
    Deletes the worktree, branch, and prompt file, keeping audit logs (.jsonl, .summary.txt, .setup.log, usage.tsv). Without -f, it refuses (exit 2) if untracked changes exist or commits are unmerged.

Configuration File and Run Options

agy-task sources <repo>/.agy-sessions/agy-task.conf (or $AGY_TASK_CONF) defining:

See templates/agy-task.conf.example. Useful agy-task run options include:

Scope Checks, Forbidden Paths, and Summary Files

To prevent unintended changes, agy-task validates boundaries after execution:

The summary file .agy-sessions/NAME.summary.txt records status (RESULT=OK, RESULT=SCOPE_VIOLATION, RESULT=SETUP_FAILED, or RESULT=AGY_FAILED), metadata, turns, tokens, elapsed seconds, git diff --stat, scope details, up to 25 response lines, and log paths. Metrics are appended to usage.tsv.

agy-task Exit Codes

The table below lists exit codes returned by agy-task:

Code Origin Description
0 agy-task Success (run: no scope violation; rm: removed).
1 Propagated from agy-run General agy execution failure during task run.
2 agy-task Invalid arguments, configuration error, resume failure, or rm refused.
4 Propagated from agy-run Login error or no active Google account found.
5 Propagated from agy-run All accounts in the pool are exhausted (whole pool out of quota).
6 Propagated from agy-run Exceeded maximum account switches permitted per run (AGY_RUN_MAX_SWITCH, default 10).
7 agy-task Setup commands defined in SETUP_CMDS failed inside worktree.
8 agy-task Scope or forbidden-file violation detected (RESULT=SCOPE_VIOLATION).

Installing the agy Skill for AI Orchestrators

Install agyr using the unified installer:

curl -fsSL https://agyr.pages.dev/install.sh | bash

Copy skills/agy into your agent skills directory:

# Claude Code
mkdir -p ~/.claude/skills
cp -r ~/tools/agy-acct/skills/agy ~/.claude/skills/

# Antigravity / Gemini CLI
mkdir -p ~/.gemini/skills
cp -r ~/tools/agy-acct/skills/agy ~/.gemini/skills/

# Shared ~/.agents/skills convention
mkdir -p ~/.agents/skills
cp -r ~/tools/agy-acct/skills/agy ~/.agents/skills/

You can also add role-split rules from docs/agent-setup.md to CLAUDE.md, GEMINI.md, or AGENTS.md. Tasks automatically inherit templates/hard-rules.txt appended by agy-task. Run agyr help and bash test/run.sh to verify.

Related Guides

Additional resources for configuring Antigravity CLI rotation and agent workflows: