Forward-deployed / Learning zone
Prompt engineeringa standalone module
Lesson 08

Prompting inside coding agents

TL;DR

Coding agents — Claude Code, Cursor, Aider, Windsurf, Continue — are agents whose tools are read_file, edit_file, run_command, search_code. Their prompts carry more weight than any other kind of prompt in daily use today, because the output isn't a chat reply — it's real code that ships. The prompt-engineering craft here has its own idioms: the prompt is the spec for the change; a project-level context file (Claude Code's CLAUDE.md, Cursor's .cursorrules, Aider's CONVENTIONS.md) supplies house rules to every session; plan mode or "propose-then-apply" separates thinking from acting on high-risk changes; and sub-agents or delegated tasks parallelize work while protecting the main context window. This lesson names the patterns, so a developer new to coding agents gets the leverage on day one instead of stumbling into it over a month.

🎯 For the AI PM (or coding-agent user)

Why it matters — For developers, this is the highest-productivity prompting surface in the industry right now. For PMs, it is where "vibe coding" turns from demo into product (see TPM for AI products).

What it changes in your decisions — You start treating your CLAUDE.md (or equivalent) as a versioned engineering artifact, not a scratch note. You reach for plan mode on any change touching more than one file. You delegate parallel investigations to sub-agents instead of blocking the main session.

Ask yourself — "Am I prompting this coding agent the way I would write a ticket for a competent contractor — spec, constraints, verification — or the way I would text a friend?"

Risk if ignored — Agent-generated code that compiles, runs, and quietly breaks something else. Or a session that wanders because you never named a success condition, and you don't notice until 45 minutes in.

The mental model

A coding-agent session

Every arrow is a prompt-engineering surface

Your prompt is the task. The project context file is the always-on system prompt.

The session
Your prompt — the task
Project context file — CLAUDE.md / .cursorrules
Agent
Tools — read · edit · run · search
Proposed changes — files, commits
You review + approve or redirect → loops into the next task

Every arrow here is a prompt-engineering surface. Your prompt is the task. The project context file is the always-on system prompt every session inherits. The tool descriptions are what the agent reads to decide what to do next. The proposed diff is what you review — and the quality of your review depends on how tightly you scoped the prompt.

Pattern 1 — the prompt is the spec

Coding-agent prompts read like small tickets, not chat messages. A weak prompt:

Add caching to the search endpoint.

A strong prompt:

Add an in-memory LRU cache to src/search/handler.py's search() function.

  • Cache key: the normalized query string.
  • Cache size: 1000 entries. Eviction: LRU.
  • Cache TTL: 5 minutes.
  • Do not cache when the caller passes no_cache=True.
  • Add a unit test in tests/search/test_cache.py covering: cache hit, cache miss, eviction at capacity, TTL expiry, and the no_cache=True bypass.
  • Do not touch any other file.

Every line in the strong prompt is a constraint the agent will honor. The "do not touch any other file" line alone prevents 30% of accidental sprawl.

The rule: prompt as if the agent will do exactly what you wrote and nothing you didn't. Because it will.

Pattern 2 — the project context file is the always-on system prompt

Claude Code reads CLAUDE.md. Cursor reads .cursorrules. Aider reads CONVENTIONS.md. All of them play the same role: a project-scoped file, checked into git, that ships to every session as part of the system prompt.

What to put in it:

What NOT to put in it:

Every project's CLAUDE.md becomes a prompt-engineering artifact you version and review like code. A bad CLAUDE.md invisibly degrades every session in that project.

Pattern 3 — plan mode and propose-then-apply

For any change touching more than one file, or any change to unfamiliar code, run the agent in plan mode (Claude Code's /plan; Cursor's "Ask" mode before "Compose"; Aider's /architect). The agent proposes the change without applying it. You review the plan, redirect if needed, then approve.

The idiom:

Skipping plan mode on a large change is the coding-agent equivalent of skipping code review. Fast at first. Painful the second time.

Pattern 4 — sub-agents for parallel investigation

Both Claude Code and Cursor let you spawn sub-agents (background tasks, task tool) for work you want to run in parallel without polluting the main session's context. Good uses:

The rule: sub-agents are for tasks whose result you want, not tasks whose process you want to steer. If you need to intervene mid-task, do it in the main session.

Pattern 5 — verification is part of the prompt

The best coding-agent prompts end with a verification clause: "After making the change, run pytest tests/search/ and report the output." "Then run npm run typecheck." "Then show me the diff." The agent runs the check itself and either declares success with evidence or reports the failure. This is the coding-agent equivalent of the acceptance criteria in a PRD.

Without a verification clause, the agent judges its own work on vibes.

Tradeoffs

Failure modes

Practitioner checklist