The Big Three CLI Coding Agents

What Works, What Doesn't, and How to Master Them

Claude Code

Gemini CLI

OpenAI Codex

A Comprehensive Guide to CLI-Based AI Coding Assistants

2 / 16

The Shared Philosophy

These Are Agentic Coding Environments, Not Chatbots

The mental shift is crucial. These tools:

The Right Mental Model

Think of them as very fast assistants:

Key insight: You're not treating it like magic — you're delegating to a capable but imperfect assistant.

3 / 16

Universal Best Practice #1

Always Work From Within Your Project Directory

Before running any CLI command, make sure you're already inside your project folder.

cd ~/projects/my-app claude # ✓ Correct - runs from project context # NOT: claude ~/projects/my-app # ✗ Wrong - loses context

This helps the agent:

Most Common Mistake

This is the single most common mistake new users make. Running from the wrong directory means the agent can't see your code properly!

4 / 16

Universal Best Practice #2

Use the Project Memory/Instruction File

Each tool has its own convention for project-specific instructions:

Tool File Name Location Recommended Size
Claude Code CLAUDE.md Project root or .claude/ directory < 200 lines per file
Gemini CLI GEMINI.md .gemini/ folder No strict limit
Codex CLI AGENTS.md Project root No strict limit

What to Include in Your Memory File

Pro tip for monorepos: Use multiple CLAUDE.md files with ancestor + descendant loading pattern.

Understanding Memory Storage

Two Types of Memory:

Key Differences:

This applies to all CLI tools - they all have both global settings and project-specific configurations.

5 / 16

Universal Best Practices #3-5

3. Be Specific in Your Prompts

Vague prompts fail across all tools.

❌ Bad:
"Fix the bug"
✓ Good:
"Fix the null pointer exception in user-service.ts line 42 when processing empty arrays"

4. Always Work in a Git-Tracked Directory

All three tools can modify your codebase directly. Git becomes your safety net:

5. Ask for a Plan First

If you're worried about token usage or unintended changes:

"Generate a plan for refactoring the auth module" # Review the plan "Looks good, but skip step 3 and modify step 5 to..." # Then execute
6 / 16

Claude Code - Specific Tips

Claude Code

Context Management is Everything

/clear Often

Every time you start something new, clear the chat. You don't need all that history eating your tokens.

Avoid the "Agent Dumb Zone"

Do manual /compact at max 50% context usage. Use /clear to reset context mid-session if switching tasks.

Optimal Configuration

Always use:

  • thinking_mode: true
  • Output Style: Explanatory

in /config for better understanding

7 / 16

Claude Code - Power Features

Claude Code

Advanced Capabilities

Permissions and Automation

Use /permissions to allowlist safe commands or /sandbox for OS-level isolation. This reduces interruptions while keeping you in control.

External Service Integration

Tell Claude Code to use CLI tools like gh, aws, gcloud, and sentry-cli when interacting with external services. CLI tools are the most context-efficient way to interact with external services.

Enhanced Rewind

/rewind was recently enhanced to allow rewinding conversation and code separately — so you can undo a bad refactoring without losing the conversation history.

Voice Input - How It Works

The claim: "Just send voice messages. It's faster for most people."

But HOW from a computer?

  • macOS: Press Fn key twice → dictation mode → speak → text appears
  • Windows: Win+H → voice typing → speak naturally
  • Linux: Various tools (e.g., nerd-dictation, whisper.cpp)
  • Alternative: Use phone's voice-to-text, then paste

Note: This converts speech to text in your terminal - it's not a literal voice call, but voice-to-text input that Claude Code processes as regular text.

8 / 16

Gemini CLI - Specific Tips

Gemini CLI

Unique Strengths

Generous Free Tier

  • 60 requests/min
  • 1,000 requests/day
  • Access to Gemini 3 models
  • 1M token context window

Context Injection with @

Use @ for explicit context injection rather than relying on memory:

Compare @./foo.py and @./bar.py

More precise and prevents hallucination

Checkpointing is Crucial

Captures state of working directory. Like time-traveling back before a wrong turn. Keep it on for non-trivial tasks.

Shell Mode Toggle

Press ! to toggle shell mode. Executes commands locally and feeds output back into conversation context.

Known Trade-off

Gemini's agent mode is less reliable on complex refactors or deeper reasoning compared to Claude. It excels at speed and iteration, not necessarily deep architectural reasoning.

9 / 16

OpenAI Codex CLI - Specific Tips

Codex CLI

Professional Features

Model Selection Matters

For most tasks, gpt-5.4 is recommended — combines strong coding, reasoning, native computer use, and broader professional workflows.

Approval Modes

Mode Command Use Case
Read Only -s read-only Audits and analysis
Auto Default Daily development
Full Auto --full-auto Complete automation

Note: Sandbox blocks network by default — explicitly enable for package installs or API calls.

Session Resume

codex resume launches a picker of recent sessions. Keeps original transcript, plan history, and approvals.

Multi-Agent Workflows

Supports parallel agents on same repository using isolated worktrees — useful for dividing frontend and backend work.

10 / 16

What CLI Agents Cannot Do Well

1. They're Visually Blind

When you need to describe a UI bug, reference a design mockup, or understand web page layout, terminal interfaces don't have the tools to see the change like an IDE does. (Though Codex and Claude Code can accept image input now.)

2. They Can't Undo External Side Effects

Checkpointing won't undo external side effects — for example, if the AI ran a database migration, it can't undo that.

3. They Require Terminal Fluency

You need to know how to navigate directories, set environment variables, and manage API keys. If you aren't comfortable with cd, ls, or chmod, you cannot use these tools effectively.

4. They're Locked to Their Ecosystems (Mostly)

11 / 16

Cost Considerations

Cost Can Spiral

Cost is the loudest topic on every developer forum.

Typical Usage Costs

Tool Model Hourly Cost (Heavy Use) Monthly Cost (Heavy Users)
Claude Code Claude Sonnet 4.6 $3-8/hour $150-200/month
Gemini CLI Gemini 3 Free tier available $0 (within limits)
Codex CLI GPT-5.4 Varies by model $100-300/month

Cost Management Tips

  • Use /clear frequently to reset context
  • Ask for plans before execution to avoid wasted tokens
  • Use the free Gemini CLI for simpler tasks
  • Monitor your usage dashboard regularly
  • Set spending limits where available
12 / 16

Complex Refactors Remain Fragile

The Architecture Matters as Much as the Model

Multiple independent benchmarks show that the same model in different agent scaffolding produces very different results.

What Works Well

  • Small, focused refactors
  • Adding new features
  • Bug fixes with clear scope
  • Test writing
  • Documentation updates

What Struggles

  • Large-scale architectural changes
  • Cross-cutting concerns
  • Performance optimizations
  • Complex state management refactors
  • Database schema migrations

Mitigation Strategy

Break complex refactors into smaller, testable chunks. Use git branches liberally. Review and test each stage before proceeding.

13 / 16

The Emerging Power Pattern: Multi-Agent Orchestration

Running Multiple CLI Agents Side by Side

Several experienced users are now running multiple CLI agents simultaneously for different strengths:

Popular Pattern: Claude + Codex

  • Claude Code: High-level design and planning
  • Codex: Implementation and execution
# Using tmux for side-by-side agents tmux new-session -d -s agents tmux split-window -h tmux send-keys -t agents:0.0 "claude" Enter tmux send-keys -t agents:0.1 "codex" Enter tmux attach -t agents

Advanced: Containerized Agents

Have your local Claude Code control another Claude Code instance running inside a Docker container — fully autonomous, sandboxed, and pulling results back when done.

Perfect for:

  • Orchestrating taxonomy annotation pipelines
  • Running parallel corpus classification passes
  • Isolated testing environments
  • Risk-free experimentation
14 / 16

Practical Workflow Example

Implementing a New Feature with Multiple Agents

Step 1: Planning with Claude Code

cd ~/projects/my-app claude > "Create a detailed plan for implementing user authentication with JWT tokens"

Step 2: Fast Implementation with Gemini

gemini > "Implement the JWT token generation function @./auth/plan.md"

Step 3: Testing with Codex

codex --full-auto > "Write comprehensive tests for the authentication module"

Step 4: Review and Refine with Claude

claude > "Review the implementation and suggest security improvements"
15 / 16

Key Takeaways

1. Context is King

Manage your context window actively. Clear often, use project memory files, and work from the right directory.

2. Git is Your Safety Net

Always work in version-controlled directories. Review changes before committing.

3. Be Specific

Vague prompts waste tokens and time. Be precise about what you want.

4. Know the Limitations

These tools can't see UI, can't undo external effects, and struggle with complex refactors.

5. Consider Multi-Agent Workflows

Different tools have different strengths. Use them together for best results.

6. Monitor Costs

API usage can add up quickly. Set limits and track spending.

The Bottom Line

The main bottleneck is learning to think in terms of delegation and context management rather than direct coding. Master these patterns, and you'll multiply your productivity.

16 / 16

Resources & Further Reading

Official Documentation

Community Resources

Alternative Tools

Perfect for Research Workflows

Especially powerful for orchestrating taxonomy annotation pipelines, running parallel corpus classification passes, and automating repetitive research tasks.