Workflow with CLI Agents

Cursor (the IDE) and terminal agents are not rivals. This site already documents Claude Code and Codex. This chapter is only about one workflow and one set of rules.


Pick the door, then the model

WorkPreferWhy
Reading files, clicking diffs, iterating on UICursor desktop AgentThe editor is the review surface
Multi-file feature you still want to watchCursor + Plan ModeThe approval boundary is obvious
Long, low-interrupt terminal jobs (migrations, repo-wide lint, tests to green)Claude Code or Codex CLIBuilt for unattended runs, permissions, hooks
One non-interactive pass in a script / CIagent -p, claude -p, Codex non-interactiveNo GUI to click
Overnight cloud runCursor Cloud Agents or Codex Cloud (see those courses)You can close the laptop

Recommendation: Cursor for the interactive edit loop; Claude Code / Codex for long autonomous terminal work. Do not let three windows edit the same files at once.

flowchart LR
  P[Task] --> Q{Need to watch the diff?}
  Q -->|Yes| C[Cursor Agent / Plan]
  Q -->|No| T{Will it run a long time?}
  T -->|Yes| L[Claude Code or Codex CLI]
  T -->|No| C
  C --> G[Git commit]
  L --> G

Three CLIs in one repo

Install (commands follow each course / official page):

# Cursor Agent CLI — https://cursor.com/docs/cli/overview
curl https://cursor.com/install -fsS | bash
irm 'https://cursor.com/install?win32=true' | iex
# Claude Code — see /en/claude-code/installation/
# Codex — see /en/codex/installation/

cursor .          # open the GUI on this directory
agent "summarize the test layout"
BinaryProductTypical session
cursorDesktop editorOpen a folder
agentCursor CLISame modes / MCP as the IDE
claudeClaude CodeTerminal agent + CLAUDE.md
codexCodex CLITerminal / app, often AGENTS.md

Cursor CLI modes match the editor: Shift+Tab or /plan, /ask, --mode=plan. MCP reads the same mcp.json files.


Align rules (no three oral handbooks)

LayerCursorClaude CodeCodex
Simple shared proseRoot AGENTS.mdCLAUDE.md (can mirror the same text)Root AGENTS.md
Structured, globbed rules.cursor/rules/*.mdcFollow the Claude Code courseCodex rules / hooks
Skills.cursor/skills/, .agents/skills/.claude/skills/.codex/skills/
MCP.cursor/mcp.jsonClaude Code MCP configCodex MCP config

Keep shared invariants (test commands, package boundaries, “never commit .env”) in root AGENTS.md only. Cursor reads it; Claude Code / Codex also honor markdown instruction files.

Cursor also loads skills from .claude/skills/ and .codex/skills/ (and the home-directory twins), which helps a shared repo. Do not copy three drifting “always bun / always npm” notes—one source of truth, and the other files say “see root AGENTS.md.”

Leave Cursor-only behavior (alwaysApply, globbed UI rules) in .mdc. Hooks, permission prompts, and sandboxes belong in the Claude Code and Codex courses.


Morning — scope in Cursor

  1. Open the repo, Ctrl+I, explain the module (Quick Start).
  2. Large feature: Shift+Tab, save the plan to the workspace.
  3. Tiny local edits with Tab / Ctrl+K.

Afternoon — hand the long job to a terminal

Give the CLI the mechanical, checkable slice of the plan. Commit or stash first so two agents do not collide:

# In Claude Code or Codex (illustrative; follow each course's CLI)
Implement steps 3–5 of docs/plans/health-endpoint.md.
Do not change the public URL. Stop when npm test passes.

Evening — review back in Cursor

git diff, then ask Agent to review—not to regenerate the feature:

Review the unstaged diff against docs/plans/health-endpoint.md.
List mismatches only. Do not edit files unless I ask.

Conflicts and locking

  • Only one agent writes files at a time. The other stays on Ask / read-only review.
  • Commit or branch before a long CLI job. Cursor checkpoints will not revert the other agent’s terminal edits.
  • Do not run overlapping global MCP JSON in the IDE and CLI unless you understand precedence.
  • Credentials stay in environment variables; never in rule files.

When Cursor alone is enough

  • You are tuning CSS / components and need the browser tool plus instant diffs
  • You are teaching: the sidepane is easier to narrate than a terminal log
  • The repo has no CLAUDE.md / Codex setup and you do not want another stack today

Leave the IDE when the job needs 30+ minutes, fine-grained permission prompts, or CI—open Claude Code or Codex and follow their install chapters.


Next

评论