How to Actually Use AI Coding Agents
A practical guide to Cursor, Claude Code, and OpenCode — what each tool is built for, how to prompt them well, and how to combine them without losing control of your codebase.
Every developer I know has tried an AI coding agent, been impressed for five minutes, then spent an hour cleaning up the mess it made. The problem is rarely the tool. It's the workflow.
After using Cursor, Claude Code, and OpenCode daily on real production projects, here's what I've learned about how to actually get value from these agents — not just generate code, but ship better software faster.
The Three Tools, Honestly
Before talking workflow, a brief map of the landscape.
Cursor is an IDE forked from VS Code. It's the most approachable entry point — your extensions, themes, and keybindings migrate over instantly. Agent mode lets you describe a task and watch it plan and apply multi-file changes inline. Diffs are visual, every change is reviewable before accepting. It's designed around the principle that you drive, AI assists.
Claude Code is Anthropic's terminal-first agent. It's the philosophical opposite: AI drives, you review. You describe what you want, the agent navigates your codebase, runs commands, writes tests, and executes everything in your real shell with your real environment. It connects to any shell-based tool — Docker, kubectl, git, your CLI of choice. Where Cursor excels at flow, Claude Code excels at depth — the hardest bugs, unfamiliar codebases, architectural changes that touch many files at once.
OpenCode is the open-source challenger from the SST team. Terminal-native with a clean TUI, provider-agnostic (Claude, OpenAI, Gemini, local models — all work), privacy-first, and free. It ships with two built-in modes you toggle with Tab: build for full file access and plan for read-only exploration. For developers who live in the terminal and want full control without subscription lock-in, it's the most interesting option right now.
The Real Skill Is Prompting, Not Picking
Here's the uncomfortable truth most comparisons miss: once you're past a baseline level of tool quality, output quality is almost entirely determined by how clearly you structure the task — not which agent you use.
A vague prompt produces a vague solution. Always.
The best prompts follow a simple structure:
Context: what the codebase does, what this file is for
Goal: what you want the agent to produce
Constraints: what it must not touch, what patterns to follow
Verification: how you'll know if it worked
For Cursor, this becomes the chat message before you hit send. For Claude Code and OpenCode, this is the task body you write in the terminal. The structure is the same either way.
The CLAUDE.md / AGENTS.md Pattern
The single highest-leverage thing you can do when starting a project with any agent is creating a persistent context file at the root.
- Cursor →
.cursorrules - Claude Code →
CLAUDE.md - OpenCode →
AGENTS.md(auto-generated with/init)
This file gets injected into every request. It becomes the agent's persistent knowledge about your project. A good one includes:
- Architecture overview — what this project does, how it's structured
- Coding conventions — naming patterns, error handling, which libraries to prefer
- What to never touch — production config, auto-generated code, vendor files
- Lessons learned — mistakes the agent made before, patterns that worked well
When the agent makes a mistake, update the file. Every error becomes a prevention. Every good output becomes a repeatable pattern. This compounds over time — a well-maintained context file makes every subsequent session noticeably better.
Context Windows and When to Clear Them
One of the most common reasons agents start producing worse output mid-session is context pollution. Over a long session, the window fills with old file contents, irrelevant command outputs, and stale conversation that actively confuses the agent.
The fix is counterintuitive: clear context frequently.
In Claude Code, use /clear between unrelated tasks. In Cursor, start a new conversation. OpenCode handles this automatically with an auto-compact feature that summarizes the conversation when approaching the context limit — one of its most underrated design decisions.
A clean, focused context will outperform a bloated one every time.
What Agents Are Actually Bad At
Knowing when not to use an agent matters as much as knowing how to use one.
Avoid agents for:
- Early architecture decisions — these require business context, growth projections, and constraints the agent can't know
- Design and UX judgment — agents produce functional interfaces, rarely elegant ones
- Complex cross-service refactoring touching message queues, multiple databases, and microservices simultaneously
Use agents for:
- Boilerplate that follows an established pattern already in your codebase
- Writing tests for code that already exists and works
- Refactoring a specific file with clear, scoped requirements
- Debugging with a concrete error message and reproduction steps
- Generating documentation from existing code
The mistake most developers make is handing agents open-ended architectural problems, then being frustrated when the output doesn't fit. The right mental model: a very fast, very capable junior developer who needs precise instructions and loses track after too many things change at once.
A Workflow That Actually Works
Here's the loop I've settled into after months of daily use:
1. Plan first, always. Before opening any agent, write the task in plain language. What needs to change, why, what must not break. This thinking is valuable independent of the agent — it forces clarity that makes the prompt better.
2. Use plan mode before build mode. Both Claude Code and OpenCode have a read-only exploration mode. Start there. Ask the agent to map the relevant files and describe what it would do before doing it. This surfaces misunderstandings early, before any files are touched.
3. Small, verifiable tasks. Break large features into the smallest unit that produces a testable outcome. "Add email validation to the signup form and write a unit test for it" is a good task. "Build the auth system" is not.
4. Review every diff. Never auto-accept. Even when the agent is right, reviewing the diff keeps you mentally in the codebase. The moment you stop reading what the agent writes is the moment bugs start accumulating silently.
5. Commit after every working step. Agents working across multiple files can leave the codebase in a broken intermediate state. Frequent commits give you clean rollback points and make it obvious when something went wrong.
The Combination That Works Best
No single tool wins every situation. The combination I've found most effective:
- Cursor for feature development in a codebase I know well — the visual diff and inline chat are fast and comfortable
- Claude Code for the hard problems — a subtle bug I can't locate, refactoring a module I didn't write, understanding an unfamiliar dependency
- OpenCode when I'm on a machine without Cursor, working in a monorepo with sensitive code, or want to switch models without changing tools
They're not competing. They're different tools with different strengths, and knowing which to reach for in which situation is half the skill.
The Underlying Principle
The developers getting the most out of AI agents share one habit: they treat the agent as an accelerator for thinking they've already done, not a replacement for doing the thinking.
The prompt is the product. The agent is the execution layer.
Write better prompts, maintain better context files, review every output, and commit often. The tool matters less than you think.