Most people who use Cloud Code almost never touch sub agents, and when they do, they don't use it the way I'm about to show you in this video. Typically, if they're a developer, they're doing it for reviewing pull requests,
running tests, running different code actions in parallel, and doing technical tasks in general. But here's what nobody's really talking about. The fact that you can use sub agents for tons
of nontechnical work and get it done that much faster, more efficiently, and more importantly,
without bloating your context window. And I'm talking about brainstorming,
planning, and all kinds of decision making. You can literally build yourself an AI council
with different perspectives, with different intentions and goals so you can make the best decisions and the best plans possible,
whether it's for a technical project or something personal or project management as a whole. And beyond just spinning them up and giving them instructions,
I'm also gonna show you a very low resolution trick that I use to monitor exactly what they're doing. Because typically, if you spin them up, you don't really know what they're doing until you get the final result. So I'm gonna show you my way of spying on them. Let's dive in. Alright. So I'll first walk you through the mental model of using sub agents in the nontechnical way, and just know that if you are technical or you wanna apply this to technical circumstances,
you absolutely can. I just wanna make it as business practical as possible, and you can take everything and just build on it from there. So the crux of the problem is typically most beginners, even intermediate,
just use Claude code in a way they just treat it like chatty bitty, where you have a conversation.
Once it fills up, you do some form of compaction. And if you don't know what compaction really does behind the scenes, in a way, it's somewhat random and nondeterministic
what Claude chooses to prioritize
when you compress your conversation. And when that happens, people start getting shocked, even though they shouldn't, that their conversations are degrading over time. So one of the most elegant ways to avoid this is creating a series of sub agents. Now as with everything vibe coding, some people are taking this to the next level where they have ten, fifty, a 100 sub agents that are all running in parallel. And while that sounds super cool,
realistically,
you should hire a sub agent the same way you would hire an employee if you were a bootstrap startup. When you feel like there's a task that deserves to run mutually exclusively
and can run without any form of dependencies
or run-in some order where the first agent goes first and baton passes it to the second, then this is where it makes the most sense. Because not only does it keep your main window clean and your context as clear as possible, but it also creates more focus between the agents. As of this recording, at least, it's well documented that Claude typically loses focus,
starts its hallucination nation journey
around 40 to 50% of the context window being used. Meaning, as you approach 80% or 90% of the context window being filled for that session before compaction, you'll notice a step down in quality. So my goal is to help you avoid that completely. Now like I said at the start of the video, the goal isn't just to spin them up, it's also to find an easy way to monitor them. If you've watched my other videos, then you know I have a tendency to go crazy mad scientist.
But in this case, I came up with a very low resolution solution where I make this markdown file, and I just call it shared reasoning.
And it's literally a file with a series of text where each agent makes its notes about what it did, what it thought, and how it came to its final conclusion. And the funny part is you can even have them simulate
debating each other if you're doing something again more on the nontechnical side. Not only does this allow you to do things like create a optimist agent, a neutral agent, and a devil's advocate agent,
like I'll show you shortly, but it gives Claude this ability to neutrally look at all the perspectives and without sycophancy,
and what that means in plain English is without its tendency to always tell you you're absolutely right, it can look at those arguments and then through pattern recognition,
give you a better decision making framework. So instead of just relying on the wisdom of one language model, you have the luxury of tapping into three brains
that came to their own conclusions in separate sessions with fresh virgin blank context windows. So the result I'm going for is a shared reasoning file where you can see the optimist agent,
how it thought through things, its key insights, recommendations,
and same thing across the board. And, again, you can take this idea, create your own derivative of it, create a series of reasoning files, but the overall goal is I go on x a lot and I see very overengineered
surveillance systems of agents. But if you as the builder and the user just wanna keep tabs on what your agents are doing, this is a pretty simple way to do that that's not intimidating to someone that's not technical. So with that, let's hop into the terminal. So you can use the Claude code extension,
but because the terminal shows a lot more verbosity,
which in plain English means, it shows a lot more of the intermediary steps of what's happening behind the curtains, I will go through and do this on the terminal itself. So I'm just gonna click out of the extension. I'll open the terminal in cursor. I will use my shortcut command to invoke the dangerously
skip permissions as I usually do, and then we will just ask a basic question. Just because if you're not as acquainted with sub agents, it's helpful to really just ask Cloud Code what's happening underneath the hood. Okay. So can you just break down what sub agents you come up with or come with out of the box?
So asking this is helpful because you can literally ask it how it's configured,
what comes out of the box, and most importantly,
what you can build on or invoke without having to rebuild yourself. And you can see here, have general purpose agents. I have explore agents.
Those are great for code exploration or even file exploration.
You have planning agents. You have feature explorers, code reviewers,
even a mobile app builder agent.
So you can create your own very easily, and all you have to do is just do slash
agents,
click on manage configuration.
I have some that come out of the box. You can click on create a new agent. And in this case, we're gonna create it at the project level. Now the difference between this
and this
is one is gonna be global, meaning if you always want a sub agent to exist and persist in every project moving forward, then that's the option you're gonna pick. So we'll pick project,
and we'll do generate with Claude. Even though you could just go to Claude on the outside, you could have a external Claude code session to help you create a very refined prompt yourself if you wanna be able to get into the nitty gritty. Alright. So I'm just gonna dictate in Claude the big picture, and it will write the instructions for the sub agent itself.
Okay. So I'm creating a language model council, and on this council, I wanna create a optimist
maximalist that always looks at the glass half full without doing it blindly. So not just a hype person or a hype agent,
but something,
someone that will take ideas, take suggestions,
and extrapolate the best way that something could go and what would need to happen for that to be true. So
pretty poetic,
but this should be able to generate from that description our angel agent, and then we'll create our devil agent. Then eventually, we'll create our neutral agent. Now I'm not gonna worry about hooking it up with tools or MCPs, although I could do another video about sub agents where I go much deeper. Let me know down the comments below if you're interested. I can click on continue, and then we can assign it a cheaper model because I don't need some crazy complex thinking. So we'll do SONNET, and then we'll pick green for optimism.
This is the prompt it's coming up with. It's called the optimist strategist. It tells you exactly where it's gonna be located,
the description of the agent. So use this agent when you need a perspective that explores the best possible outcomes of an idea, proposal, or situation while grounding that optimism in actionable pathways. So that's exactly what I want. So I'll click on create.
Now we have that ready to go. I'll create the devil agent or not the devil agent, the devil's advocate agent. So we'll send over a similar prompt. Okay. So I wanna spin up a devil's advocate agent, and the goal of this agent isn't to say no no matter what. It should be able to take into account some form of nuance. It shouldn't always look at the darker side, but it has a tendency to be more on the pessimistic
side of things. So it's not unrealistically
pessimistic,
but it looks at situations
or ideas in a way where it looks at the other side and really pushes back on pure maximalist
optimism.
So you'll notice yourself learning how to say poetic words to create these prompts because you have to describe
the TLDR of what you're going for and then hope that Opus is smart enough to extrapolate off of that. Once again, we'll click on continue.
I'll pick Sonnet, and this time, as you guessed it, we'll make it red toward devil's advocate.
Use this agent. Let's just take a look here. Use this agent when you want a critical examination of ideas, plans, proposals,
or assumptions.
This agent excels at stress testing. That's exactly what we're going for. Optimistic projections, identifying blind spots, surfacing hidden risks, etcetera. So we're good to go. We'll create the neutral agent later. So all I'll do is I'll escape from here. And one pro tip is if you ever wanna invoke a specific one of these sub agents, all you have to do is do at and then do optimist
right here, and you'll see that it invokes this specific agent. So if you wanna send a very specific request purely to the devil's advocate and you don't wanna leave it up to chance as to whether or not Claude realizes when to invoke which, then this is the best way to do that. Now that I have both, one shortcut I could do is just do slash initialize. This will create a Claude MD with the understanding of the existence of these different sub agents. Can we change it? Absolutely. And I will change it because I will tell it when to invoke them and how to make them work because we're missing one piece of the puzzle, which is creating this shared reasoning file where they're dictated to document what they're doing and how they're doing it. And you can see right there, it's written the Claude code file, and it gives you the TLDR right here. So it tells you that it understands the project purpose,
agent configuration system for decision making, the architecture,
file structure.
So we have the eighty twenty good to go. Now we need to give it the 20. So let us basically give it the instruction now on creating this file and documenting in CloudMD that will act as our command center to steer the course of the conversation and how these sub agents are invoked. So let me do this.
Okay. So now I wanna create a file that I called shared underscore reasoning dot markdown file. And what I want to happen is, and I want you to document this in the CloudMD,
is when I ask for my counsel to gather,
you can't even create a magic word that I can say, like, agents gather.
I wanna be able to submit an idea and have both sub agents work on developing that idea, coming up with a base case where it could work or where it couldn't work. And depending on where that sub agent skews, I want it to come back with a full report, but also throughout that process,
document its thinking and its decision making process,
any key insights in this shared reasoning file.
Essentially, even though these sub agents can work in parallel, I want them in parallel as well to document what they're thinking, how they're coming to their conclusions,
so everything is maintained in this markdown file. And I want you to persist this behavior even if we add more agents to this very council.
So this should be able to give us exactly what we're looking for. I'll send this off, and I'll show you the result. And you can see right here, it says, I will launch all council agents in parallel. Each agent will document their reasoning and shared reasoning.
Each agent returns a full report with their perspective,
and you get a balanced view with a persistent record of how each agent reached their conclusions,
which is awesome because what we can do in the future, just as a spoiler, is we can have Claude itself
look at the shared reasoning file, then come to its own conclusions without its natural bias to always be this yes person to say, you're so awesome, Mark. Your idea is so smart. You're absolutely right. In a way, we're trying to weight its opinion in the virgin opinions of someone that's supposed to be negative, someone that's supposed to be positive, and now we'll add someone that will be neutral. So since I'm lazy and now we have everything in context, I will just ask it to spin up a sub agent that is on the neutral side. So I'll say, cool. Can you spin up one more sub agent that you also persist in our dot clawed root folder as a sub agent MD?
And we want it to be a neutral sub agent. So you can see how the positive one is configured, the more negative or pessimistic one, create a neutral one, and then update the clot MD and the rules accordingly.
So now we can just offload because we have enough context within the session for it to know exactly what I'm looking for. And after a few minutes, it not only rereads the instructions that we had before, so both of the sub agents right here, it then creates another markdown file that's stored in our CloudMD as you could see right here, the neutral analyst. It comes up with a description without us even having to do the slash command agents,
and then it updates the CloudMD to add the neutral analyst as well. So it says it provides objective analysis, maps trade offs, synthesizes perspectives,
and anchors decisions to evidence. So that's exactly what we're looking for, and then even gives us a diagram. It came up with a color for blue for neutral. So that's how you know we have AGI. It came up with blue. Key characteristics,
output structure, and now it shows you the updated council. So now you could be ready to go. You could add a few more because with this, unlike with the world of code, I can tell you working on production grade projects for clients, we don't use sub agents that often in production because and you can spin up even more if it makes you happy, but in most cases, of five or six, at least for this specific application,
you might not need them. So now that everything's set up, I won't test it in the same chat because some people have this tendency
to set everything up in a chat and then ask for x, and then x works perfectly. And when they go in a brand new chat, x doesn't work anymore. And the reason is you had this running conversation in context. So even if for whatever reason the sub agent wasn't set up properly,
because the context is here, it will execute the task perfectly. So we wanna be able to stress test our CloudMD,
our central brain, to make sure it knows exactly how to orchestrate all of our agents. So all I'll do is I'll open a brand new session. We'll re spin up Cloud Code, and we'll test out an actual idea. And now comes the fun part. So I'm actually gonna give a real idea that myself and my team have been working on as one of our 100 side projects, and it's for creating an AI avatar academy
where anytime something new comes out in AI, it will use the Hegen API
to create a series of lessons, and I'm curious to see if it would make sense to go head to head with other well known education companies that do async content, but have this platform that always auto updates, uses my likeness to see does it make sense, does it make business sense, is there longevity or not. Okay. So I had this crazy idea, and I want to align and invoke my entire council to give me their thoughts on this matter. So I wanna create a brand new platform. I wanna call it AI Avatar Academy.
And the goal of the academy is there would be some form of scheduled cron job that would watch everything brand new that's coming out on the Internet. So if it's a brand new update from Google Gemini or Anthropic or OpenAI
or something that's really trending on x related to GenAI,
I would want it to go and scrape that information,
go and look up the documentation,
then use Hegen or similar and use the, let's say, the Hegen API to come up with a clone avatar of myself and then create and spin up tons of lessons. So when people go in, there is an ever growing library
of AI generated content that they know is AI generated, but it also comes with this knowledge based chatbot that also has knowledge of those same things. So they have this ever growing portal of tutorials that they can watch.
What do you think about this idea? So now I will try to inhale oxygen after that soliloquy
while this hopefully invokes all of our sub agents. And you can see right here, it says, let me gather the full council to give you a comprehensive perspective on AI Avatar Academy, and you can see we have now invoked all three agents. We have the optimist, the devil's advocate, and the neutral one, and I will go into the future and come back once they're done. And this is still not done, but I wanted to show you a peek of what's happening. So the beauty of sub agents, as you can see right now, the token usage is around the same for all of them. And had they all run-in the same session, we would have had almost 80 to 90 already full because the denominator,
as of this recording, is 200 tokens. So the fact that they're all running on their own, meaning they're still in their prime real estate of context window, they're not in the hallucination nation zone, and they can keep focusing on their specific task, which is taking our goal and just scrutinizing it with their perspective. And after five minutes, they finish up. They've all used around 50,000 tokens. We'll take a look at the shared reasoning file shortly.
But you could see it comes back with a council report.
It walks through each of their perspectives. So the visionary, the optimist naturally leans positive where it says it could become the definitive
real time knowledge infrastructure
for AI literacy where millions turn first to understand what's happening in AI.
And then the devil's advocate, which I care more for, is it really scrutinize the API that I'm talking about that from a cost standpoint,
it might not make sense unless we're not making enough revenue.
Legal liability,
so scraping likely violates the terms of service of major platforms,
derivative content from copyrighted docs, legally gray,
actually very solid points. And you have the neutral one that basically assesses the technical achievability, high,
content quality achievable, medium, market viability, low medium, and then economic viability, uncertain.
So now this gives you the ability to audit all of these different perspectives. It comes back with a consensus,
and then Claude,
neutrally,
gives you a recommendation that says proceed with the validation first approach,
curation algorithm, plus 50 high quality tutorials
to prove the concept. And then the agent gives you the TLDR of the devil's advocate,
high risk, validate demand, model economics. So what's cool is if you can imagine this Venn diagram, it's looking for what is shared in the middle. So if you're trying to make a hard decision in the business,
in life, what you should sell in AI if you are selling AI solutions, then this could be super useful. And then just to finish things off, I just wanna show you one of the more complex,
very scientific prompts I like to do once in a while. Make them fight each other. I told you. It's very scientific. So now what happens is we have them run-in parallel again, but this time to scrap each other instead of to independently
just write in the same file what conclusion they come to. So then it comes back with a series of fights and the proclaimed winner. So round two,
optimist fires back at critics,
and it walks through exactly what their arguments were. So you're comparing apples to oranges for YouTube versus HeyGen powered learning.
Um, I'm even gonna continue reading that.
Devil's advocate dismantles
the optimism. So it's like you're watching a play by play. Neutral analyst calls out both sides. So you get to and I mean this in serious terms. Look at different lines of reasonings. Naturally, I am making this more extreme to make this more entertaining and for you to get the point. But if you have actual
mature
decision making processes, you can do this to look at a scoreboard and see, alright. Where do the devil's advocate win versus the optimist and why? Then you can always take a look at our file, which I haven't shown you yet, but it really well organizes everything. So you could see this file captures the collective thinking process of the agent council.
Each agent documents their reasoning, key insights, and decision making process. So you could see it dates the session. It looks at the overall idea under review,
the neutral analyst reasoning, key considerations,
analysis process, critical insight,
optimist,
uh, strategist reasoning, same thing. And then you have this all documented with also a confidence level when they come to their final conclusions. And, I actually use this a lot for running my business, prompt advisers, well as my community,
making decisions, having my trusted council of folks in addition to my trusted council of human beings. So hopefully, this video not only entertained you, but gave you a brand new skill that you can put in your back pocket to help you be that much better of a decision maker. So if you want access to the prompts I sent, the markdown files for my devil's advocate agent, the optimist, and the neutral one, and the diagrams I showed you at the beginning just to break down the concept later on, I'll make them available to you in the second link in the description below. But after speaking to your AI council, if you decide that you wanna step things up and be in a community where we're doing much deeper dives on Cloud Code, delivering full systems, and giving you access to not just myself and my team, but coaches certified in cybersecurity,
vibe coding, and software engineering, then maybe check out the first link in the description below, and I'll see you in my early adopters community. And for the rest of you, if you could leave me a like and a comment on the video, I would be infinitely grateful as it keeps this channel growing and keeps you more incentivized to do more weird stuff like this. I'll see you in the next one.