So a key part of working with agents is crafting good
prompts, and a key part of that is adding the right context.
For example, let's say I wanna enhance my dummy CLI
application here with another feature that also allows me to
generate dummy products, not just users.
So we could open up a new chat session in agent mode and
say, "I want
to enhance my CLI tool
to also generate dummy products
depending on the flags
with which it was executed." I then also provide some
details on how my dummy product should look like, because again, being
specific is a good idea. You can use plan mode, as you saw
before, and it will ask for follow-up questions,
have to hope that it asks for the things you
want it to ask. If you already know, for example, the shape of a dummy
product, in this case, tell it. You don't need to hope for the AI
to guess it or to ask for it. Still, of course,
plan mode, but you wanna be as specific as
possible. And as mentioned, you wanna add the right context and
maybe point at some examples. Here I know that I already have a CLI
tool that generates dummy users. Now, as mentioned, in a
simple project like this, the chances of the AI detecting that
other file are almost at 100%, but still, I
know that there is this main.py file which has that other CLI
program, so why wouldn't I explicitly point the AI
it? Now here actually, it already added main.py as
context to this prompt. You can see the context here,
because that's the editor I now have open, and the open
editor window will always be added as context.
If you select some text here, for example, the selected code will
be the context that's added. If you don't have a selection,
file. But let's say this was closed.
In that case, as you can see, there's no context here, and you can add
context with the add context button, and there's a lot of context you can
add. You can add files and folders, you could take a screenshot, you
can also paste images in here, and a lot of other
things. Alternatively, you can also
use the hash key and then bring up this menu to
open context from here whilst typing, and you can enter
filenames here too, like main.py.
So this will now point at that file and add it as a context here.
Now again, I wanna make sure that we also take the official
account, and therefore I'll go to it here, copy that URL, and you can
add that as context too. So we could say, "Also take a
look at the official docs," and
paste that link in there, and if we wanna improve our chances of it
really making that request to the docs, you can use the fetch
context tool here, and then add the link
here. This gives it an extra hint that it should fetch this
page and send a request to it and get the content.
And now if I hit enter, it'll therefore go ahead
this prompt and all the context I included in there, and that includes
a request to these docs hopefully.
Yeah, it asks me if I wanna allow it sending
do.
I also don't wanna review the results here, the results of that request.
It should just go ahead. Same for this request.
And now based on all that information it gathered
spits out that plan it wants to implement.
It also has some follow-up questions here, and I'll provide my
answers. Hit enter to get a refined
plan,
refine it again with another answer to another question, and then just
as before, I'll press start implementation,
this. And now it'll, just as before, go ahead
in agent mode now and edit my files or maybe create some new
files to implement this new feature.
So here it now edited this main.py file and it wants to run it with
the help command to see if that works, and I'll allow this command, and
it can indeed also execute terminal commands, as you see here.
But as always, it asks for permission first.
Now it wants to run the command to actually generate some products,
of course carefully take a look at these commands so that it doesn't do
anything you don't want it to do. But I'm fine with this command here.
I can see that this works, and you therefore see this agent is really
testing its own program. And of course, I could also in general
allow all these UV commands so that I'm not
constantly asked again and again and again for it here with
that specific command line tool, which I'm fine with when the
AI uses it. So it now tested it, it was able to
see that terminal output, that's another feature this agent mode
has, and with that, it wrote the code and on its own
validated that it works correctly.
Of course, you still should also review the code on
own, take a look at it, and see if it's in line with your expectations and
requirements before you then accept or deny it.
You can, of course, by the way, also ask for follow-up edits or
improvements. It's not just accept or decline.
You can also ask for improvements, but here I'm fine with it
it.