7 min read

Getting Started with AI CLI Agents: Claude Code & Codex

Getting Started with AI CLI Agents: Claude Code & Codex

AI is moving from the chat window into the terminal. The browser interface is fine for asking questions, but the terminal is where you actually get work done — where the agent can read your files, edit your code, and run commands on your behalf.

That capability change is also a complexity change. A chat agent can hallucinate; a terminal agent can hallucinate and delete your homework. This guide is for the user who has used ChatGPT or Claude in the browser and is ready to graduate to a CLI tool — but who has never opened a terminal before, or has only opened one nervously.

We will install one (or both) of the two leading CLI agents, set up the minimum scaffolding to keep you safe, and run a few small tasks. Nothing fancy. The goal is to build the right habits early, before they become expensive to unlearn.

1. Pick Your Operating System Path

On a Mac: You are on the golden path. macOS is Unix-based, and the built-in Terminal app (under /Applications/Utilities/) will work for everything in this guide.

On Windows: You have a choice. The native PowerShell will work for many basic agent commands, but a lot of the open-source tooling assumes a Unix-like environment. The cleaner path is WSL2 — Windows Subsystem for Linux 2 — which gives you a real Linux environment running alongside Windows. Microsoft has a one-page setup guide. Plan to spend an hour on this; it pays back the time within a week.

If you are absolutely allergic to setup, native PowerShell is fine for getting started. You can graduate to WSL2 later.

2. The Terminal: Built-in Is Fine

Whatever terminal app comes with your operating system is enough. Open it. You are now at a "command prompt." This is where you will spend most of your time with these tools.

Once you are comfortable, you may hear about alternatives like Ghostty, iTerm2, or Warp — modern terminals with GPU acceleration, better fonts, and split-pane support that makes it easier to view your code and the agent side-by-side. They are nice. They are not necessary on day one.

3. Choose Your Agent: The Wallet Rule

There are two leading CLI agents as of this writing:

  • Claude Code (from Anthropic) — pairs with Claude.
  • Codex CLI (from OpenAI) — pairs with ChatGPT.

You can run both. Most people start with one. The simplest selection rule: follow your wallet.

  • Already paying for Claude Pro ($20/month)? Start with Claude Code.
  • Already paying for ChatGPT Plus ($20/month)? Start with Codex CLI.

The reason matters. These CLI agents send a lot of tokens — every read of a file, every search, every multi-step plan. If you pay per-token via API, a single afternoon of work can run $5–$20. The fixed-price subscriptions are heavily cross-subsidized for exactly this kind of usage. Heavy users almost always come out ahead on a subscription.

If you do not have either subscription, pick the model whose output style you prefer in the browser. They are more similar than they are different at this stage.

4. Install and Authenticate

Both agents need Node.js installed. If you do not have it, install Node.js LTS — accept the defaults.

Claude Code:

curl -fsSL https://claude.ai/install.sh | bash

Then run claude in any directory. It will open a browser, you log in, and you are connected.

Codex CLI:

npm install -g @openai/codex

Then run codex login. Same browser flow.

That is it. You now have an AI agent that can see and modify the directory you are in.

This is the moment to take a breath. The agent's reach is bounded by the directory you start it in — but inside that directory, it can do almost anything. We are going to make sure "almost anything" stays useful and not destructive.

5. The Brain: CLAUDE.md and AGENTS.md

Your agent's persistent memory is a markdown file in the root of whatever project you are working on. Claude Code reads CLAUDE.md. Codex reads AGENTS.md. The format is plain markdown — instructions, rules, examples.

Most beginner mistakes trace back to one root cause: the agent did not know your rules, so it made up its own. This file is how you tell it. It is also how you avoid repeating the same instructions every session.

Do not try to write a perfect brain file on day one. Start with these four rules, which prevent the most common early-days frustrations:

Accuracy & Truth

Tell the agent to prioritize technical reality over agreeing with you. AI assistants are trained to be helpful, which sometimes manifests as telling you what you want to hear. You want the opposite.

"Do not invent answers to please me. If my idea is wrong, say so. If you do not know something, say you do not know."

This single instruction will save you hours.

Sources, Trust, and Confidence

Demand that the agent state its confidence level when it makes claims. AI models will speak with the same confident voice whether they are quoting a verified source or improvising.

"When you make a factual claim, label your confidence: known from training, inferred, or unverified. Verify claims against primary sources before asserting them as fact."

You will be surprised how often "unverified" is the honest answer.

Read Before Editing

This is the one beginners hit most often. Agents will sometimes hallucinate a file's contents based purely on its name — they think they know what utils.ts probably contains, and they will write edits as if they are right. They are usually almost-right, which is worse than wrong. The fix is to make reading mandatory.

"Always read a file's contents before attempting to edit it. Do not assume what is in a file based on its name or location."

Plan Before Doing

For anything beyond a one-line change, force a pause. Have the agent write a plan, let you review it, and then execute. This is the single highest-leverage habit you can build.

"For tasks touching multiple files or making structural changes, draft a markdown plan first and wait for my approval before executing."

This converts catastrophic mistakes into easy ones. The agent might write a plan that misunderstands your intent, but reading a plan takes 30 seconds. Reading 47 file changes after the fact takes an hour and might leave your project broken.

These four rules go in CLAUDE.md (or AGENTS.md) at your project root. As you work, you will discover other rules you want to add — your project's specific framework versions, naming conventions, the directories the agent should never touch. Add them as you encounter the need. Do not try to write them all upfront.

6. Organize Your System: Folders Matter More Than You Think

A CLI agent treats your filesystem as its external working memory. If your folders are a mess, the agent's reasoning will be a mess. If you have one giant Documents/ folder with 4,000 files, the agent will struggle to find anything and may put new files in unpredictable places.

Think of your root project directory in three distinct buckets:

  1. The System / Brain. Files the agent uses to govern itself — CLAUDE.md, AGENTS.md, any custom scripts or skills you write later.
  2. The Knowledge Base. Static, read-only reference material — documentation, style guides, examples you want the agent to consult but not modify.
  3. The Workspace. The actual sandbox where work gets done and files change rapidly.

Beginners often skip this and let the agent dump everything in one place. It works for a week. By month two, you cannot find anything and the agent is generating files with conflicting names.

A simple starting structure that works for most people is PARA — Projects, Areas, Resources, Archives — a method popularized by Tiago Forte for personal knowledge management. PARA is human-centric and not designed with AI in mind, but it gets you to a clean four-folder structure on day one, which is much better than no structure.

Projects/      ← active work with deadlines
Areas/         ← ongoing responsibilities
Resources/     ← reference material
Archives/      ← completed and inactive

You will eventually want to evolve away from PARA toward something more AI-native — folder structures designed around how the agent actually consumes information, not how a human filing cabinet would. But that is a topic for a future article. PARA is enough for week one, and clean enough that the agent will not get lost.

7. Go Play

The fastest way to get comfortable is to use the agent on small, low-stakes tasks where the cost of failure is approximately zero. Do not start by asking the agent to refactor your tax software. Start with these:

Travel planning. Write a short text file (preferences.txt) listing your dietary preferences and travel style. Then ask: "Read my preferences.txt and act as a luxury travel agent. Build a 3-day food-focused itinerary for Tokyo."

Action item extraction. Paste a meeting transcript into a file. Ask: "Read this transcript and list the 3 things I need to do this week."

Tone shifting. Drop a draft email into a file. Ask: "Read my draft email and make it sound professional but firm. Show me the revised version."

ELI5 summarization. Save a complex legal paragraph or a dense technical paper to a file. Ask: "Read this and explain it to me like I am five years old."

These tasks share two properties: the agent has to read a file before responding, and the output is text you can sanity-check yourself. You build the muscle of giving the agent material to work from, instead of expecting it to know things.

While you are playing, two interface concepts are worth practicing:

The context window and compacting. As you chat, the agent's "memory" of the current session fills up — your messages, its responses, the files it has read, the commands it has run. Eventually this gets long enough to slow the agent down and degrade its reasoning. Both Claude Code and Codex have a /compact command that summarizes the conversation so far and clears out the noise while preserving your instructions. Use it when the agent starts feeling forgetful or sluggish. Aim to compact before a long session, not after.

Templates. Create a simple text file with a fill-in-the-blank format — for example, a meeting-notes template with Date:, Attendees:, Decisions:, Action Items: headers — and ask the agent to use it to structure output. Templates dramatically improve consistency. They also teach you that the agent is much better at filling in a structure than at inventing one.

8. What Comes Next

You now have a working CLI agent, a brain file with four critical rules, a folder structure that is not chaos, and some practice on real tasks. That is enough to be useful for weeks of work.

When you are ready to go deeper, the next concepts to explore are:

  • Hooks and approval modes. "Ask me first" is a soft guarantee — the agent has to remember to ask. Hooks are a hard guarantee — code that runs before every tool call and can deterministically block destructive commands. The shift from trust to enforcement is the beginner-to-intermediate jump.
  • Version control as a safety net. Git is your time machine. Once you are comfortable with git commit after every successful step, you can let the agent attempt riskier work knowing you can always rewind.
  • Progressive disclosure. Cramming 500 rules into one CLAUDE.md does not work — frontier models reliably follow about 150–200 instructions. The fix is breaking your rules into specialized files that load only when relevant.
  • Context rot and task isolation. When you need the agent to read a 1,000-line log file, you do not want all that text rotting in your reasoning loop afterward. There are specific patterns for keeping high-volume tasks isolated from the work that needs to remember things.

Each of those is a future article. For now, you have what you need. Open a terminal. Try one of the play tasks. Make a mistake. Recover from it. That is how the early days are supposed to feel.