CoursesAI-powered Sanity developmentIntroduction to prompting

AI-powered Sanity development

Lesson
2

Introduction to prompting

Log in to watch a video walkthrough of this lesson
Log in
Video thumbnail
Get better results from AI tools by crafting effective prompts, setting realistic expectations, and using them for interactive brainstorming sessions.
Log in to mark your progress for each Lesson and Task

Much of working with AI tooling requires “prompting,“ and writing good prompts is referred to as "prompt engineering." Essentially, writing instructions into a text box that the AI will execute.

For the entire history of computing, programming relied on getting consistent outputs from consistent inputs. However, this is not true when working with AI tools and so knowing how to write good inputs to get predictably good outputs becomes critically important.

Many factors will define the results that you get. The model that you are working with (for example, Claude Sonnet by Anthropic, ChatGPT by OpenAI, etc), the context that it has, and above all the quality of your prompt.

Through a lot of hype and the need for attention, AI tools have been largely oversold in terms of the scale what they can do with short prompts and large code-bases.

If you have only seen a few tweets and demos, you may expect to be able to write a short description of what you need, watch the computer magically do the rest, and put your feet up.

This is not the case. Here's a few tips on writing better prompts.

You should never consider that any AI tool or model is a flawless oracle, an all-knowing entity that can understand your deepest thoughts and desires and make exactly what you want.

A bad prompt that's missing all your context looks like this, and because AI tools are hard-coded to always respond with something, you'll get something, but it's extremely unlikely to be what you want.

Create a blog

While incredibly capable, AI tools don't know what they don't know. They have gaps in their knowledge.

Technical gaps like not knowing about a new framework that was released yesterday.

Context gaps like not knowing what you don't tell it. Novice prompt engineers leave out details for which every AI model will do its best to fill the void.

Without contextual, specific prompting, AI tools will at best produce the most average (read: uninspiring) result or at worst make up something (also known as a “hallucination”) that doesn't actually work.

Don't let AI fill the gaps in your prompts with its own ideas.

One way to approach writing good prompts is to ask instead of tell. Depending on your level of expertise in writing software, you may not fully understand the best course of action, especially at the very beginning of a project.

A good prompt asks context-rich questions:

I run a local bakery and would like to start blogging. What's a suitable technology stack that you would choose to build this for me?

Therefore, you are more likely to get great results by asking the AI what should be done.

Describe the problem that you have and that you need its help to solve.

Describe who you are and what you are expecting.

Describe to the computer the human problems that you are being paid to solve.

In the early stages of a project, AI tools are most valuable as a sparring partner for your ideas or a brainstorming session.

Despite having access to almost all knowledge in human history, you should consider your AI tool to be no smarter than a fresh, out-of-the-box intern.

An intern that you have found asleep and has only been awoken at the moment that you have pressed “send” in the prompt text box.

An intern that will confidently lie at any moment.

An intern that you can simply put away and replace in a moment when you are unhappy with the results.

Okay maybe "intern" isn't a good simile. It's important to not consider your AI tools to be "human." This is kind of the best framing we have for now.

But you get the point—frame your expectations. For all that AI tools can do, they can quickly lead to user frustration if you come to them with mismatched expectations.

As it is in the physical world, so it is true in the digital. Keep it simple, stupid.

Keep your prompts short and with all required context.

Unless you are prepared to spend a lot of time pre-planning your project into the perfect prompt, don't expect one prompt and get the result you want. Break down your required outcome into bite-sized pieces—whether the outcome of each prompt is to write code or to keep ideating.

In short, when writing prompts

  • Early in a project, you should ask, not tell
  • Ideate and brainstorm with the AI; you don’t need to write code with every prompt
  • Level-set your expectations about how much AI can actually do
  • Make sure the AI has all the context you had to ask the question, to answer it

In the following lesson, we'll start writing some prompts inside of a code editing tool.

Mark lesson as complete
You have 1 uncompleted task in this lesson
0 of 1