Claude Code ➡️ Agentic Swarms
My favorite AI search and coding assistant is Claude, specifically the Claude Code extension in VS Code.
Anthropic nailed the UI/UX and leveraged the underutilized right-side panel in VS Code. Having an instance of Claude running locally, adjacent to where my code lives, feels like the correct way to integrate AI into my software development process. I can reference local files by path, classes, functions, and variables - Claude is able to pull all of this immediately into context.
Combined with the built in tools like web search, grep, sed, and MCP servers (Anthropic recently started natively supporting GitLab, which pairs awesomely with my local GitLab instance, it is a powerful pair programming assistant.
After some time, I found there are limitations to using Claude Code on it's own.
Multi-turn Conversation Performance Degradation
LLMs (including Claude Code) suffer performance degradation when used in multi-turn conversation. One study found that performance degrades 39% when users engage in multi-turn conversation compared to a single message-response. This severely hampers an iterative development process. It also puts a lot of pressure on the developer to make the first prompt comprehensive enough that the LLM gets things right on the first attempt, which is rarely the case IMO. The "Compact" operation that Claude periodically runs once you've exhausted the context window compounds this phenomenon as Claude summarizes the chat up to that point; nitty-gritty details are lost in the process.
This motivates the need to store the conversation/context up to any given point.
System Instruction Overhead Cost
Advanced users of Claude know that the real magic happens when you start modifying the CLAUDE.md file and begin inserting your own domain tuned system instructions. This includes leveraging Skills to selectively include the right system instruction for the given task at hand. For example, if I am building a full-stack app and have system instructions spread across database, API, and frontend, I don't want to waste precious tokens including all of these skills if I am making a new endpoint in the API (I only want the API skills included). This becomes really powerful when you begin including scripts that Claude can invoke from the command line. This feature is rapidly evolving and IMO feels a little too customizable at the moment. I found myself spending more time fiddling with the CLAUDE.md and writing boilerplate skills than I was building the thing I set out to create in the first place.
This motivates the need to have access to some "pre-cooked" skills that I don't need to write and be responsible for tuning to every single new project I want to build.
Cost of Managing Multiple Instances
After a few weeks of using Claude Code, I realized that there are some serious performance gains to be had turning on shared memory and launching multiple instances of Claude with different skills (system instructions) to try and tackle a task. This "agentic" approach absolutely chews through tokens, but elevated the solution from having a single pair programmer to a team of programmers working to solve my task. I found I could give each individual instance a "role" on the team so that their precious context was best spent on the skills I preloaded them with. This works great and also raises new concerns:
- How do the agents coordinate amongst themselves? It was hard to get them to truly work together. This made integrating the different pieces each agent was tasked with together into a cohesive solution.
- How is consensus reached when there are conflicting views? The classic tension between code optimization and readability began to raise. I found that my system instruction definitions inherently biased the agents implementation. My own strengths/weaknesses began to be reflected in the agents! For areas where I am weaker, the agents began to go "off-script" more and write code that appeared optimized but I had no way of checking.
This motivates the need to have algorithms built in to manage the coordinated efforts of multiple agents.
The Solution
In software, I like to say "anything can be built given enough time and resources". Building a system that fills the gap in capability that I identified above would be a gargantuan undertaking that distracts me from using these tools to build the things I actually want to build! Thankfully we live in a time where open-source is prevalent and someone had already beat me to it.
Enter the claude-flow solution.
It addresses all of the concerns I had with Claude Code and then some! I typically use the hive-mind feature for one off requests:
$ npx claude-flow@alpha hive-mind wizard
The wizard command walks you through the specification process of building a team of agents to tackle the given objective, including role specification, coordination type, consensus mechanism, and if you want each agent to get their own instance of Claude Code.
If I have a better understanding of the roadmap of things I need to build to get my desired functionality, I will queue up multiple invokes of npx claude-flow@alpha hive-mind spawn like so
npx claude-flow@alpha hive-mind spawn "the objective is stored in ./objectives/00_obj.md" --claude --queen-type strategic --max-workers 5 --consensus weighted --monitor 2>&1
npx claude-flow@alpha hive-mind spawn "the objective is stored in ./objectives/01_obj.md" --claude --queen-type strategic --max-workers 5 --consensus weighted --monitor 2>&1
npx claude-flow@alpha hive-mind spawn "the objective is stored in ./objectives/02_obj.md" --claude --queen-type strategic --max-workers 5 --consensus weighted --monitor 2>&1
...
This changes my role from a programmer into a product manager. I can fire this off and come back a few hours later to see what the team got done. It's not perfect, I still have to modify a lot of the resultant code, but this enables a team of agents to work on my product without me baby-sitting them. I had to upgrade to Claude Max to make the most of these features.
This blogpost is getting a bit lengthy, stay tuned for a follow on post where I detail some of the uses of claude-flow!