Skip to content

How to Write Effective Prompts for Codex CLI

AI prompt engineering concept

Problem

When I started using Codex CLI, my prompts were either too vague or overly specific. Both approaches produced bad results.

Too vague: “Build an API for users” → Generic code missing my actual requirements

Too specific: 50-line technical specification → Overwhelmed Codex, got confused output

I was stuck in iteration loops, spending more time fixing than building.

What happened?

I fell into two traps that many developers hit:

Trap 1: Over-specification

I provided too much technical detail, overwhelming Codex with constraints:

Overly complex prompt (WRONG)
Implement a RESTful API endpoint with CRUD operations,
parameter validation using JSON Schema, authentication
via JWT tokens with RS256 signing, rate limiting at
100 req/min, and error handling conforming to RFC 7807...
[continues for 50 more lines]

Result: Confused output, missed requirements, multiple revision cycles.

Trap 2: Under-planning

I jumped straight into execution without clear architectural decisions:

Vague prompt (WRONG)
Build me an e-commerce product catalog

Result: Codex invented tech choices I didn’t want, inconsistent patterns, technical debt.

How to solve it?

I learned three principles that transformed my Codex prompts.

Principle 1: The ELI5 Technique

Use simple, conversational language. Avoid jargon and complex specifications.

Better ELI5 prompt
Create a simple API for managing users. It should have
basic create, read, update, and delete actions. Keep it
straightforward - handle errors nicely and make sure
users can't access each other's data.

Why this works:

  • Reduces ambiguity in instructions
  • Forces me to clarify my own thinking
  • Produces clearer, more maintainable code
  • Makes iteration faster

Principle 2: Strategic Planning Before Execution

Invest time upfront planning architecture and tech stack BEFORE engaging Codex.

Planning checklist
[ ] Authentication system choice (OAuth, JWT, session)
[ ] Database technology and schema decisions
[ ] Design system/component library
[ ] State management approach
[ ] API architecture (REST, GraphQL, tRPC)

Time allocation that works:

Time investment
2 days planning (human decisions)
5 hours execution (Codex implementation)
= Better outcomes than jumping straight to execution

Principle 3: Provide Frameworks, Not Specifications

Give Codex high-level patterns and let it fill in implementation details.

Framework approach prompt
I need a simple user management API with basic CRUD.
Here's what I want:
1. Users can be created, viewed, updated, and deleted
2. Each user has an email, password, and name
3. Basic validation - emails look valid, passwords secure
4. Users should only edit their own data
5. Handle errors gracefully
Tech context:
- Node.js with Express
- PostgreSQL database
- JWT for authentication
Keep it simple. We can add complexity later.

This communicates requirements without over-constraining implementation.

The reason

I think the key reason is cognitive load management.

When I overload prompts with technical details:

  • I create ambiguity (multiple ways to interpret)
  • I constrain Codex’s ability to find optimal solutions
  • I increase mental overhead for reviewing outputs
  • I slow down iteration cycles

When I use simple language and clear frameworks:

  • Outputs are easier to review
  • Iteration is faster
  • Code is more maintainable
  • I leverage Codex’s training rather than fighting it

Common mistakes to avoid

1. Trying to control every implementation detail

Trust Codex with implementation. Focus on desired outcomes.

2. Skipping planning to “save time”

Invest upfront to save hours of rework later.

3. Using jargon and complex technical language

Use simple, conversational language (ELI5 approach).

4. Accepting whatever tech stack Codex invents

Make key architectural decisions upfront.

5. Over-explaining context

Provide just enough context for the current task.

Summary

In this post, I showed how to write effective prompts for Codex CLI. The key point is combining simple language, strategic planning, and high-level frameworks to reduce cognitive load and produce better code.

Try the ELI5 technique on your next Codex session: write prompts in simple conversational language, spend time planning your architecture, and trust Codex with implementation details. You’ll see better results in less time.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments