Codex InfinityCodexInfinity

Write Agent Task Prompts That Actually Finish

· 6 min read

An autonomous coding agent works best when the task reads like a good ticket. The agent can run for as long as the job needs, so the prompt is the main lever you control. A few minutes of structure at the start saves hours of review at the end.

Start with one outcome

Describe the finished state in a sentence. "Add a /health endpoint that returns the build version and a 200 status" gives the agent a clear target. "Improve the backend" gives it a research project. When you have a large goal, split it into several tasks and let each one end in a pull request you can read in a few minutes.

Name the files and the commands

Point at the directories that matter and say how to verify the work. If your repo uses Bun, say so. If the test command is bun test, put it in the prompt. Agents perform best when they can run the same checks you would run, so include the install, build, and test commands you trust.

Share the conventions

Tell the agent about naming, formatting, and libraries your team prefers. One line such as "use the existing fetch wrapper in lib/api.ts" keeps the diff consistent with the rest of the codebase. Repeating guidance across many tasks is a sign it belongs in a shared prompt you reuse.

Use the CI Sentinel fix prompt as a template

CI Sentinel accepts an auto_fix_prompt that is sent whenever a run fails. A good example is: "Use Bun for install and test. Fix failing CI and open a PR with a concise summary." It names the tooling, states the outcome, and describes the deliverable in three short sentences. Borrow that shape for your own tasks.

Steer with follow ups

You can keep working on the same branch from GitHub. Comment @codeggsinfinity review or @codeggsinfinity fix the failing tests on a pull request, or use /codex followed by your request. The agent picks up on that branch, so each follow up stays small and focused. Review comments become the second prompt in a short conversation.

Review the result like a teammate's PR

Read the diff, run the checks, and leave comments where you want changes. Because the agent opens a pull request, the familiar review flow applies. Merge when the diff matches your intent, or reply with one more instruction and let it iterate.

A worked example

Suppose your app returns a generic error when a user uploads an empty file. A strong prompt reads: "In server/upload.go, return a 400 with a clear message when the uploaded file is empty. Add a table test covering empty, small, and large files. Run go test ./... and open a PR with a two sentence summary." The goal, scope, checks, and deliverable are all present, so the agent can work through the task and report back without further input.

Build a prompt library

Keep a short list of prompts for jobs you repeat: dependency bumps, test coverage for a module, documentation refreshes, and bug triage. Reusing a proven prompt gives consistent pull requests, and you can refine it a little each time the agent returns something close but not quite right.

Try it

Install the CLI with curl -fsSL https://codexinfinitystatic.codex-infinity.com/cli/latest/install.sh | bash, or open the dashboard, write one task using the structure above, and watch the agent stream its progress in real time.

Start with Codex Infinity or browse the full blog.

← Back to Blog