Working with Agents
The Collaboration Spectrum
Section titled âThe Collaboration SpectrumâMaximizing AI involvement isnât the pointâeffective agentic engineering is about finding the right balance for each task. Neither doing everything yourself nor delegating everything works well.
Hands-off works best for well-defined tasks:
- Boilerplate generation
- Test writing
- Documentation
- Refactoring established patterns
Hands-on is essential for:
- Architecture decisions
- Security-sensitive code
- Requirements clarification
- Domain-specific logic
Most real work falls somewhere in between. Feature implementation, debugging, and API design benefit from active collaboration where you guide while the agent executes.
When to Intervene
Section titled âWhen to InterveneâWatch for these signals that itâs time to step in:
- Agent looping: Repeating similar attempts without progress
- Quality declining: Output getting worse, not better
- Scope creep: Drifting beyond the original task boundaries
- Irreversible actions: About to delete data, push to production, or make breaking changes
When the agent is making steady progress and errors are getting corrected, let it continue. Intervene when you see circular patterns or diminishing returns after 2-3 reprompts.
The Review Mindset
Section titled âThe Review MindsetâReviewing agent output differs fundamentally from reviewing human code. Focus on intent and correctness, not style preferencesâthe agent wonât learn from your feedback anyway.
Always verify:
- Does the output actually solve the stated problem?
- Are edge cases and error conditions handled?
- Is the approach reasonable, not just functional?
- Any security implications?
Donât assume passing tests mean correctness or that confident explanations reflect accuracy. Treat agent output like code from a skilled contractor: technically competent but unfamiliar with your specific context.
Building AI-Ready Codebases
Section titled âBuilding AI-Ready CodebasesâThe Unix philosophyâsmall tools, clear interfaces, composabilityâis exactly what agents need to work effectively. Structure your code with agents in mind.
- Small, focused functions: A 20-line function is far easier for an agent to understand and modify correctly than a 200-line one. Smaller scope means fewer errors.
- Clear interfaces: Explicit inputs and outputs help agents reason about dependencies and chain operations together. Ambiguous interfaces cause integration bugs.
- Consistent patterns: Predictable structure reduces agent errors. When similar problems are solved similarly, agents can apply patterns reliably.
- Good naming:
getUserById(id)beatsget(x). Descriptive names are context that helps agents understand code without extensive exploration.
You donât need to rewrite everything. As you touch code, nudge it toward these patternsâthe benefits compound over time.
Effective Feedback
Section titled âEffective FeedbackâWhen course-correcting, be specific about whatâs wrong and what you want instead. âThe error handling is missingâadd try/catch blocks that log failures and return graceful fallbacksâ will get far better results than âFix the error handling.â
Keep corrections focused. A single clear direction works better than multiple vague complaints.