liveBook · Manning

Agent Mode

As explained in Vibe Engineering

Agent mode is an AI-assistance mode that can directly edit files and execute instructed changes within a codebase.

Agent mode can change a codebase directly, so a vague request can produce a much broader edit than intended. Unlike chat mode, which explains or suggests without directly modifying files, agent mode applies changes based on instructions. It is useful for multi-step work, but scope and verification need explicit attention. section 2.1 section 9.5.2

An agent may read files, plan, generate code, run tests, inspect output, and iterate. That loop consumes more context than a standard completion: estimates range from 5 to 20 times as many tokens. Choose agent mode when the task needs coordinated changes; for smaller tasks, inline editing or completion may be enough. section 9.5.2 section 9.1.3

A multi-step migration

A legacy JBoss application with a database, REST controllers, business logic, and UI needs changes across its layers. Agent mode supports the code modifications involved in migrating to Spring Boot and MongoDB; chat mode remains useful for explanations and suggestions. section 2.1

Constrain an agent workflow before it expands:

  • Specify the files or module relevant to the task, and exclude directories that should not be explored. section 9.5.2
  • Set a retry limit and ask the agent to stop and report unresolved failures instead of iterating indefinitely. section 9.5.2
  • Run relevant tests after changes, and review the resulting edits and failures. A token target is a cost constraint, not evidence that the change works. section 9.5.2
  • Maintain project rules as the code changes; stale instructions can be injected into later requests and mislead the agent. section 9.1.3
Listing 9.6 Custom slash commands for cost-controlled agent workflows
markdown
<!-- .claude/commands/focused-refactor.md -->
# Focused Refactor
Refactor the specified function or module with these constraints:
- Read ONLY the files directly relevant to the change
- Do NOT explore the broader codebase unless explicitly needed
- Generate ONLY the changed code (diff format preferred)
- Do NOT explain changes unless asked
- Run existing tests after changes; do NOT write new tests
- If tests fail, fix the issue in max 2 iterations, then stop and report what's unresolved
- Budget: aim to complete in under 50,000 tokens total
$ARGUMENTS

A reusable focused-refactor command combines file scope, test execution, a two-iteration limit, and a token target. section 9.5.2

Permission and planning controls vary by tool. In Cline, actions such as reading files require approval; its modes also distinguish design, editing, and question-answering capabilities. A plan can be reviewed before execution rather than treating every proposed action as an automatic change. section 5.2.1

How Vibe Engineering covers it

How deep it goes
Defines the mode and details file-scope, retry, output, and token controls for agent workflows.
Examples
Illustrates a JBoss-to-Spring Boot migration and a reusable focused-refactor command with test and retry constraints.
What you can do after
Operate/configure it using scoped instructions, tests, retry limits, and project rules for agent workflows.
How it connects
Connects agent mode to context engineering, automated testing, access control, and plan-act-observe loops.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vibe Engineering. The section links point to the parts of the book it draws on.