ZenCoderZenCoder

Agent Mode

Agent mode is ZenCoder's most powerful feature. Give it a natural-language task and it will autonomously read your code, reason about what to change, and apply precise edits โ€” all within your workspace.

โš ๏ธ
Agent mode can modify files. Review proposed edits carefully before confirming. Use --max-iter to limit autonomous steps on complex tasks.

How it works

Agent mode uses a ReAct loop โ€” Reason, Act, Observe โ€” until the task is complete or the iteration limit is reached.

1. Plan
ZenCoder reads the task and decides which files to explore first.
2. Read
It calls file_read, file_glob, and workspace_search to gather context.
3. Reason
The model synthesises what it found and decides what edits are needed.
4. Edit
It calls file_edit with a precise diff. You're shown the proposed change and asked to confirm.
5. Verify
It re-reads the edited file to check the change landed correctly.
6. Repeat
If more files need changing, it continues until done or max iterations.

Agent tools

The agent has access to six workspace tools. It decides which to call based on the task.

ToolDescription
file_readRead the full contents of any file in the workspace
file_globFind files matching a glob pattern (e.g. **/*.go)
workspace_searchFull-text search across the entire workspace
list_directoryList directory contents recursively
file_editApply a targeted diff/edit to a file
file_removeDelete a file from the workspace

CLI usage

  1. 1

    Simple agent task

    zencoder agent "Add input validation to all POST handlers"
  2. 2

    With a specific model and iteration limit

    zencoder agent \
      -m anthropic/claude-3-5-sonnet \
      --max-iter 20 \
      -w ./internal \
      "Refactor the auth module to use the new AppError type throughout"
  3. 3

    Review the session trace

    Each agent step is logged. You'll see something like:

    [Agent] Reading: internal/auth/middleware.go
    [Agent] Search: "AppError" โ†’ 12 matches in 5 files
    [Agent] Reading: internal/errors/errors.go
    [Agent] Proposing edit to internal/auth/middleware.go
    
    --- a/internal/auth/middleware.go
    +++ b/internal/auth/middleware.go
    @@ -42,7 +42,7 @@
    -    return fmt.Errorf("unauthorized: %v", err)
    +    return &AppError{Code: 401, Msg: "unauthorized", Cause: err}
    
    Apply this change? (y/n/skip): y
    [Agent] โœ“ Applied. Continuing...

Agent mode in VSCode

Switch the Mode dropdown to Agent in the chat panel. All subsequent messages run through the agent loop โ€” ZenCoder will read and edit files in your open workspace directory.

โ„น๏ธ
Plan mode shows the proposed step list before executing. Ask mode is single-turn and never edits files. Agent mode is the only mode that can write to disk.

Best practices

  • ยทBe specific about scope: 'Refactor the auth module' is better than 'Refactor the codebase'.
  • ยทUse --max-iter on large tasks to step through changes incrementally.
  • ยทReview each proposed edit before confirming โ€” the agent shows diffs.
  • ยทCommit your current work before running agent mode on critical files.
  • ยทUse --routing cloud for complex multi-file refactors; local models work for small, targeted edits.
  • ยทThe agent has no network access โ€” it can only read/write files in your workspace.

Next

Troubleshooting โ€” common issues and fixes