In Claude code you can agents. Now what is an agent? You can think of it as a smart assistant. You can create an agent, give it a goal, then have it go at it working independently then return the results.
In this article I am
going to keep it very basic and simple and focus on just creating your first
agent.
See https://code.claude.com/docs/en/sub-agents#quickstart-create-your-first-subagent [1] for more detailed information
Making your first agent
Open up Claude code and run the command /agents
|
> /agents |
You will see this tabbed
menu with the tabs running and Library.
You can see I have no
agents running right now.
If I go to Library and go down you see I have an option to
create a new agent.
Click enter
Choose a location.
In this case I am going to choose my personal directory vs the project.
Now choose Generate with Claude
Now we start our conversation to describe what this agent should do
Here is an example of what you might normally do with an
agent.
|
A code
improvement agent that scans files and suggests improvements |
(taken from https://code.claude.com/docs/en/sub-agents#quickstart-create-your-first-subagent [1])
But we are not going to do normal we are going to do simple so you know how to set up and use the tool.
Let’s create a price checker. I am in the market for a Western Digital Pro 20TB hard drive (model number WD202KFGX).
My prompt
|
A price
checker agent that will check the current price for a Western Digital Red
20TB hard drive model number WD202KFGX |
It will start to generate the agent
Now you need to select tools…. Why?
Well normally Claude is very cautious.
When you ask it to do something it asks for your direct permissions to
do that action (in many cases)
For an agent we would like them to be autonomous (work on their own with
no… or very little interaction from us)
So, what can we do here?
We could select All Tools then it can use all the tools. This would make it very powerful but also, potentially, very dangerous. In my case I need it to be able to read from web sites… So what permissions should I give it.
Let’s select
Read-only tools
When I press enter I see it change to 20 of 23 tools
selected.
Now go up and select Continue
Select the model. I
will select Opus
Choose a color. I
will choose Red
Now for memory. I am
going to select User Scope.
But why? And what is
this?
Well basically… The first time this agent kicks off ever it will have to keep
track of a few things as it tries to accomplish its goal. Once the goal is accomplished, if you have no
persistent memory then the next time you run the agent it will be like running
it totally fresh without any memory of the last run or runs.
However if we allow it to save a memory it will have that
next time it runs (it can add/tweak it on every run as well)
So for now lets set it to User Scope
There are our results.
Press Enter to Save
Now we can see that this agent exists.
And if I look in my file system
|
> ls ~/.claude/agents |
There is an agent Mark Down file there.
Also if I look here
|
> ls ~/.claude/agent-memory/ |
I can see there is a memory folder for this agent but there
is nothing there yet.
Running the Agent
Now that the agent exists how can I run it?
Use the @ followed by the agent name (You can use tab
completion)
Or you can scroll down through all the options
|
> @wd-red |
(then press tab)
Now run it.
It came back and asked for permissions.
And another ask, and another, and another. I think I have some tweaks to make.
OK I got a result.. (A bit off... but a result)
But I had to interact with it let me see if I can fix this.
|
> For the agent @/home/patman/.claude/agents/wd-red-20tb-price-checker.md I need to make some permission adjustments. When I last ran it I had to give it
permission to access web sites and also to adjust its own memory. Please adjust the agent so it has the permissions to do
this and does not need to ask for it next time. |
You can see it update the settings.json file.
Let me do one more tweak.
|
> Update the
@/home/patman/.claude/agents/wd-red-20tb-price-checker.md agent so that when
it finds the best price it opens the URL using the open command line command |
Now let’s try it again
|
> @wd-red |
(then press tab)
OK.. failure
A few more back and forth conversations to get it working….
OK it worked without any intervention on its own. It still needs some tweaks but it works.
So why use an agent vs just using a Skill? They both have Mark Down files
(instructions). So why have agents?
1.
Context -
Agents have their own context so
they can focus on their mission
2.
Memory -
Agents can keep their own memory
between sessions
3.
Parallel -
Agents run in parallel. So you can continue your session while they
run in the background (They could be running for hours to solve a problem)
I have not gotten into having multiple agents running or
even agents coordinating (this can be very powerful).
But for now I just wanted a simple write up on getting
something working.
References
[1] Quickstart:
create your first subagent
https://code.claude.com/docs/en/sub-agents#quickstart-create-your-first-subagent
Accessed 06/2026
No comments:
Post a Comment