OpenCastle

Docs / Agentic Development

Agentic Development & Multi-Agent Orchestration

Master AI-assisted software development — from effective single-agent vibecoding to coordinating specialist agent teams with orchestration frameworks like OpenCastle.

What Is Agentic Development?

Agentic development — sometimes called vibecoding — is a workflow where you collaborate with AI coding agents instead of writing every line yourself. You describe what you want, and the agent handles the how: writing code, running tests, fixing errors, and iterating until the task is done.

This isn't about blindly accepting AI output. The best results come from treating the agent as a capable junior developer — one that needs clear direction, good context, and code review.

Key mindset shift: Your job moves from "writing code" to "directing, reviewing, and verifying code." The quality of your input directly determines the quality of the output.

Write Great Prompts

The quality of agent output is directly proportional to the quality of your instructions. Vague prompts produce vague results. Specific prompts with context produce production-ready code.

DO

Be specific and provide context

"Add a `lastLogin` timestamp field to the User model in `src/models/user.ts`. Update the login handler in `src/auth/login.ts` to set it on successful authentication. Use the existing `updatedAt` pattern for the database update."
DON'T

Give vague, context-free instructions

"Track when users log in."
DO

Reference existing files and patterns

"Create a new API route at `src/api/invoices.ts` following the same pattern as `src/api/orders.ts` — validate with Zod, use the existing `db` client, and return typed responses."
DON'T

Expect the agent to guess your conventions

"Make an invoices endpoint."
DO

Specify acceptance criteria

"The component should handle loading, error, and empty states. It needs to be keyboard-accessible and work at mobile breakpoints. Add unit tests for the data transformation logic."
DON'T

Leave requirements implicit

"Build a user list component."

Build Tools, Not Tasks

This is the single most impactful pattern for agentic development. When facing a large refactoring or repetitive task, ask the agent to create a tool or script that performs the operation — rather than asking it to do the work directly.

Why Tools Beat Direct Edits

  • Repeatable — Run the tool again if new files appear or requirements change
  • Verifiable — Review the tool's logic once, trust it for 500 files
  • Reviewable — A 50-line script is easier to code review than 200 scattered file edits
  • Debuggable — When something goes wrong, you debug one script — not hunt through hundreds of diffs
  • Safe — Run with --dry-run first, apply when confident
DO — Ask for a tool

Create a codemod

"Write a codemod script that finds all React components using the old `<Button variant='primary'>` API and replaces them with `<Button color='brand'>`. Support both JSX and TSX. Add a --dry-run flag that prints changes without writing."
DON'T — Do it manually

Edit every file one by one

"Update every Button component in the codebase to use `color='brand'` instead of `variant='primary'`."

With 80+ files, the agent will miss some, introduce inconsistencies, or hit context limits mid-way.

DO — Ask for a tool

Create a migration script

"Write a script that reads all YAML config files in `config/`, converts them to TOML format, and writes the output to `config-v2/`. Preserve comments where possible."
DON'T — Do it manually

Convert each file individually

"Convert config/database.yml to TOML. Now convert config/auth.yml. Now convert config/cache.yml..."

Each conversion is a separate context window with no shared logic. Errors compound instead of being fixed once.

DO — Ask for a tool

Build a linter rule

"Create an ESLint rule that flags any direct `console.log` calls in `src/` and suggests using our logger utility from `src/lib/logger` instead. Include auto-fix support."
DON'T — Do it manually

Find-and-replace across the codebase

"Replace all console.log calls with logger calls in the codebase."

A rule catches new violations too. Manual replacement is a one-shot fix that regresses immediately.

Scope Your Requests

AI agents work best with focused, well-scoped tasks. Large, multi-concern requests lead to mediocre results everywhere instead of excellent results somewhere. Break big features into small, independently testable pieces.

DO

Break work into focused tasks

"Step 1: Create the database schema for invoices with these fields: id, amount, status, customerId, createdAt. Step 2: Build the API route with list and create endpoints. Step 3: Build the UI table component."
DON'T

Ask for everything at once

"Build a complete invoicing system with database, API, UI, PDF export, email notifications, and Stripe integration."
DO

Ship and verify incrementally

"Let's start with just the data model and API. Once that's working and tested, we'll add the UI."
DON'T

Wait until everything is done to test anything

"Build the full feature, I'll test it all at the end."

Verify, Don't Trust

AI agents are confident, fast, and sometimes wrong. Always verify their output. Run tests, inspect diffs, and check edge cases. The agent is a tool — you're still the engineer.

DO

Ask the agent to prove its work

"After making the changes, run the test suite and show me the results. Also run the type checker."
DON'T

Merge without checking

"Looks good, ship it." (without reviewing the diff or running tests)
DO

Review diffs before committing

"Show me the git diff of all changes so I can review before we commit."
DON'T

Let the agent commit and push on its own

"Just push all changes to main." (skipping review entirely)

Use Context Effectively

Agents don't automatically know your project's conventions, architecture, or unwritten rules. The more relevant context you provide, the better the output matches your codebase.

DO

Point to existing patterns

"Create a new service following the same pattern as `src/services/userService.ts` — use dependency injection, return Result types, and log with our structured logger."
DON'T

Assume conventions are obvious

"Create an order service."

The agent might use a completely different pattern — classes instead of functions, throw instead of Result, console.log instead of your logger.

DO

Mention constraints and requirements

"We use Tailwind CSS v4 with our custom design tokens. Colors come from `theme.colors` — don't use arbitrary hex values. All components must support dark mode."
DON'T

Let the agent make style decisions

"Style the card component nicely."

Iterate, Don't Restart

When the agent produces something close but not right, give targeted feedback and ask for adjustments. Starting over from scratch throws away correct work and burns context.

DO

Give specific, targeted feedback

"The table component looks good, but the sorting logic is wrong — it should sort by date descending by default, not ascending. Also, the empty state should show the illustration from `public/empty-inbox.svg`."
DON'T

Throw away everything and start over

"This is wrong. Redo the whole thing."

Without saying what's wrong, the agent repeats the same mistakes. And you lose the parts that were already correct.

DO

Acknowledge what's right

"The API route structure and validation are perfect. Just two changes: rename the `getData` function to `fetchInvoices`, and add pagination support using cursor-based pagination."
DON'T

Provide only negative feedback

"That's not what I wanted."
Multi-Agent Development

Why Multi-Agent?

A single AI agent is powerful — but it has limits. Context windows fill up. Prompts lose focus when mixing UI, backend, tests, and security in one conversation. Knowledge is shallow across too many domains.

Multi-agent development solves this by assigning specialist agents to focused tasks — just like a real engineering team. A Team Lead decomposes work, delegates to experts, and verifies results. Each agent operates within a well-scoped context, producing higher quality output.

Key Insight: Multi-agent orchestration isn't about replacing developers — it's about giving each AI agent the right scope, the right context, and the right expertise to do its best work.
DO

Decompose into specialist tasks

"Developer: implement the form. Testing Expert: write E2E tests. Security Expert: audit auth flow."
DON'T

Overload one agent with everything

"Build the feature, write tests, add docs, fix accessibility, and optimize performance."

Orchestration Patterns

In multi-agent development, an orchestrator (or Team Lead) coordinates the work. It analyzes requirements, creates a plan, assigns tasks to specialist agents, and verifies their output — similar to a tech lead managing a team of engineers.

Orchestrator Pattern
Team Lead
decomposes & delegates
Developer
Tester
Reviewer
verifies & delivers
Team Lead

Key orchestration principles:

  • Task decomposition — break work into the smallest meaningful, independently verifiable units
  • File partitioning — parallel agents never touch the same files, eliminating merge conflicts
  • Dependency ordering — tasks are phased so dependent work waits for prerequisites
  • Independent verification — every output is reviewed before being accepted
DO

Define clear file ownership per agent

"Developer A owns src/components/. Developer B owns src/api/. No overlap."
DON'T

Let parallel agents edit the same files

Two agents both modifying layout.tsx at the same time → merge conflicts and lost work

Specialist Agents

Instead of one generalist AI trying to handle everything, multi-agent systems assign focused roles with domain-specific instructions, tools, and context. This mirrors how real engineering teams operate — you wouldn't ask a backend engineer to also design the UI and write the security audit.

Premium

Architecture, security, orchestration — tasks requiring deep reasoning and cross-system awareness.

Team Lead · Architect · Security Expert
Standard

Feature implementation, UI components, API design — core development work.

Developer · UI/UX Expert · API Designer
Utility

Testing, data pipelines, DevOps — specialized but well-scoped operational tasks.

Testing Expert · Data Expert · DevOps Expert
Economy

Documentation, research, SEO — tasks that benefit from speed over raw reasoning power.

Researcher · Documentation Writer · Copywriter
DO

Match agent tier to task complexity

Premium model for security audits. Economy model for docs updates. Right tool for the job.
DON'T

Use the most expensive model for everything

Running a premium model to update README files wastes budget without adding value.

Quality Gates

In single-agent workflows, you manually verify output. In multi-agent systems, quality gates automate verification — ensuring every agent's work passes review before being accepted.

  • Deterministic checks — lint, type-check, and test suites run automatically
  • Fast review — a lightweight reviewer agent checks acceptance criteria, file partitions, and regressions
  • Panel review — for high-stakes changes (security, auth, DB migrations), multiple independent reviewers vote PASS/BLOCK
  • Self-improvement — lessons from failures are captured and fed back into future agent prompts

Quality gates turn multi-agent development from "hope it works" into a verified pipeline. Every agent's output is independently checked before it touches the main branch.

DO

Verify at every step of the pipeline

Agent delivers → fast review → lint/typecheck → tests → merge. Every gate must pass.
DON'T

Trust agent output without verification

Merging code because "the agent said it works" — always run tests and reviews.

Get Started with OpenCastle

OpenCastle transforms your AI coding assistant into a coordinated multi-agent team. It works with GitHub Copilot, Cursor, Claude Code, and OpenCode — providing the orchestration layer, specialist agent definitions, and quality gates described in this guide.

One orchestrator. Multiple specialists. Zero chaos. OpenCastle gives you 19 specialist agents across 4 tiers, on-demand skills, workflow templates, and built-in self-improvement — all configured through simple instruction files in your repo.
1

Install OpenCastle

npx opencastle init
2

Customize for your project

npx opencastle doctor
3

Ask the Team Lead to orchestrate

@team-lead Implement the new user settings page

Read the CLI documentation for setup details, or explore the plugin system for extending OpenCastle with custom agents and skills.