Technical Deep-Dive

How I Built an AI Copilot

An honest look at building a multi-agent AI system that turned one automation developer into a small team. 18 specialised agents, a structured knowledge base, and the architecture that makes it work.

18
Specialised Agents
50+
Knowledge Base Docs
5x
Database Speedup
1
Developer, Many Agents

Why I needed a copilot

The automation work was getting more complex. The old approach stopped working.

The Process (Before)

Using Gemini or Claude in the browser. Copy-paste context. Explain the project from scratch each conversation. Lose track of decisions made last week. Repeat mistakes because the AI forgot the lesson learnt.

The Breaking Point

Projects were getting bigger. 12+ workflow ecosystems. Multiple APIs. Complex business logic. The context was too scattered, too big. I was spending more time re-explaining than building. I had become the bottleneck.

The Goal

Build an AI coworker. One that knows the codebase, the conventions, the past mistakes. One that can fill knowledge gaps, pick up where I reach my limit, and push way past those limits. A force multiplier, not just a chat interface.

The Constraint

This had to work with existing tools. No custom infrastructure. No team to maintain it. Just me, an AI, and whatever I could build in the gaps between client work. It had to be practical, not theoretical.

What powers the copilot

Every component was chosen for a specific reason. Here's what I use and why.

Claude Opus 4

Core reasoning engine

OpenCode CLI

Terminal-based interface

Local File System

Persistent knowledge base

Markdown

Agent specs and docs

Python

Agent scripts

Git

Version control

Interface

Why a CLI over browser?

The browser interface resets context every conversation. A CLI tool running locally has access to the entire file system. It can read documentation, execute scripts, and maintain context across sessions.

Why: The AI can read its own documentation, learn from past mistakes logged in files, and access the full codebase without copy-paste. Context persists because files persist.
Model

Why Claude over GPT?

Claude writes better code and works natively with OpenCode. More importantly, the Pro and Max memberships give fixed monthly costs instead of unpredictable API bills that scale with usage.

Why: Predictable costs matter when you're running agents all day. Pay once, use as much as needed. No anxiety about token consumption eating into margins.
Knowledge

Why local files over a vector DB?

Vector databases add complexity and cost. For a single-user system, simple file-based knowledge just works. The AI reads markdown files directly. No embedding, no retrieval tuning, no infrastructure.

Why: KISS principle. The AI can grep through files, read specific documents, and understand context. It's simple, debuggable, and doesn't require any additional services.
Architecture

Why multiple agents?

One giant prompt trying to do everything fails. Specialised agents with focused responsibilities perform better. An agent that only does database work knows SQL deeply. An agent that only deploys workflows knows the n8n API inside out.

Why: Separation of concerns. Each agent has a clear job, clear inputs, clear outputs. The orchestrator routes tasks to specialists. Quality goes up, errors go down.

18 agents, one ecosystem

Each agent has a specific role. Together they cover the full development lifecycle.

How it works

When I give the copilot a task, the Orchestrator (Agent 00) analyses it and routes to the right specialist. Need a new workflow? Agent 05. Need to edit an existing one? Agent 13. Need database changes? Agent 15. Each agent has its own specification file that defines exactly what it does and how.

00

Orchestrator

Analyses tasks and routes to specialists. The traffic controller for the whole system.

01

Project Planner

Requirements gathering and scoping. Creates project briefs from vague ideas.

02

Project Structurer

Technical architecture design. Turns requirements into workflow blueprints.

03

Prompt Engineer

Optimises AI prompts for workflow nodes. Makes AI steps reliable.

04

API Specialist

External API integration. Handles authentication, endpoints, error handling.

05

n8n Specialist

Generates new workflow JSON from architecture specs.

06

n8n Deployment

Deploys workflows to the n8n instance via API.

07

Notion Admin

Creates and updates project documentation in Notion.

08

Version Control

Git operations. Commits, branches, version management.

09

Monitoring

Workflow health checks and alerting.

10

Workflow Critic

Automated quality validation. Catches errors before deployment.

13

Workflow Editor

Edits existing live workflows via the n8n API.

14

Communications

Drafts emails and messages in my writing style.

15

Database Management

SQL operations on Supabase/PostgreSQL.

16

GitHub Management

Repository operations, issues, PRs.

18

UI Builder

Creates single-file HTML tools and dashboards.

28,000+ lines of institutional memory

The copilot doesn't just have tools. It has context. Everything I've learnt, documented.

The knowledge base is organised into categories. When the copilot needs to know how to name a file, it reads the naming standards. When it needs to integrate with an API, it reads the API documentation. When it makes a mistake, I document it in LESSONS-LEARNT.md so it never happens again.

Coding Standards

Consistent, error-free code across all projects

JavaScript best practices for n8n nodes. Python standards (PEP 8, type hints). Common patterns and anti-patterns specific to workflow development.

Conventions

Every file type has a home and a naming pattern

File naming standards by type. Directory structure rules. Workflow versioning policy. The copilot never asks "where should I put this?" It knows.

Guides & SOPs

Step-by-step procedures for complex tasks

Project operations guide. Agent spawning guide. Session management protocol. When I figure out the best way to do something, I document it so the copilot always does it that way.

API Documentation

Complete reference for every integration

29 markdown files covering every API we use. Endpoints, authentication, rate limits, common gotchas. The copilot can write API integrations without me explaining the API.

Lessons Learnt

Institutional memory that prevents repeated mistakes

Every time something breaks in a non-obvious way, I document it. The copilot reads this file. It knows that comment syntax matters in n8n code nodes. It knows about rate limit gotchas. It learns from my mistakes.

The Onboarding Protocol

New AI sessions start with a mandatory onboarding checklist. The copilot must read 8 core documents before taking any action. This ensures it never creates files in wrong locations, uses incorrect naming, or forgets the conventions. It takes about 5 seconds and prevents hours of rework.

How a task actually flows

From vague request to deployed solution.

1

Request

"I need a workflow that sends Slack alerts when jobs fail"

I describe what I need, provide context, and point to relevant files. The copilot asks clarifying questions to fully understand the requirement before proceeding.

2

Orchestration

Agent 00 analyses and routes

The Orchestrator determines this needs: Project Planner (requirements), Project Structurer (architecture), n8n Specialist (build), and Deployment (push live).

3

Planning

Agents 01 and 02 create the blueprint

Project brief gets created. Architecture gets designed. The copilot asks clarifying questions if needed. I approve the plan before building starts.

4

Building

Agent 05 generates the workflow

The n8n Specialist creates the workflow JSON following all conventions. It knows the naming standards, the structure requirements, the error handling patterns.

5

Quality Check

Agent 10 validates before deployment

The Workflow Critic checks for disconnected nodes, missing error handling, incorrect patterns. Catches issues before they hit production.

6

Deployment

Agent 06 pushes to n8n

The workflow gets deployed via API. Git commit gets created. Documentation gets updated. All automatic.

What I'd tell myself before starting

Building an AI copilot taught me more about software development than the AI itself.

1

Documentation is the product

The AI is only as good as its context. Every hour spent documenting conventions, patterns, and lessons learnt pays dividends. The knowledge base is the real asset. The AI is just the interface to it.

2

Specialisation beats generalisation

One agent trying to do everything fails. Eighteen agents each doing one thing well succeeds. The cognitive load of context-switching is real for AI too. Keep agents focused.

3

Failures are documentation opportunities

When the copilot makes a mistake, don't just fix it. Document why it happened and how to prevent it. The LESSONS-LEARNT.md file is one of the most valuable files in the system.

4

Standards prevent chaos

Strict naming conventions, file locations, and coding standards seem bureaucratic until you have 100+ workflows. Then they're the only thing keeping the system navigable.

5

The AI needs guardrails

Mandatory onboarding protocols, quality gates, self-critique steps. The AI will confidently do the wrong thing if you let it. Build in checkpoints.

6

Start with the workflow, not the tech

I wasted time on vector databases and custom tooling before realising simple markdown files work better. Start with the simplest thing that could work. You can add complexity later if needed.

7

The human is still essential

The copilot multiplies my capabilities, it doesn't replace my judgement. I test everything, guide it when it goes off track, sometimes do things myself and explain why. I make suggestions, review outputs, and handle client communication. It's a partnership, not delegation.

8

The system improves with use

Every project adds to the knowledge base. Every mistake becomes documentation. Six months in, the copilot handles tasks that would have broken it on day one.

Practical tips that will save you time

Everything I wish someone had told me before starting. The lessons that cost me time.

Tool Choice

Why OpenCode over Claude Code?

I needed multiple AI models, not just Claude. OpenCode is free, open source, has a clean interface, and lets you swap models easily. This saved me when Anthropic randomly banned my account (a known bug affecting many developers). No response to appeals. Had to create a new account and now I keep it to one device only.

Lesson: Don't lock yourself into one provider. The ability to switch models when one fails is not optional, it's insurance.
Context Management

Why agents are not optional

OpenCode has a 200k token window. Gemini in browser has 1M. Space runs out fast. Agents don't consume your session tokens, which helps, but the real reason is consistency. Agents do exactly the same thing every time based on their prompt and knowledge base. The chat AI doesn't.

Lesson: The chat AI is greedy. It wants to do everything itself. Without agents, you'll watch it attempt tasks it shouldn't, ignore specialists, and produce inconsistent results.
Agent Zero

The Orchestrator exists because I couldn't remember

Within days you'll have 10+ agents. You won't remember their names, IDs, or numbers. The Orchestrator's sole purpose is to point the AI to the correct agent and enforce usage. Now I just say "run via Agent 0" and the right specialist gets called.

Lesson: Build the routing layer early. Don't rely on memory or the chat to figure out which agent to use.
The Classic Pitfall

Don't assume the AI knows how

I asked it to create and spawn agents. It did a good job for simple tasks, but complex ones kept getting stuck. The missing piece was context. I fell into the classic trap of expecting the AI to know things because it's "smart".

Lesson: I asked it to research agent-spawning guidelines. Anthropic's documentation came up. I read it, tested it, it worked. Now that knowledge is in the knowledge base and every session can access it.

The Prompt Engineering Loop

I don't write my own prompts anymore. The Prompt Engineer agent handles everything AI-related: OpenCode commands, agent specifications, deep research prompts, workflow AI node prompts, documentation. If it involves instructing an AI, this agent writes it better and faster than I ever could. Here's the loop: I brief it, it generates what I need, I test and refine. This is how the agent was improved too: I researched advanced prompt styles, fed the research back, and the agent upgraded itself. Self-healing loop. Agents fixing agents.

Commands: /start and /refresh

Context loading without repetition

I was repeating myself every session. Pointing to the same docs. Explaining the same structure. Now /start reads all directories, documentation, knowledge base, knows the agents, and waits for my command. /refresh is a lighter version for mid-session resets.

Commands: /end

End of day sync

Summarises the session, saves under the correct project folder, checks for misplaced files, queries n8n for updated workflows that need pushing to GitHub, checks if agents or knowledge base changed and need committing. One command, full sync.

The Power of Connected Specialists

Each agent connects to my tech stack. The n8n agent has API access to all workflows. The database agent can query, edit, delete, and create records directly. They gather their own context without me copy-pasting. Recently I ran a full database audit: structure, speed, data quality. It identified issues I didn't know existed, fixed them, made the database 5x faster with proper indexing, and flagged workflow problems based on data stuck in certain statuses. This is what happens when specialists have access to their tools.

Want to build something similar?

The principles here apply to any complex automation project. Let's talk about what's possible for yours.