agy-codex
Skill3 starsChanged 5 days agoMITView on GitHub
Delegate a well-scoped coding or read-only investigation task from Codex to the local `agy` CLI. Implement tasks go through `agy-task run` (worktree, setup, scope check, compact summary; it runs no tests); read-only exploration through `agy-run`. Use only for self-contained tasks with a mechanical way to verify the result; never for architecture decisions or ambiguous requirements. agy runs with --dangerously-skip-permissions, so implement tasks run only in a dedicated git worktree and every prompt carries the HARD RULES block (`agy-task` adds it). The Claude Code skill is maintained separately as `agy`.
In this repositoryOne other file it gives its agents.
- agySkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 18
Report reset times to the user in UTC+7: Never read the contents of the oauth token file (only stat -c %Y).
- Very specific: line 26
Use: when the task is small and self-contained enough for one prompt with no back-and-forth, and either mechanically verifiable …
- Very specific: line 61
If agy-task is unavailable or too rigid: references/manual-worktree.md.
- Distinctive: line 71
After the helper reports the worker PID, give a short launch summary and end the turn.
- Very specific: line 76
Read the exit code and the filtered final result, including response.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Delegate work to agy from Codex
agy is a separate coding-agent CLI (~/.local/bin/agy). Launch it only through agy-task (implement) or agy-run (read-only). Paths like references/… are relative to this skill's base directory; read a reference file only when its situation comes up — they are kept out of this file on purpose to save context.
Invariants
- Model:
gemini-4-hydrogen-highonly (user rule 2026-11-27). Pass--model gemini-4-hydrogen-highexplicitly on every agy call (agy-task,agy-run, resume, fallback commands), never omit it (agy-rundefaults togemini-4-hydrogen-highsince 2026-11-27, but an explicit flag keeps every command self-describing). No other model, ever, unless the user explicitly asks: not the other Hydrogen tiers (gemini-4-hydrogen-{low,medium,xhigh}), notgemini-3.8-flash-*, notgemini-4-argon-*, Claude or GPT-OSS, not even for cross-checks or small tasks. There is no model fallback either: a sustained 503 means stop and tell the user, seereferences/503-fallback.md. - Never a bare
agy -p. agy >= 1.2.14 reads its login from the OS keyring and ignores the token file thatagyrswaps;agy-runneutralizes that and rotates accounts on 429. The user starts their own interactive agy with plainagyr, notagy. - Never trust agy's exit code or report.
agy-taskonly checks scope and runs no tests (verify step removed 2026-10-08); you read the diff and run the tests yourself. agy has reported green while tsc was broken, a resumed run can echo an old 429, and a content-filter block (agy >= 1.4.5/1.5.0) finishes withRESULT=OK, exit 0, andchanged files: (none)("This request was blocked by Gemini's filters…"). Always check that the worktree diff is non-empty. - Implement tasks only via
agy-task(it creates the worktree; never ask agy togit worktree add). Explore / bug-finding tasks target the main repo read-only viaagy-run --add-dir "$REPO"(always pass--add-dir: without it agy silently writes into~/.gemini/antigravity-cli/scratch/and still reports success). - One small task per session, exact files/lines in the task file (quota burns with context size;
references/logs-and-costs.md). At most 20 runs in parallel (user rule 2026-10-12, raised from 12;references/parallel.md). Checkpgrep -fc '^bash .*agy-(task run --name|run --prompt)'before launching more. Launch each task as its own separate tool call; never bundle tasks into a shell loop orwaitloop. For background work, prefer the per-task callback inreferences/callback.mdwhen the local app-server is available; if it is unavailable, explain the limitation and wait on the terminal session instead. Once all required callback jobs have started and the remaining work depends on their results, give a short launch summary and end the current turn. Do not poll status, logs or PIDs, or continue independent review while waiting, unless the user asks. - Task files and logs live in
<repo>/.agy-sessions/(gitignored), never/tmpor agy's scratch dir. Keep the logs, delete prompt files when done. Foragy-task, use the compact summary. Foragy-run, after it finishes, filter the JSONL locally and read only the finalresultevent; do not load the full log into Codex context. Inspect other log events only when needed to diagnose an error or missing result. Filtering locally does not itself consume agy model quota. - Report reset times to the user in UTC+7. Never read the contents of the oauth token file (only
stat -c %Y). - agy never runs tests (user rule 2026-10-08: test runs lag the machine). No prompt may ask agy to run tests, builds, type-checks or linters, not even "one test file": the HARD RULES blocks and the
agy-taskprompt tail forbid it, so the task file must not contradict that (write acceptance criteria as observable code behavior, never "makepnpm testpass").agy-taskhas no verify step either: Codex runs checks after agy has answered and the diff is read, one targeted command at a time (never several suites in parallel). - Locked accounts:
agyr lock <name>marks an account that must never be used for agy tasks (its quota is shared with another product).agy-run/agy-taskcheck this at start: if the active account is locked they rotate withagyr nextfirst (exit 5 if every unlocked account is on cooldown) and every 429 rotation skips locked accounts too. Neveragyr usea locked account before launching a task, never unlock one without the user asking, and do not useagyr rotate/agyr cooldownto get away from a locked account (that would put a cooldown on it);agyr use $(agyr next)is the way.agyr test(only when the user asks) deliberately tests locked accounts too, so it does spend their shared quota.
--dangerously-skip-permissions (passed by agy-run) is the user's choice (2026-09-25); safety comes from the worktree isolation, the HARD RULES block and the scope check. If Codex's policy blocks that flag, tell the user instead of working around it.
When to use / not
- Use when the task is small and self-contained enough for one prompt with no back-and-forth, and either mechanically verifiable (build/lint/test, diff mirrors an existing pattern) or a read-only investigation whose findings you can sanity-check; or when you want a real separate-process perspective.
- Don't for architecture/design decisions, security-sensitive code or nuanced judgment calls; anything you can't fully specify in one prompt (agy has zero context from this conversation); big multi-bug batches (split them); or when writing the task file takes the same research as doing it (then just do it). If you already found the exact line(s), edit directly.
Workflow: implement task (agy-task)
- Plan, don't over-specify (user rule 2026-09-25): goal, root cause / suspected area, relevant files, the pattern to mirror, acceptance criteria. Don't pre-trace every line or paste full code — Codex traces the code during review.
- Write ONLY the task part to
<repo>/.agy-sessions/<task>.task.txt: Repo/stack, Task, Plan, Acceptance criteria, an ENVIRONMENT NOTE ("the env is prepared; on an env failure STOP: no pnpm install, no symlinks, no copying from outside"). Do not write the working directory, scope, HARD RULES or verify list: the script adds them. Never tell agy to run or "make pass" any test/build/lint (invariant 8). - Launch with callback, one separate tool call per task. Read
references/callback.mdand use the helper below; do not launchagy-taskdirectly when callback is available. After the helper reports a worker PID, finish this turn once all tasks have launched. If sandbox permissions block access to the app-server socket or agy accounts, request the normal approval and retry the helper; do not treat a permission denial as a reason to bypass policy. If callback is genuinely unavailable or the user wants to wait directly, explain that and wait on the terminal session. Do not poll JSONL for routine progress:python3 "${AGY_SKILL_DIR:-$HOME/.agents/skills/agy-codex}/scripts/agy_callback.py" --name <task> --repo "$REPO" --result "$REPO/.agy-sessions/<task>.summary.txt" -- agy-task run --name <task> --task "$REPO/.agy-sessions/<task>.task.txt" --scope '<pathspec>' [--scope …] [--base <ref>] --model gemini-4-hydrogen-high--modeltakes the FULL model id from invariant 1 (gemini-4-hydrogen-high). The short wordshigh/hydrogenare not model names: agy rejects them at once witherror: invalid model selection (--model "high" …),turns=0, exit 1, the worktree stays clean, and the message is not a quota or login problem. Check the spelling of--modelfirst when a run fails this way.--base: commit-ish the worktree branches from (default:HEADof the current worktree). When running from a linked worktree (e.g. an MR/feature worktree) whose branch differs from the main checkout, ALWAYS pass--base <branch|sha>explicitly (e.g.--base HEADor--base $(git rev-parse --short HEAD)).agy-taskresolves git paths back to the repository's main checkout, so explicitly pinning--baseensures all parallel tasks branch from the exact target commit and prevents any risk of drifting to the main checkout's branch. Always give--scope(paths agy may change; a moved HEAD, i.e. an agy commit, is a violation too). Setup and file copies come from<repo>/.agy-sessions/agy-task.conf(any leftoverVERIFY/DEFAULT_VERIFYthere is ignored;--verify*flags no longer exist and fail with exit 2).agy-taskruns NO tests: you run them afterwards (step 5); when Go tests hit a shared dev DB, use a targetedcd backend && go test ./internal/foo/.... stdout = a compact summary, also saved as.agy-sessions/<task>.summary.txt; progress goes to stderr. The user can watch with the live command inreferences/logs-and-costs.md. Pre-flight note:agyr locked "$(agyr active)" && agyr use "$(agyr next)"is optional because agy-run does it itself; it only matters when you need to know which account will be used. Read the exit code and the summary:
exit Meaning Do 0 agy finished and scope is ok ( RESULT=OK); NOTHING was testedcheck changed filesis non-empty (if(none)with a "blocked by Gemini's filters" report, reword neutrally without exploit/race phrasing and rerun with--reuse-worktree --no-setup). Note: if an earlier turn hit 429 and rotated accounts, the summary may showagy: status=ERROR … - agy reported ERROR - check the diff before trusting itwhileRESULT=OKbecauseagyechoes the old quota error inresultJSON; review (step 5) and run the tests yourself8 RESULT=SCOPE_VIOLATIONread the violation lines; send agy a corrected follow-up (see "Correction round" below), don't hand-fix 7 setup failed (worktree kept) fix the environment, rerun with --reuse-worktree(setup reruns)2 bad arguments, config, or worktree/branch conflict fix the command 4 login error / no active account STOP, tell the user; references/quota-auth.md5 whole pool on cooldown STOP, tell the user the earliest reset (UTC+7); references/quota-auth.md1, 6 other agy failure / too many account switches first check changed files:andagy report:in the summary — if the edits and report are already complete (e.g. a stream timeout or interrupt echo at the very end), check scope/diff and run tests instead of redoing the task. Otherwise check the log forinvalid model selection(wrong--modelvalue, see step 3); a 503 →references/503-fallback.md(no switching to another model); other quota/auth errors →references/quota-auth.mdA 429 on one account is NOT a stop, and the user does not switch accounts for it.
agy-run(andagy-task, which calls it) kills agy at once, puts that account on cooldown from itsResets in, switches to the next ready account and resumes the same conversation by itself. So do not tell the user "out of quota, switch accounts" for a 429 and do not wait for them. Stop only on exit 4 (login) or exit 5 (every account on cooldown: tell the user the earliest reset in UTC+7). Never retry in a loop or fall back to doing the task yourself on 4/5.Correction round (review or your tests found a problem in what agy wrote): continue the SAME agy conversation, since agy wrote that code and its tests and remembers why. Write a short new task file (what is wrong, file/line, what it should do; the code already in the worktree is agy's earlier work, fix it, don't redo it) and run
agy-task run --name <task> --resume --task <new-task-file> --scope '<pathspec>' --model gemini-4-hydrogen-high.--resumetakes the conversation id from the lastinitevent of.agy-sessions/<task>.jsonland implies--reuse-worktree --no-setup; it exits 2 if there is no log or id. Use--reuse-worktree --no-setupWITHOUT--resume(fresh conversation) only when the old conversation went the wrong way or has grown huge (quota burns with context size). Same rules as any run: agy runs no tests, you review the diff and test again afterwards.Round limit: at most 2
--resumerounds per task. Before declaring a run stuck, checkgrep -c '^{' .agy-sessions/<task>.jsonlandtail -1(stderr /.erronly logs account switches and looks idle whilestep_updateevents are still growing). If the task still is not right after 2 rounds, or event count has stopped growing / produced no new file for ~10 min, stop it:kill -KILLthe agy-task, agy-run andagy --conversationpids (SIGTERM does not stop the child; exit 137 is then expected). Commit the reviewed good part onagy/<task>(the worktree branch, not the target branch) so nothing is lost, then start a fresh conversation on the same worktree with a narrow task file:agy-task run --name <task> --reuse-worktree --no-setup --task <narrow-task-file> --scope '<pathspec>' --model gemini-4-hydrogen-high. Put the exact facts agy kept searching for into that task file.- Review (tiered): mechanical change → summary + skim the diff + one targeted check; risky (auth, payment, migrations, concurrency) → read the full
git -C <repo>/.worktrees/agy-<task> diffand run the key checks yourself. Nothing has been tested before this point (neither agy noragy-taskruns tests), so this is the only test run: targeted, run in the worktree, one command at a time. agy reads code accurately but misjudges cross-file consequences and over-rates severity. Mutation-checking agy's tests: never undo the mutation withgit checkout -- <file>while agy's changes are uncommitted (it wipes them; happened 2026-09-29): copy the file to the scratchpad or commit first. Rungofmt -lon Go files agy touched. - Integrate and clean up: stage only in-scope files explicitly (never
git add -A), commit on the worktree branchagy/<task>(only when the user asks), cherry-pick/ff to the target branch, thenagy-task rm <task> -f(without-fit refuses after a cherry-pick: the commits are not reachable from HEAD). It keeps the logs/summary and appends nothing else;.agy-sessions/usage.tsvaccumulates tokens and seconds per task.
If agy-task is unavailable or too rigid: references/manual-worktree.md.
Workflow: explore / bug-finding task (read-only, agy-run)
Write the task part to .agy-sessions/<task>.task.txt (say which checks Codex already ran and point at exact files), append the read-only HARD RULES, then launch through the callback helper (pre-flight note: agyr locked "$(agyr active)" && agyr use "$(agyr next)" is optional because agy-run does it itself; it only matters when you need to know which account will be used). Read references/callback.md first:
{ cat "$REPO/.agy-sessions/<task>.task.txt"; echo; \
sed "s#<ABS_PATH>#$REPO#g" "${AGY_SKILL_DIR:-$HOME/.agents/skills/agy-codex}/references/hard-rules-explore.txt"; } > "$REPO/.agy-sessions/<task>.txt"
python3 "${AGY_SKILL_DIR:-$HOME/.agents/skills/agy-codex}/scripts/agy_callback.py" --name <task> --repo "$REPO" --result "$REPO/.agy-sessions/<task>.jsonl" -- agy-run --prompt "$REPO/.agy-sessions/<task>.txt" --add-dir "$REPO" --log "$REPO/.agy-sessions/<task>.jsonl" --model gemini-4-hydrogen-highAfter the helper reports the worker PID, give a short launch summary and end the turn; do not wait, inspect logs, or perform speculative review. Only after the callback arrives, inspect the result and working tree:
grep '^{' "$REPO/.agy-sessions/<task>.jsonl" | jq -cs '[.[] | select(.event=="result")] | last | if . == null then error("no result event") else .result | {status,response,finished_reason,error,num_turns,usage} end'
git -C "$REPO" status --short # must still be cleanRead the exit code and the filtered final result, including response; a missing result requires diagnosis and is not success. agy-run exit codes are the same as above (0 ok, 1, 2, 4, 5, 6). Check findings against the code before reporting them; delete the prompt files afterwards.
References (read on demand)
references/quota-auth.md— exit 4/5/6, 429, login, account pool (agyr), keyring trap, stale-429, auto-continue after a re-loginreferences/503-fallback.md— sustained 503 / stalled runs: no model fallback, retry rules, when to stop and tell the userreferences/parallel.md— running several tasks at once, integration, queueing many tasksreferences/logs-and-costs.md— stream-json events, jq commands, the--add-dirtrap, why quota burns, smoke testreferences/manual-worktree.md— the manual implement workflowagy-taskautomatesreferences/callback.md— run one task detached and notify the originating Codex thread when it finishesreferences/hard-rules-explore.txt— HARD RULES block for read-only tasks (<ABS_PATH>placeholder); the implement block is~/tools/agy-acct/templates/hard-rules.txt
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

