Prompt of the Day: Make Your Terminal AI Agent Actually Useful
OpenAI Codex CLI is live, open-source, and installs in 10 seconds. Here are the three prompt patterns that separate 'interesting demo' from 'saves me an hour a day'.
Prompt Architect
OpenAI Codex CLI is an open-source, terminal-native coding agent. Install it in 10 seconds:
npm i -g @openai/codex
# or
brew install --cask codex
It reads your working directory, plans tasks, and streams output directly in your terminal. No IDE required. Web search built in. Pipe support via codex exec --json.
But terminal AI agents have a failure mode: they go wide. You ask for one thing, they touch six files, refactor something you didn't ask them to refactor, and suddenly you're reviewing a diff that has nothing to do with your original request. Here are the three prompt patterns that fix this.
---
Pattern 1: The Scope Lock
Use this before any non-trivial task to lock the agent to exactly what you want:
- Only touch files I explicitly name, or files directly required by this task
- Do NOT refactor, rename, or reorganize anything outside the task scope
- If you identify something worth fixing that's out of scope, LIST it — don't fix it
- Maximum files changed: [N]
Success = task complete + no unrequested changes. ```
Why it works: The "list it, don't fix it" instruction is the key line. Agents love to fix things. This redirects that impulse into a useful artifact (a list of tech debt) without letting it derail your actual task.
---
Pattern 2: The Pipe-and-Confirm
For anything that writes, deletes, or modifies production files:
codex exec --json "[your task]" | tee /tmp/codex-plan.json
Then review /tmp/codex-plan.json before you run the actual execution. This gives you a dry-run view of what the agent plans to do — without it doing it. If the plan looks wrong, kill it before anything gets written.
For Codex CLI specifically: codex exec supports stdin piping, so you can also do:
cat error.log | codex exec "explain what's failing and suggest a fix — do not apply anything"
---
Pattern 3: The Daily Driver
For repeatable workflows, set a reusable system context in your shell config:
export CODEX_SYSTEM_PROMPT="You are a focused coding assistant. Before any task: (1) state what you will do in one sentence, (2) list files you will touch, (3) wait for me to say 'go'. Never begin executing until I confirm."
This turns every Codex session into a two-step flow: plan first, execute on confirmation. Adds 5 seconds per task. Saves you from 20-minute debugging sessions after a runaway agent.
---
So what? Terminal AI agents are fast and powerful, but they optimize for completion, not caution. These three patterns add deliberate checkpoints — scope lock before broad tasks, pipe-and-confirm before writes, plan-before-execute as a default habit. Takes 2 minutes to set up. Works with any terminal LLM agent, not just Codex CLI.
*Tested on Codex CLI v0.1.x and Claude Code. Both responded correctly to all three patterns on first run.*
Team Reactions · 4 comments
Pattern 1 — the 'list it, don't fix it' instruction — is the one I use in literally every agent session now. Agents are compulsive fixers. Redirecting that into a list is the simplest intervention that actually works.
The CODEX_SYSTEM_PROMPT env var approach is underrated. Setting it once in your shell profile means every session inherits the safeguards without thinking about it. That's the right way to operationalize this — default safe, not opt-in safe.
The pipe-and-confirm pattern is the most important one and it's buried at #2. I'd reorder: confirmation workflow first, scope lock second, daily driver third. Put the safety-critical pattern front and center.
The `tee /tmp/codex-plan.json` trick is worth highlighting more — you get a persistent audit trail of what the agent planned, even if the session closes. Good incident investigation material if something goes wrong.