{"id":33560,"date":"2026-07-01T18:28:54","date_gmt":"2026-07-01T12:58:54","guid":{"rendered":"https:\/\/www.systweak.com\/blogs\/?p=33560"},"modified":"2026-07-02T11:20:17","modified_gmt":"2026-07-02T05:50:17","slug":"script-ai-agent-tasks-with-codex-gemini-claude","status":"publish","type":"post","link":"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/","title":{"rendered":"How to Script AI Agent Tasks With Codex, Gemini (agy), and Claude"},"content":{"rendered":"<div class=\"summary\">\n<p style=\"text-align: justify;\">If you automate work with CLI AI agents, you quickly hit the same wall: each agent takes its prompt, its working directory, and its role in a slightly different way, and the wrong shell or the wrong flag order silently breaks the whole run. This guide distills the rules that actually work on Windows, learned the hard way, so you can script a task once and hand it to whichever agent you prefer.<\/p>\n<\/div>\n<div class=\"note\" style=\"text-align: justify;\"><span data-sheets-root=\"1\"><div class=\"ntself\" style=\"border-left-color:#d10014;background: #f3e8e8;\">\n<\/span><strong>Example user:<\/strong>\u00a0all paths below use a fictional Windows user\u00a0<strong>John Smith<\/strong> &#8211; short username <code>jsmith<\/code>, long username\u00a0<code>johnsmith<\/code> (no spaces). Swap in your own username where you see these.<\/div>\n<div class=\"note\" style=\"text-align: justify;\"><\/div>\n<\/div>\n<div class=\"rule\" style=\"text-align: justify;\">\n<p><div class=\"ntself\" style=\"border-left-color:#d10014;background: #f3e8e8;\"><strong><br \/>\nGolden rule we learned the hard way:<\/strong>\u00a0use\u00a0<code>cmd<\/code>\u00a0(<code>.cmd<\/code>\u00a0batch files) to launch these CLIs,\u00a0<em>not<\/em>\u00a0PowerShell. The reason is stdin redirection and quoting (see Section 2).<br \/>\n<span data-sheets-root=\"1\"><\/div>\n<\/span><\/p>\n<\/div>\n<div class=\"warn\" style=\"text-align: justify;\">\n<p><span data-sheets-root=\"1\"><div class=\"ntself\" style=\"border-left-color:#d10014;background: #f3e8e8;\">\n<\/span>\u26a0\u00a0<strong>Safety &#8211; the examples run agents unattended.<\/strong>\u00a0They use\u00a0<code>--dangerously-bypass-approvals-and-sandbox<\/code>\u00a0(Codex),\u00a0<code>--dangerously-skip-permissions<\/code>\u00a0(agy), and\u00a0<code>--permission-mode bypassPermissions<\/code>\u00a0(Claude). These\u00a0<strong>turn off approval prompts and sandboxing<\/strong> so the agent can act on its own &#8211; Codex&#8217;s own help calls this &#8220;EXTREMELY DANGEROUS.&#8221; Use them only in a folder you trust, on work under version control that you can revert, never on a shared or production machine. Drop the flag (or use Codex <code>-s read-only<\/code>\u00a0\/ agy\u00a0<code>--sandbox<\/code>) when you want a safety net.<br \/>\n<span data-sheets-root=\"1\"><\/div>\n<\/span><\/p>\n<\/div>\n<h2 style=\"text-align: justify;\">1. The Three Clients at a Glance<\/h2>\n<div class=\"table-responsive\">\n<table>\n<thead>\n<tr>\n<th>Client<\/th>\n<th>Exe (portable form)<\/th>\n<th>Working dir set by<\/th>\n<th>Prompt in<\/th>\n<th>Instructions \/ params passed by<\/th>\n<th>&#8220;Done&#8221; signal<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>Codex<\/strong>\u00a0(OpenAI)<\/td>\n<td><code>%LOCALAPPDATA%\\Programs\\OpenAI\\Codex\\bin\\codex.exe<\/code><\/td>\n<td><code>-C \"&lt;dir&gt;\"<\/code>\u00a0flag<\/td>\n<td><code>&lt; prompt.txt<\/code>\u00a0(stdin)<\/td>\n<td>a\u00a0<strong>ROLE token<\/strong>\u00a0as one quoted positional arg<\/td>\n<td>state file ends\u00a0<code>RUN_STATUS: COMPLETE<\/code><\/td>\n<\/tr>\n<tr>\n<td><strong>agy<\/strong>\u00a0(Gemini)<\/td>\n<td><code>%LOCALAPPDATA%\\agy\\bin\\agy.exe<\/code><\/td>\n<td><code>pushd \"&lt;dir&gt;\"<\/code>\u00a0cwd, or\u00a0<code>--add-dir<\/code><\/td>\n<td><code>-p \"text\"<\/code>\u00a0<strong>arg only &#8211; no stdin<\/strong>\u00a0(see Section 3, \u2020)<\/td>\n<td><strong>no token<\/strong>\u00a0\u2192 uses its default role<\/td>\n<td>the output file it was told to write exists<\/td>\n<\/tr>\n<tr>\n<td><strong>Claude<\/strong>\u00a0(Claude Code)<\/td>\n<td><code>claude<\/code>\u00a0(must be on\u00a0<strong>PATH<\/strong>)<\/td>\n<td><code>pushd \"&lt;dir&gt;\"<\/code>\u00a0(uses cwd)<\/td>\n<td><code>&lt; prompt.txt<\/code>\u00a0(stdin)<\/td>\n<td>command-line\u00a0<strong>flags<\/strong>\u00a0(<code>--model<\/code>,\u00a0<code>--effort<\/code>, \u2026)<\/td>\n<td>state file ends\u00a0<code>RUN_STATUS: COMPLETE<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<style>\n.table-responsive {<br \/>     width: 100%;<br \/>     overflow-x: auto;<br \/>     -webkit-overflow-scrolling: touch;<br \/> } <\/p>\n<p> .table-responsive table {<br \/>     width: 100%;<br \/>     min-width: 700px;<br \/>     border-collapse: collapse;<br \/> }<br \/><\/style>\n<p style=\"text-align: justify;\"><strong><br \/>\nThe same brief file can feed all three &#8211; but they read it differently.<\/strong>\u00a0Codex and Claude read the prompt from\u00a0<strong>stdin<\/strong>\u00a0(<code>&lt; brief.txt<\/code>);\u00a0<strong>agy does not read stdin<\/strong> &#8211; you pass its prompt as the <code>-p<\/code>\u00a0argument, so for a long brief you tell agy\u00a0<em>&#8220;read brief.txt and follow it&#8221;<\/em>\u00a0(see Section 3 \u2020). The role is chosen differently too: Codex gets a ROLE token argument, agy uses its default, Claude is steered by flags.<\/p>\n<p><strong>Also Read: <\/strong><a href=\"https:\/\/www.systweak.com\/blogs\/stop-ai-agents-wasting-tokens-in-document-pipelines\/\" target=\"_blank\" rel=\"noopener\">Stop AI Agents Wasting Tokens in Document Pipelines<\/a><\/p>\n<h2 style=\"text-align: justify;\">2. Which shell &#8211; cmd vs PowerShell (the main question)<\/h2>\n<h3 style=\"text-align: justify;\">Use cmd (.cmd batch) to launch the three CLIs. Always.<\/h3>\n<p style=\"text-align: justify;\">Three concrete reasons:<\/p>\n<ol style=\"text-align: justify;\">\n<li><strong>Stdin redirection\u00a0<code>&lt; prompt.txt<\/code>.<\/strong> Codex and Claude read the big prompt from standard input (agy is the exception &#8211; it takes its prompt as the <code>-p<\/code>\u00a0argument, see Section 3).<br \/>\ncmd: <code>codex.exe exec ... &lt; \"%PROMPT%\"<\/code> &#8211;\u00a0 works.<\/p>\n<ul>\n<li>PowerShell:\u00a0<strong><code>&lt;<\/code>\u00a0is not supported<\/strong>\u00a0(PowerShell reserves it and errors). You&#8217;d have to rewrite every call as\u00a0<code>Get-Content prompt.txt | codex.exe ...<\/code>, which changes encoding\/newline handling and is easy to get wrong. Not worth it.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Quoting the ROLE token.<\/strong>\u00a0Codex takes one big quoted argument like\u00a0<code>\"ROLE=DRAFTER. Write the blog post described on stdin; save it as draft.md.\"<\/code>. cmd passes it verbatim inside\u00a0<code>\"...\"<\/code>. PowerShell would re-parse\u00a0<code>=<\/code>,\u00a0<code>;<\/code>, and quotes differently.<\/li>\n<li><strong>The whole toolchain is already batch.<\/strong>\u00a0Loops, resume logic, and state checks all use cmd features (<code>for %%F<\/code>,\u00a0<code>findstr<\/code>,\u00a0<code>!ERRORLEVEL!<\/code>). Mixing shells adds bugs, not value.<\/li>\n<\/ol>\n<h3 style=\"text-align: justify;\">Use PowerShell only for Windows-admin tasks, not for launching the agents.<\/h3>\n<p style=\"text-align: justify;\">Good PowerShell jobs: editing the user\u00a0<strong>PATH<\/strong>, environment variables, service\/registry work, anything with no clean cmd equivalent. Example we actually used: adding claude&#8217;s folder to PATH with\u00a0<code>[Environment]::SetEnvironmentVariable(\"Path\", \u2026, \"User\")<\/code>\u00a0because\u00a0<code>setx<\/code>\u00a0truncates a long PATH.<\/p>\n<h3 style=\"text-align: justify;\">Use neither for searching files.<\/h3>\n<p style=\"text-align: justify;\">For find\/grep\/walk use\u00a0<code>rg<\/code>\u00a0\/\u00a0<code>fd<\/code>, not PowerShell loops.<\/p>\n<div class=\"rule\" style=\"text-align: justify;\">\n<p><strong>One-line rule:<\/strong>\u00a0<em>cmd launches the AI. PowerShell configures Windows. rg\/fd search files.<\/em><\/p>\n<\/div>\n<h2 style=\"text-align: justify;\">3. Sample commands (copy-paste, dummy data)<\/h2>\n<p style=\"text-align: justify;\">These are\u00a0<strong>self-contained<\/strong> &#8211; you do <strong>not<\/strong>\u00a0need any of this repo&#8217;s\u00a0<code>.cmd<\/code>\u00a0files to use them. Replace the dummy values with your own:<\/p>\n<table>\n<thead>\n<tr>\n<th>Dummy value used below<\/th>\n<th>Means<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>C:\\work\\project<\/code><\/td>\n<td>the folder the agent should work in<\/td>\n<\/tr>\n<tr>\n<td><code>C:\\work\\prompt.txt<\/code><\/td>\n<td>your prompt \/ instructions file (big prompts live here)<\/td>\n<\/tr>\n<tr>\n<td><code>C:\\work\\out.jsonl<\/code>\u00a0,\u00a0<code>C:\\work\\out.err.log<\/code><\/td>\n<td>where stdout \/ stderr are saved<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"note\" style=\"text-align: justify;\">\n<p><span data-sheets-root=\"1\"><div class=\"ntself\" style=\"border-left-color:#d10014;background: #f3e8e8;\"><\/span><br \/>\nThe exe paths use\u00a0<code>%LOCALAPPDATA%<\/code>\u00a0so they work for any Windows username. Run these in\u00a0<strong>cmd<\/strong>\u00a0(a\u00a0<code>.bat<\/code>\/<code>.cmd<\/code>\u00a0file or a\u00a0<code>cmd.exe<\/code>\u00a0window), not PowerShell (see Section 2).<br \/>\n<span data-sheets-root=\"1\"><\/div>\n<\/span><\/p>\n<\/div>\n<h3 style=\"text-align: justify;\">Codex (baseline \/ generate) &#8211; sets its own dir with <code>-C<\/code><\/h3>\n<pre style=\"background: #1e1e1e; color: #e6e6e6; padding: 20px; border-radius: 8px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.6; overflow-x: auto; white-space: pre;\">set \"CODEX=%LOCALAPPDATA%\\Programs\\OpenAI\\Codex\\bin\\codex.exe\"\r\n\r\n\"%CODEX%\" exec --json --skip-git-repo-check --dangerously-bypass-approvals-and-sandbox ^\r\n  -c model_reasoning_effort=high -C \"C:\\work\\project\" ^\r\n  \"ROLE=BASELINE. Follow the prompt on stdin in full; keep every detail.\" ^\r\n  &lt; \"C:\\work\\prompt.txt\" &gt; \"C:\\work\\out.jsonl\" 2&gt; \"C:\\work\\out.err.log\"<\/pre>\n<ul style=\"text-align: justify;\">\n<li><code>exec<\/code>\u00a0= non-interactive run.\u00a0<code>--json<\/code>\u00a0= machine-readable event stream.<\/li>\n<li><code>--skip-git-repo-check<\/code>\u00a0+\u00a0<code>--dangerously-bypass-approvals-and-sandbox<\/code>\u00a0= unattended, no prompts.<\/li>\n<li><code>-c model_reasoning_effort=high<\/code>\u00a0= a config key\/value (<code>xhigh<\/code>\u00a0deeper,\u00a0<code>low<\/code>\u00a0cheap).<\/li>\n<li><code>-C \"C:\\work\\project\"<\/code>\u00a0=\u00a0<strong>Codex is the only one that takes a working-dir flag.<\/strong><\/li>\n<li>The quoted\u00a0<code>\"ROLE=...\"<\/code> string = the instruction token, one quoted arg &#8211; <strong>this is how you steer Codex.<\/strong>\u00a0Put a short instruction here; the bulk of the task goes in the prompt file.<\/li>\n<li><strong>Cheap ping<\/strong>\u00a0(prompt read from stdin as\u00a0<code>-<\/code>, read-only):\n<pre style=\"background: #1e1e1e; color: #e6e6e6; padding: 20px; border-radius: 8px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.6; overflow-x: auto; white-space: pre;\">echo Reply with exactly: PONG_CODEX | \"%CODEX%\" exec --skip-git-repo-check -s read-only -c model_reasoning_effort=low -<\/pre>\n<\/li>\n<\/ul>\n<h3 style=\"text-align: justify;\">agy \/ Gemini &#8211; works in the current folder or <code>--add-dir<\/code><\/h3>\n<p style=\"text-align: justify;\"><strong>Flag order matters:<\/strong>\u00a0<code>-p<\/code>\u00a0grabs\u00a0<em>the very next token<\/em>\u00a0as its prompt, so put every other flag\u00a0<strong>before<\/strong>\u00a0<code>-p<\/code>\u00a0and the quoted prompt\u00a0<strong>immediately after<\/strong>\u00a0it.<\/p>\n<pre style=\"background: #1e1e1e; color: #e6e6e6; padding: 20px; border-radius: 8px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.6; overflow-x: auto; white-space: pre;\">set \"AGY=%LOCALAPPDATA%\\agy\\bin\\agy.exe\"\r\n\r\nREM (a) SHORT prompt - prompt is the argument to -p, all other flags first:\r\n\"%AGY%\" --dangerously-skip-permissions -p \"Reply exactly: PONG\"\r\n\r\nREM (b) BIG instructions - agy can't read stdin, so point it at the file instead:\r\npushd \"C:\\work\\project\"\r\n\"%AGY%\" --dangerously-skip-permissions --log-file \"agy.log\" -p \"Read C:\\work\\prompt.txt and follow it exactly.\" &gt; \"agy-out.log\" 2&gt;&amp;1\r\npopd<\/pre>\n<p style=\"text-align: justify;\"><strong>Do NOT<\/strong>\u00a0write\u00a0<code>agy -p --dangerously-skip-permissions \"...\"<\/code>\u00a0(then\u00a0<code>-p<\/code>\u00a0eats\u00a0<code>--dangerously-skip-permissions<\/code>\u00a0as its prompt) or\u00a0<code>agy -p &lt; file<\/code>\u00a0(fails:\u00a0<code>flag needs an argument: -p<\/code>).<\/p>\n<p style=\"text-align: justify;\"><strong>Verified flag list<\/strong>\u00a0(from\u00a0<code>agy --help<\/code>):<\/p>\n<table>\n<thead>\n<tr>\n<th>Flag<\/th>\n<th>Meaning<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>-p<\/code>\u00a0\/\u00a0<code>--print<\/code><\/td>\n<td>run one prompt non-interactively &#8211; <strong>the prompt is this flag&#8217;s argument; agy never reads stdin<\/strong><\/td>\n<\/tr>\n<tr>\n<td><code>--prompt<\/code><\/td>\n<td><strong>alias for\u00a0<code>--print<\/code><\/strong><\/td>\n<\/tr>\n<tr>\n<td><code>-i<\/code>\u00a0\/\u00a0<code>--prompt-interactive<\/code><\/td>\n<td>run an initial prompt, then stay interactive<\/td>\n<\/tr>\n<tr>\n<td><code>-c<\/code>\u00a0\/\u00a0<code>--continue<\/code><\/td>\n<td>continue the most recent conversation<\/td>\n<\/tr>\n<tr>\n<td><code>--conversation &lt;id&gt;<\/code><\/td>\n<td>resume a specific conversation by ID<\/td>\n<\/tr>\n<tr>\n<td><code>--project &lt;id&gt;<\/code>\u00a0\/\u00a0<code>--new-project<\/code><\/td>\n<td>pick \/ create a project context<\/td>\n<\/tr>\n<tr>\n<td><code>--add-dir &lt;path&gt;<\/code><\/td>\n<td>add a directory to the workspace (repeatable) &#8211; the alternative to <code>pushd<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>--model \"&lt;name&gt;\"<\/code><\/td>\n<td>pick model (list them with\u00a0<code>agy models<\/code>)<\/td>\n<\/tr>\n<tr>\n<td><code>--print-timeout 10m<\/code><\/td>\n<td>how long print mode waits (default\u00a0<strong>5m<\/strong>)<\/td>\n<\/tr>\n<tr>\n<td><code>--log-file &lt;path&gt;<\/code><\/td>\n<td>write the CLI log (essential for debugging &#8211; see below)<\/td>\n<\/tr>\n<tr>\n<td><code>--dangerously-skip-permissions<\/code><\/td>\n<td>auto-approve all tool actions<\/td>\n<\/tr>\n<tr>\n<td><code>--sandbox<\/code><\/td>\n<td>run with terminal restrictions (use this to limit what it can touch)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align: justify;\"><strong>\u2020 How the prompt is passed &#8211; this is the subtle part (verified on this install):<\/strong><\/p>\n<ul style=\"text-align: justify;\">\n<li><strong>agy&#8217;s prompt is ALWAYS the\u00a0<code>-p<\/code>\u00a0argument.<\/strong>\u00a0It does\u00a0<strong>not<\/strong>\u00a0read stdin.\u00a0<code>agy -p &lt; file.txt<\/code>\u00a0fails with\u00a0<code>flag needs an argument: -p<\/code>, and\u00a0<code>agy -p --flag \"text\"<\/code>\u00a0mis-parses (the flag becomes the prompt). Always:\u00a0<em>other flags first, then\u00a0<code>-p \"your prompt\"<\/code>.<\/em><\/li>\n<li><strong>Short prompt \u2192 inline:<\/strong>\u00a0<code>agy --dangerously-skip-permissions -p \"Reply exactly: PONG\"<\/code>.<\/li>\n<li><strong>Long instructions \u2192 point agy at a file:<\/strong>\u00a0keep the\u00a0<code>-p<\/code>\u00a0prompt short and let agy open the file itself:\u00a0<code>-p \"Read C:\\work\\prompt.txt and follow it exactly.\"<\/code>\u00a0This sidesteps the ~8191-char cmd argument limit\u00a0<em>and<\/em> the no-stdin limitation. (Codex and Claude differ &#8211; they <strong>do<\/strong>\u00a0take the big prompt on stdin via\u00a0<code>&lt; file<\/code>.)<\/li>\n<\/ul>\n<div class=\"warn\" style=\"text-align: justify;\">\n<p><span data-sheets-root=\"1\"><div class=\"ntself\" style=\"border-left-color:#d10014;background: #f3e8e8;\">\n<\/span><\/p>\n<p>\u26a0\u00a0<strong>Known agy issue on Windows (found 2026-07-01, confirm before trusting print output):<\/strong><\/p>\n<ul>\n<li>In print mode agy\u00a0<strong>authenticated and sent the prompt but printed no response text<\/strong>. The\u00a0<code>--log-file<\/code> showed a Windows path bug &#8211; it tried to open a Unix-style path <code>\/Users\/johnsmith\/.gemini\/antigravity-cli\/...\/transcript.jsonl<\/code>.<\/li>\n<li>Practical rule:\u00a0<strong>judge agy by the files it wrote, never by stdout.<\/strong>\u00a0Add\u00a0<code>--log-file<\/code>\u00a0to any agy run you need to debug. Spot-check the first output file it writes for real substance.<\/li>\n<li><strong>agy is not read-only.<\/strong>\u00a0During a bare &#8220;ping&#8221; it left a source file modified. If you don&#8217;t want it changing files, add\u00a0<code>--sandbox<\/code>\u00a0(and check your VCS status, e.g.\u00a0<code>git status<\/code>\u00a0\/\u00a0<code>svn status<\/code>, after a run).<\/li>\n<\/ul>\n<p><span data-sheets-root=\"1\"><\/div>\n<\/span><\/p>\n<\/div>\n<h3 style=\"text-align: justify;\">Claude Code (final master) &#8211; runs in the current folder, must be on PATH<\/h3>\n<pre style=\"background: #1e1e1e; color: #e6e6e6; padding: 20px; border-radius: 8px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.6; overflow-x: auto; white-space: pre;\">pushd \"C:\\work\\project\"\r\n\r\nclaude -p --input-format text --model opus --effort high ^\r\n  --permission-mode bypassPermissions --output-format stream-json --verbose ^\r\n  &lt; \"C:\\work\\prompt.txt\" &gt; \"out.jsonl\" 2&gt; \"out.err.log\"\r\n\r\npopd<\/pre>\n<ul style=\"text-align: justify;\">\n<li><code>-p<\/code>\u00a0= print\/non-interactive.\u00a0<code>--input-format text<\/code>\u00a0= stdin is the plain prompt.<\/li>\n<li><code>--model opus<\/code>\u00a0= the model.\u00a0<code>--effort max|xhigh|low<\/code>. (<code>claude --help<\/code>\u00a0\/ your model list shows valid names; some installs also accept\u00a0<code>opus[1m]<\/code> for a 1-million-token context &#8211; install-specific, so use plain <code>opus<\/code>\u00a0unless you know\u00a0<code>[1m]<\/code>\u00a0works on yours.)<\/li>\n<li><code>--permission-mode bypassPermissions<\/code>\u00a0= no approval prompts (needed for unattended runs).<\/li>\n<li><code>--output-format stream-json --verbose<\/code>\u00a0= full event log to the\u00a0<code>.jsonl<\/code>.<\/li>\n<li><strong>Claude is called bare (<code>claude<\/code>), so its folder must be on PATH.<\/strong> If PATH is wrong you get &#8220;&#8216;claude&#8217; is not recognized&#8221; &#8211; the single most common breakage after a reinstall.<\/li>\n<\/ul>\n<h2 style=\"text-align: justify;\">4. Things to keep in mind (the traps we hit)<\/h2>\n<h3 style=\"text-align: justify;\">Paths \/ install<\/h3>\n<ul style=\"text-align: justify;\">\n<li><strong>Never hardcode\u00a0<code>C:\\Users\\&lt;name&gt;\\\u2026<\/code>.<\/strong>\u00a0A username change (<code>jsmith<\/code>\u00a0\u2192\u00a0<code>johnsmith<\/code>) broke every old script. The fix is\u00a0<code>%LOCALAPPDATA%<\/code> &#8211; it resolves per-user automatically, so scripts survive a reinstall or username change. Prefer that form.<\/li>\n<li><strong><code>claude<\/code>\u00a0must be on PATH.<\/strong>\u00a0Add its folder (e.g.\u00a0<code>C:\\Users\\johnsmith\\.local\\bin<\/code>) via PowerShell&#8217;s\u00a0<code>[Environment]::SetEnvironmentVariable(..., \"User\")<\/code>.\u00a0<strong>Do not use\u00a0<code>setx<\/code><\/strong> if PATH is long &#8211; it truncates at 1024 chars.<\/li>\n<li>A PATH change only applies to\u00a0<strong>new<\/strong>\u00a0terminal windows.<\/li>\n<\/ul>\n<h3 style=\"text-align: justify;\">Batch (cmd) syntax that matters<\/h3>\n<ul style=\"text-align: justify;\">\n<li>Start scripts with\u00a0<code>setlocal enabledelayedexpansion<\/code>, then read changing vars as\u00a0<code>!VAR!<\/code>\u00a0inside loops\/<code>if<\/code>\u00a0blocks. Plain\u00a0<code>%VAR%<\/code>\u00a0is frozen at parse time and will be stale inside a\u00a0<code>for<\/code>\/<code>if<\/code>.<\/li>\n<li>Line-continue with\u00a0<code>^<\/code>\u00a0at end of line; escape specials as\u00a0<code>^|<\/code>,\u00a0<code>^&lt;<\/code>,\u00a0<code>^&gt;<\/code>,\u00a0<code>^&amp;<\/code>.<\/li>\n<li>Redirection:\u00a0<code>&gt; out<\/code>\u00a0(stdout),\u00a0<code>2&gt; err<\/code>\u00a0(stderr),\u00a0<code>2&gt;&amp;1<\/code>\u00a0(merge). All three clients log this way.<\/li>\n<li><code>pushd \"%DIR%\"<\/code>\u00a0\u2026\u00a0<code>popd<\/code>\u00a0to run a tool &#8220;in&#8221; a folder (agy and Claude need this; Codex uses\u00a0<code>-C<\/code>).<\/li>\n<li><code>chcp 65001 &gt;nul<\/code> at the top forces UTF-8 (the Claude ping does this) &#8211; avoids mangled characters.<\/li>\n<li>Check a state file with\u00a0<code>findstr \/c:\"RUN_STATUS: COMPLETE\" \"%DIR%\\...STATE.md\"<\/code>.<\/li>\n<\/ul>\n<h3 style=\"text-align: justify;\">Running \/ limits<\/h3>\n<ul style=\"text-align: justify;\">\n<li><strong>Exit code is the quota signal.<\/strong>\u00a0Non-zero from any client usually means the plan limit was hit; the scripts stop cleanly and\u00a0<strong>resume on re-run<\/strong> &#8211; they never spin.<\/li>\n<li><strong>Claude: run ONE instance at a time<\/strong>\u00a0(single window). Parallel Claude burns through your plan limits faster.<\/li>\n<li><strong>Codex \/ agy can run two at once<\/strong>\u00a0by splitting the work into odd\/even slices (two windows). But\u00a0<strong>one writer per state file<\/strong> &#8211; two Codex processes writing the same folder corrupt the state.<\/li>\n<li><strong>Resume signals differ:<\/strong>\u00a0for long jobs, decide what &#8220;done&#8221; means. Codex &amp; Claude can write a state file you grep for (e.g. ends with\u00a0<code>RUN_STATUS: COMPLETE<\/code>); for agy, check that the output file it was told to write now exists. A small\u00a0<code>done.OK<\/code>\u00a0marker file lets a finished folder be skipped on re-run.<\/li>\n<\/ul>\n<h3 style=\"text-align: justify;\">Prompts \/ instructions<\/h3>\n<ul style=\"text-align: justify;\">\n<li><strong>Codex &amp; Claude take a big prompt on stdin<\/strong>\u00a0(<code>&lt; prompt.txt<\/code>) &#8211; the real prompt files are tens of KB, past the ~8191-char cmd argument limit, so stdin is the only option for them.<\/li>\n<li><strong>agy is different: it does NOT read stdin.<\/strong>\u00a0Its prompt is the\u00a0<code>-p<\/code>\u00a0argument. For big instructions, keep\u00a0<code>-p<\/code>\u00a0short and point agy at the file:\u00a0<code>-p \"Read C:\\work\\prompt.txt and follow it exactly.\"<\/code>\u00a0Put all other flags\u00a0<strong>before<\/strong>\u00a0<code>-p<\/code>\u00a0(see Section 3 \u2020).<\/li>\n<li>Pick the role by the mechanism each client uses:\u00a0<strong>Codex = ROLE token arg<\/strong>,\u00a0<strong>agy = default (no token)<\/strong>,\u00a0<strong>Claude = flags<\/strong>. Same task, three different &#8220;steer&#8221; mechanisms.<\/li>\n<li><strong>agy print mode can send but print nothing on Windows (path bug) and can edit files<\/strong> &#8211; verify by output files, add <code>--log-file<\/code>, and use\u00a0<code>--sandbox<\/code>\u00a0if it must not touch anything (see Section 3).<\/li>\n<\/ul>\n<h2 style=\"text-align: justify;\">5. Quick smoke test before any big run (standalone pings)<\/h2>\n<p style=\"text-align: justify;\">Run each; a healthy client echoes the token back.<\/p>\n<pre style=\"background: #1e1e1e; color: #e6e6e6; padding: 20px; border-radius: 8px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.6; overflow-x: auto; white-space: pre;\">REM --- Codex: expect PONG_CODEX ---\r\necho Reply with exactly: PONG_CODEX | \"%LOCALAPPDATA%\\Programs\\OpenAI\\Codex\\bin\\codex.exe\" exec --skip-git-repo-check -s read-only -c model_reasoning_effort=low -\r\n\r\nREM --- agy: expect PONG (flags first, then -p \"prompt\"; see the Windows print bug in section 3) ---\r\n\"%LOCALAPPDATA%\\agy\\bin\\agy.exe\" --dangerously-skip-permissions --new-project --print-timeout 1m --log-file \"agy-ping.log\" -p \"Reply exactly: PONG\"\r\n\r\nREM --- Claude: expect PING_PONG_OK ---\r\necho Reply exactly: PING_PONG_OK and nothing else.&gt; ping.txt\r\nclaude -p --input-format text --model opus --effort low --permission-mode bypassPermissions --output-format stream-json --verbose &lt; ping.txt<\/pre>\n<p style=\"text-align: justify;\">If a ping fails: check the exe path (does\u00a0<code>%LOCALAPPDATA%<\/code>\u00a0resolve to your install?), check\u00a0<code>claude<\/code>\u00a0is on PATH, and open the\u00a0<code>.err.log<\/code>\u00a0\/\u00a0<code>--log-file<\/code>\u00a0output.<\/p>\n<h2 style=\"text-align: justify;\">6. Worked example &#8211; script a blog post (draft \u2192 revise \u2192 polish)<\/h2>\n<p style=\"text-align: justify;\">Goal: turn one idea into a finished blog post for your website, unattended, by chaining the three clients. Each does one stage:\u00a0<strong>Codex drafts \u2192 agy revises \u2192 Claude polishes.<\/strong>\u00a0They hand off through files in a shared folder, and each stage reads its own small instruction file.<\/p>\n<h3 style=\"text-align: justify;\">Step 1 &#8211; write three instruction files<\/h3>\n<p style=\"text-align: justify;\">Put these in\u00a0<code>C:\\work\\blog\\<\/code>. Each one is a plain-text brief (the &#8220;prompt&#8221;):<\/p>\n<p style=\"text-align: justify;\"><code>1-draft.txt<\/code><\/p>\n<pre style=\"background: #1e1e1e; color: #e6e6e6; padding: 20px; border-radius: 8px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.6; overflow-x: auto; white-space: pre;\">Write a first-draft blog post for our company website. Topic: \"Why small businesses should archive their email\". Audience: non-technical small-business owners. Tone: friendly, practical. Length: ~700 words. Format: Markdown - one H1 title, 3-4 H2 sections, a short closing call-to-action. Save the result as draft.md in the current folder. Do nothing else.<\/pre>\n<p style=\"text-align: justify;\"><code>2-revise.txt<\/code><\/p>\n<pre style=\"background: #1e1e1e; color: #e6e6e6; padding: 20px; border-radius: 8px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.6; overflow-x: auto; white-space: pre;\">Read draft.md in the current folder. Improve it: tighten the intro, add one concrete example per section, and make the call-to-action specific. Keep it ~700 words and the same Markdown structure. Save the improved version as revised.md. Do nothing else.<\/pre>\n<p style=\"text-align: justify;\"><code>3-polish.txt<\/code><\/p>\n<pre style=\"background: #1e1e1e; color: #e6e6e6; padding: 20px; border-radius: 8px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.6; overflow-x: auto; white-space: pre;\">Read revised.md in the current folder. Do a final copy-edit: fix grammar, cut filler, ensure the H1 and headings read well, and verify the tone is friendly and clear. Save the final as final.md. Do nothing else.<\/pre>\n<h3 style=\"text-align: justify;\">Step 2 &#8211; one batch file to run the pipeline<\/h3>\n<p style=\"text-align: justify;\">Save as\u00a0<code>write-blog.cmd<\/code>\u00a0and run it from a\u00a0<code>cmd<\/code>\u00a0window (<code>write-blog.cmd<\/code>):<\/p>\n<pre style=\"background: #1e1e1e; color: #e6e6e6; padding: 20px; border-radius: 8px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.6; overflow-x: auto; white-space: pre;\">@echo off\r\nsetlocal enabledelayedexpansion\r\nset \"WORK=C:\\work\\blog\"\r\nset \"CODEX=%LOCALAPPDATA%\\Programs\\OpenAI\\Codex\\bin\\codex.exe\"\r\nset \"AGY=%LOCALAPPDATA%\\agy\\bin\\agy.exe\"\r\n\r\necho [1\/3] Codex drafting...\r\n\"%CODEX%\" exec --json --skip-git-repo-check --dangerously-bypass-approvals-and-sandbox ^\r\n  -c model_reasoning_effort=high -C \"%WORK%\" ^\r\n  \"ROLE=DRAFTER. Follow the brief on stdin and write the file it names.\" ^\r\n  &lt; \"%WORK%\\1-draft.txt\" &gt; \"%WORK%\\codex.jsonl\" 2&gt; \"%WORK%\\codex.err.log\"\r\n\r\necho [2\/3] agy revising...\r\npushd \"%WORK%\"\r\n\"%AGY%\" --dangerously-skip-permissions --log-file \"agy.log\" -p \"Read 2-revise.txt in this folder and follow it exactly.\" &gt; \"agy.out.log\" 2&gt;&amp;1\r\npopd\r\n\r\necho [3\/3] Claude polishing...\r\npushd \"%WORK%\"\r\nclaude -p --input-format text --model opus --effort high ^\r\n  --permission-mode bypassPermissions --output-format stream-json --verbose ^\r\n  &lt; \"3-polish.txt\" &gt; \"claude.jsonl\" 2&gt; \"claude.err.log\"\r\npopd\r\n\r\necho Done. Final post: %WORK%\\final.md\r\ndir \/b \"%WORK%\\*.md\"<\/pre>\n<h3 style=\"text-align: justify;\">What this shows (the three lessons in one place)<\/h3>\n<ul style=\"text-align: justify;\">\n<li><strong>Same shape, three steer mechanisms:<\/strong>\u00a0Codex is steered by the quoted\u00a0<code>\"ROLE=...\"<\/code>\u00a0token, agy by its default (no token), Claude by flags.\u00a0<strong>How each gets the brief differs:<\/strong>\u00a0Codex and Claude read it from stdin (<code>&lt; 1-draft.txt<\/code>,\u00a0<code>&lt; 3-polish.txt<\/code>);\u00a0<strong>agy can&#8217;t read stdin, so it&#8217;s told to open the file<\/strong>\u00a0(<code>-p \"Read 2-revise.txt ... and follow it\"<\/code>).<\/li>\n<li><strong>Hand-off via files:<\/strong>\u00a0every stage runs in\u00a0<code>C:\\work\\blog<\/code>, so\u00a0<code>draft.md<\/code>\u00a0\u2192\u00a0<code>revised.md<\/code>\u00a0\u2192\u00a0<code>final.md<\/code>\u00a0chain works because each brief tells the agent which file to read and which to write.<\/li>\n<li><strong>You don&#8217;t need all three.<\/strong> Any single client can do the whole job &#8211; e.g. give Claude one brief (&#8220;write, self-edit, and save final.md&#8221;) and skip the other two. The three-stage split just gives you a draft, an independent revision, and a polish from different models.<\/li>\n<\/ul>\n<h3 style=\"text-align: justify;\">Check the result<\/h3>\n<ul style=\"text-align: justify;\">\n<li>Open\u00a0<code>C:\\work\\blog\\final.md<\/code>. If a stage&#8217;s\u00a0<code>.md<\/code>\u00a0is missing, read that stage&#8217;s\u00a0<code>.err.log<\/code>\u00a0\/\u00a0<code>agy.log<\/code>. Remember agy may print nothing to the console &#8211; <strong>judge it by whether\u00a0<code>revised.md<\/code>\u00a0appeared<\/strong>, not by stdout (see Section 3).<\/li>\n<\/ul>\n<div class=\"cta\" style=\"text-align: justify;\">\n<p><span data-sheets-root=\"1\"><div class=\"ntself\" style=\"border-left-color:#d10014;background: #f3e8e8;\"><\/span><\/p>\n<p><strong>Want your agents to run faster and cheaper too?<\/strong> Pair this scripting workflow with fast local CLI tools so your agents search and parse files instead of burning tokens &#8211; see the companion guide, <a href=\"https:\/\/www.systweak.com\/blogs\/agent-token-saver-toolkit\/\" target=\"_blank\" rel=\"noopener\">How to Cut AI Coding Agent Costs with Fast Local Tools<\/a>.<\/p>\n<p><span data-sheets-root=\"1\"><\/div>\n<\/span><\/p>\n<h3>Frequently Asked Questions<\/h3>\n<div class=\"accordion_sec faq-section\">\n<div id=\"accordion-menu\">\n<h4 class=\"accordion-header plus\">Should I use cmd or PowerShell to launch CLI AI agents?<\/h4>\n<div class=\"accordion-panel\">\n<p class=\"accordion-content aio-answer-block\">Use cmd (.cmd batch files) to launch Codex, agy, and Claude. PowerShell does not support the < stdin redirection these tools rely on, and it re-parses quotes and special characters differently, which breaks the ROLE token. Reserve PowerShell for Windows-admin tasks like editing PATH, and use rg\/fd for searching files.<\/p>\n<\/div>\n<h4 class=\"accordion-header plus\">How do Codex, agy, and Claude each receive their prompt?<\/h4>\n<div class=\"accordion-panel\">\n<p class=\"accordion-content aio-answer-block\">Codex and Claude read the prompt from standard input (< prompt.txt). agy does not read stdin at all - its prompt is the -p argument, so for a long brief you tell agy to open the file itself, e.g. -p 'Read prompt.txt and follow it exactly'.<\/p>\n<\/div>\n<h4 class=\"accordion-header plus\">How do I set the agent's role for each client?<\/h4>\n<div class=\"accordion-panel\">\n<p class=\"accordion-content aio-answer-block\">Each client uses a different mechanism. Codex takes a quoted ROLE token as a positional argument. agy has no token and uses its default role. Claude is steered by command-line flags such as --model and --effort.<\/p>\n<\/div>\n<h4 class=\"accordion-header plus\">Why should I never hardcode C:Users&lt;name&gt; paths?<\/h4>\n<div class=\"accordion-panel\">\n<p class=\"accordion-content aio-answer-block\">A username change breaks every hardcoded path. Use %LOCALAPPDATA% instead - it resolves per-user automatically, so scripts survive a reinstall or a username change.<\/p>\n<\/div>\n<h4 class=\"accordion-header plus\">Is it safe to run these agents unattended?<\/h4>\n<div class=\"accordion-panel\">\n<p class=\"accordion-content aio-answer-block\">The unattended examples turn off approval prompts and sandboxing (Codex calls this 'EXTREMELY DANGEROUS'). Only use them in a folder you trust, on work under version control you can revert, never on a shared or production machine. Drop the bypass flag or use a read-only\/sandbox mode when you want a safety net.<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\"><\/div>\n<\/div>\n<\/span><\/p>\n<\/div>\n<p style=\"text-align: justify;\">\n","protected":false},"excerpt":{"rendered":"<p>If you automate work with CLI AI agents, you quickly hit the same wall: each agent takes its prompt, its working directory, and its role in a slightly different way, and the wrong shell or the wrong flag order silently breaks the whole run. This guide distills the rules that actually work on Windows, learned&hellip; <a class=\"more-link\" href=\"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/\">Continue reading <span class=\"screen-reader-text\">How to Script AI Agent Tasks With Codex, Gemini (agy), and Claude<\/span><\/a><\/p>\n","protected":false},"author":28,"featured_media":33638,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[95],"tags":[111,96,114,105,113,109,110,104,117,116,112,115],"class_list":["post-33560","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-artificial-intelligence-ai","tag-agy","tag-ai-agents","tag-batch-scripting","tag-claude-code","tag-cmd-vs-powershell","tag-codex-cli","tag-gemini-cli","tag-multi-agent-pipeline","tag-role-token","tag-stdin","tag-unattended-automation","tag-windows-automation","entry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8-RC2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Script AI Agent Tasks With Codex, Gemini &amp; Claude<\/title>\n<meta name=\"description\" content=\"Learn to script unattended tasks across Codex, Gemini (agy) &amp; Claude CLI agents: which shell, how to pass prompts and roles, plus a full blog pipeline.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Script AI Agent Tasks With Codex, Gemini &amp; Claude\" \/>\n<meta property=\"og:description\" content=\"Learn to script unattended tasks across Codex, Gemini (agy) &amp; Claude CLI agents: which shell, how to pass prompts and roles, plus a full blog pipeline.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/systweak\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-01T12:58:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-07-02T05:50:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.systweak.com\/content\/wp\/bg_systweak_com\/uploads\/2026\/07\/How-to-Script-AI-Agent-Tasks-With-Codex-Gemini-agy-and-Claude.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Shrishail Rana\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@systweak\" \/>\n<meta name=\"twitter:site\" content=\"@systweak\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shrishail Rana\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/script-ai-agent-tasks-with-codex-gemini-claude\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/script-ai-agent-tasks-with-codex-gemini-claude\\\/\"},\"author\":{\"name\":\"Shrishail Rana\",\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/#\\\/schema\\\/person\\\/5e62626639f4132937a86e08174d94df\"},\"headline\":\"How to Script AI Agent Tasks With Codex, Gemini (agy), and Claude\",\"datePublished\":\"2026-07-01T12:58:54+00:00\",\"dateModified\":\"2026-07-02T05:50:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/script-ai-agent-tasks-with-codex-gemini-claude\\\/\"},\"wordCount\":2168,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/script-ai-agent-tasks-with-codex-gemini-claude\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/cdn.systweak.com\\\/content\\\/wp\\\/bg_systweak_com\\\/uploads\\\/2026\\\/07\\\/How-to-Script-AI-Agent-Tasks-With-Codex-Gemini-agy-and-Claude.webp\",\"keywords\":[\"agy\",\"AI agents\",\"batch scripting\",\"Claude Code\",\"cmd vs PowerShell\",\"Codex CLI\",\"Gemini CLI\",\"multi-agent pipeline\",\"ROLE token\",\"stdin\",\"unattended automation\",\"Windows automation\"],\"articleSection\":[\"Artificial intelligence (AI)\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/script-ai-agent-tasks-with-codex-gemini-claude\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/script-ai-agent-tasks-with-codex-gemini-claude\\\/\",\"url\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/script-ai-agent-tasks-with-codex-gemini-claude\\\/\",\"name\":\"How to Script AI Agent Tasks With Codex, Gemini & Claude\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/script-ai-agent-tasks-with-codex-gemini-claude\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/script-ai-agent-tasks-with-codex-gemini-claude\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/cdn.systweak.com\\\/content\\\/wp\\\/bg_systweak_com\\\/uploads\\\/2026\\\/07\\\/How-to-Script-AI-Agent-Tasks-With-Codex-Gemini-agy-and-Claude.webp\",\"datePublished\":\"2026-07-01T12:58:54+00:00\",\"dateModified\":\"2026-07-02T05:50:17+00:00\",\"description\":\"Learn to script unattended tasks across Codex, Gemini (agy) & Claude CLI agents: which shell, how to pass prompts and roles, plus a full blog pipeline.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/script-ai-agent-tasks-with-codex-gemini-claude\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/script-ai-agent-tasks-with-codex-gemini-claude\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/script-ai-agent-tasks-with-codex-gemini-claude\\\/#primaryimage\",\"url\":\"https:\\\/\\\/cdn.systweak.com\\\/content\\\/wp\\\/bg_systweak_com\\\/uploads\\\/2026\\\/07\\\/How-to-Script-AI-Agent-Tasks-With-Codex-Gemini-agy-and-Claude.webp\",\"contentUrl\":\"https:\\\/\\\/cdn.systweak.com\\\/content\\\/wp\\\/bg_systweak_com\\\/uploads\\\/2026\\\/07\\\/How-to-Script-AI-Agent-Tasks-With-Codex-Gemini-agy-and-Claude.webp\",\"width\":1199,\"height\":750,\"caption\":\"How to Script AI Agent Tasks With Codex, Gemini (agy), and Claude\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/script-ai-agent-tasks-with-codex-gemini-claude\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Script AI Agent Tasks With Codex, Gemini (agy), and Claude\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/#website\",\"url\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/\",\"name\":\"\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/#organization\",\"name\":\"Systweak Software\",\"url\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Systweak Software\"},\"image\":{\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/systweak\",\"https:\\\/\\\/x.com\\\/systweak\",\"https:\\\/\\\/www.instagram.com\\\/systweak\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/systweak-software\\\/\",\"https:\\\/\\\/www.pinterest.com\\\/systweak\",\"https:\\\/\\\/www.youtube.com\\\/c\\\/SystweakSoftware\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/#\\\/schema\\\/person\\\/5e62626639f4132937a86e08174d94df\",\"name\":\"Shrishail Rana\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/107867f9eead7ba9823a44831ed5e122cc8a98beb34539d072d6c662686003b6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/107867f9eead7ba9823a44831ed5e122cc8a98beb34539d072d6c662686003b6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/107867f9eead7ba9823a44831ed5e122cc8a98beb34539d072d6c662686003b6?s=96&d=mm&r=g\",\"caption\":\"Shrishail Rana\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/shrishail-r-686243\\\/\"],\"url\":\"https:\\\/\\\/www.systweak.com\\\/blogs\\\/author\\\/shrishail\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Script AI Agent Tasks With Codex, Gemini & Claude","description":"Learn to script unattended tasks across Codex, Gemini (agy) & Claude CLI agents: which shell, how to pass prompts and roles, plus a full blog pipeline.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/","og_locale":"en_US","og_type":"article","og_title":"How to Script AI Agent Tasks With Codex, Gemini & Claude","og_description":"Learn to script unattended tasks across Codex, Gemini (agy) & Claude CLI agents: which shell, how to pass prompts and roles, plus a full blog pipeline.","og_url":"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/","article_publisher":"https:\/\/www.facebook.com\/systweak","article_published_time":"2026-07-01T12:58:54+00:00","article_modified_time":"2026-07-02T05:50:17+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdn.systweak.com\/content\/wp\/bg_systweak_com\/uploads\/2026\/07\/How-to-Script-AI-Agent-Tasks-With-Codex-Gemini-agy-and-Claude.webp","type":"image\/webp"}],"author":"Shrishail Rana","twitter_card":"summary_large_image","twitter_creator":"@systweak","twitter_site":"@systweak","twitter_misc":{"Written by":"Shrishail Rana","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/#article","isPartOf":{"@id":"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/"},"author":{"name":"Shrishail Rana","@id":"https:\/\/www.systweak.com\/blogs\/#\/schema\/person\/5e62626639f4132937a86e08174d94df"},"headline":"How to Script AI Agent Tasks With Codex, Gemini (agy), and Claude","datePublished":"2026-07-01T12:58:54+00:00","dateModified":"2026-07-02T05:50:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/"},"wordCount":2168,"commentCount":0,"publisher":{"@id":"https:\/\/www.systweak.com\/blogs\/#organization"},"image":{"@id":"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.systweak.com\/content\/wp\/bg_systweak_com\/uploads\/2026\/07\/How-to-Script-AI-Agent-Tasks-With-Codex-Gemini-agy-and-Claude.webp","keywords":["agy","AI agents","batch scripting","Claude Code","cmd vs PowerShell","Codex CLI","Gemini CLI","multi-agent pipeline","ROLE token","stdin","unattended automation","Windows automation"],"articleSection":["Artificial intelligence (AI)"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/","url":"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/","name":"How to Script AI Agent Tasks With Codex, Gemini & Claude","isPartOf":{"@id":"https:\/\/www.systweak.com\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/#primaryimage"},"image":{"@id":"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.systweak.com\/content\/wp\/bg_systweak_com\/uploads\/2026\/07\/How-to-Script-AI-Agent-Tasks-With-Codex-Gemini-agy-and-Claude.webp","datePublished":"2026-07-01T12:58:54+00:00","dateModified":"2026-07-02T05:50:17+00:00","description":"Learn to script unattended tasks across Codex, Gemini (agy) & Claude CLI agents: which shell, how to pass prompts and roles, plus a full blog pipeline.","breadcrumb":{"@id":"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/#primaryimage","url":"https:\/\/cdn.systweak.com\/content\/wp\/bg_systweak_com\/uploads\/2026\/07\/How-to-Script-AI-Agent-Tasks-With-Codex-Gemini-agy-and-Claude.webp","contentUrl":"https:\/\/cdn.systweak.com\/content\/wp\/bg_systweak_com\/uploads\/2026\/07\/How-to-Script-AI-Agent-Tasks-With-Codex-Gemini-agy-and-Claude.webp","width":1199,"height":750,"caption":"How to Script AI Agent Tasks With Codex, Gemini (agy), and Claude"},{"@type":"BreadcrumbList","@id":"https:\/\/www.systweak.com\/blogs\/script-ai-agent-tasks-with-codex-gemini-claude\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.systweak.com\/blogs\/"},{"@type":"ListItem","position":2,"name":"How to Script AI Agent Tasks With Codex, Gemini (agy), and Claude"}]},{"@type":"WebSite","@id":"https:\/\/www.systweak.com\/blogs\/#website","url":"https:\/\/www.systweak.com\/blogs\/","name":"","description":"","publisher":{"@id":"https:\/\/www.systweak.com\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.systweak.com\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.systweak.com\/blogs\/#organization","name":"Systweak Software","url":"https:\/\/www.systweak.com\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.systweak.com\/blogs\/#\/schema\/logo\/image\/","url":"","contentUrl":"","caption":"Systweak Software"},"image":{"@id":"https:\/\/www.systweak.com\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/systweak","https:\/\/x.com\/systweak","https:\/\/www.instagram.com\/systweak\/","https:\/\/www.linkedin.com\/company\/systweak-software\/","https:\/\/www.pinterest.com\/systweak","https:\/\/www.youtube.com\/c\/SystweakSoftware"]},{"@type":"Person","@id":"https:\/\/www.systweak.com\/blogs\/#\/schema\/person\/5e62626639f4132937a86e08174d94df","name":"Shrishail Rana","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/107867f9eead7ba9823a44831ed5e122cc8a98beb34539d072d6c662686003b6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/107867f9eead7ba9823a44831ed5e122cc8a98beb34539d072d6c662686003b6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/107867f9eead7ba9823a44831ed5e122cc8a98beb34539d072d6c662686003b6?s=96&d=mm&r=g","caption":"Shrishail Rana"},"sameAs":["https:\/\/www.linkedin.com\/in\/shrishail-r-686243\/"],"url":"https:\/\/www.systweak.com\/blogs\/author\/shrishail\/"}]}},"_links":{"self":[{"href":"https:\/\/www.systweak.com\/blogs\/wp-json\/wp\/v2\/posts\/33560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.systweak.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.systweak.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.systweak.com\/blogs\/wp-json\/wp\/v2\/users\/28"}],"replies":[{"embeddable":true,"href":"https:\/\/www.systweak.com\/blogs\/wp-json\/wp\/v2\/comments?post=33560"}],"version-history":[{"count":24,"href":"https:\/\/www.systweak.com\/blogs\/wp-json\/wp\/v2\/posts\/33560\/revisions"}],"predecessor-version":[{"id":33732,"href":"https:\/\/www.systweak.com\/blogs\/wp-json\/wp\/v2\/posts\/33560\/revisions\/33732"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.systweak.com\/blogs\/wp-json\/wp\/v2\/media\/33638"}],"wp:attachment":[{"href":"https:\/\/www.systweak.com\/blogs\/wp-json\/wp\/v2\/media?parent=33560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.systweak.com\/blogs\/wp-json\/wp\/v2\/categories?post=33560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.systweak.com\/blogs\/wp-json\/wp\/v2\/tags?post=33560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}