Mastering Agent Engineering: A Comprehensive Workflow for Productivity

This guide details a robust agent engineering workflow designed for maximum productivity and enjoyment, moving beyond basic demos to real-world application. The author, Kun, a former principal engineer at Meta, Microsoft, and Atlassian, shares insights gained from building and shipping dozens of production-ready coding agents daily. The core philosophy emphasizes a terminal-centric approach, efficient use of memory and skills, and strategic delegation to a growing "crew" of AI agents.

Why I Work in the Terminal

A fundamental aspect of this workflow is the heavy reliance on the terminal. While graphical user interfaces (GUIs) offer richer visuals, the terminal provides two critical advantages for productivity:

  1. Uninterrupted Flow: Keeping hands on the keyboard minimizes context switching. Constantly moving to a mouse breaks concentration and disrupts the creative flow. Terminal applications are inherently keyboard-driven, ensuring hands remain in one place.
  2. Ubiquitous Access: The terminal allows for a consistent workflow across all devices, including mobile. This means the same powerful tools and environments are accessible anywhere.

For those who prefer GUIs, the concepts discussed remain applicable, focusing on the underlying principles of agent interaction rather than specific interface mechanics.

WezTerm and My Lua Config

The terminal emulator of choice is WezTerm. Its key strengths include:

What is tmux?

Within WezTerm, tmux (terminal multiplexer) is essential for managing multiple agent sessions. tmux allows users to:

While tmux offers immense power, default configurations can be basic. Customizing tmux with keybindings and styling is recommended for an optimal experience.

Neovim as Editor

The preferred text editor is Neovim, a modern evolution of Vim. Neovim, like Vim, is designed for keyboard-centric operation:

While Neovim has a learning curve, mastering it leads to significantly faster and more fluid code editing.

Agent Harnesses

To interact with AI models, an "agent harness" is required. The author regularly uses four:

For this walkthrough, Cloud Code is used for familiarity, but the workflow is designed to be model-agnostic, acknowledging the rapidly evolving AI landscape.

My Global Memory File

Agents, as fresh recruits, need onboarding. This is achieved through memory files and skills.

Project-Level Memory File

Each project can have its own memory file (e.g., highbit/agents/memory.md). This file is more verbose and serves as the collective learning for agents working on that specific project. It includes:

This file is built incrementally. When an agent makes a mistake, the correction is added to the memory file, allowing agents to learn and improve over time.

Using Skills

To manage the growing size of memory files and improve efficiency, conditionally useful information can be moved into skills. For example, end-to-end testing instructions are only relevant when an agent is making changes.

Skills use progressive disclosure: only a small description is loaded into the system prompt initially, and the full skill content is loaded only when the agent decides to use it. This prevents token bloat.

How Skills May Hurt Your Agent

Caution is advised when installing random skills from the internet. These can pose security risks (e.g., exposing API keys) and may degrade performance. A skill with 177,000 GitHub stars was evaluated and found to increase token usage by 5% while worsening results. Popularity does not equate to effectiveness; rigorous evaluation is crucial.

Voice Input

A significant productivity boost comes from adopting voice input. Talking is approximately three times faster than typing.

The Importance of Agent Ergonomics

The design of external tools agents use significantly impacts their performance.

Planning with Interactive Artifacts

For complex planning, Lavish is a critical tool. It allows agents to generate interactive HTML artifacts that visualize options and prototypes, making discussions much more efficient than reading walls of text in the terminal.

This interactive approach drastically improves the clarity and efficiency of the planning phase.

Validating Code Changes

The author's approach to code validation shifts from manual diff review to a more managerial role, leveraging automation.

Long-Running Tasks

To keep agents busy during periods of inactivity (like sleep), the "Goodnight, Have Fun" tool is used.

While similar functionality exists in Cloud Code and Codex, "Goodnight, Have Fun" offers more precise control over token and iteration caps.

Parallel Worktrees and Agents

To manage multiple agents working concurrently without conflicts, Git worktrees are employed.

This enables running multiple agent sessions in parallel, each in its own isolated environment, significantly increasing parallel work capacity.

First Mate

As the number of parallel agent sessions grows, managing them becomes exhausting. The First Mate is introduced as a higher-level agent that orchestrates and manages the other agents.

This layer of abstraction allows the user to focus on the strategic direction ("where should we go next?") rather than the operational details of managing individual agents.

The Captain's Mindset

With the First Mate handling operational overhead, the user's focus shifts to higher-level strategy. This requires a mindset shift from "sailor" to "captain":

By mastering this workflow, users can transition from directly managing individual agents to becoming a strategic captain, leading a powerful crew to achieve ambitious goals. All tools mentioned are free and open-source, available on the author's GitHub.

Key Takeaways