Video Lesson: Craft a focused prompt in Claude Code

Craft a focused prompt in Claude Code

Learn how to craft effective Claude Code prompts by breaking tasks down, defining key requirements, and leaving room for flexible implementation or future features.


Lesson Content

Let's build something, for example: a CRUD interface for a todo list in Laravel, with the ability to create, read, update, and delete tasks.

Here's our prompt:

Build a todos feature which allows end-users to create, read, update or delete tasks on a todo list.

But let's say that we also want todos to be assignable to categories. This is where your prompting techniques start coming into play.

Break complex asks into smaller pieces

When you're working with Claude Code, the temptation is to describe your entire vision upfront in a single prompt. And that's a really good way to work.

But sometimes it's better to break down a really complex ask into smaller pieces. With this technique, you'll want to start with the core functionality first, and then build outward from there.

Rather than asking Claude Code to build a full CRUD interface for todos with categories all at once, start with the basic todo functionality first. Adding something like categories isn't a dependency, so we don't even need to mention that (yet).

We should hint at future extensions though. Here's how I'd phrase it:

Build it to be extensible to allow other features, such as categories, to be added to tasks in the future.

Notice I kept this open-ended rather than locking it down to JUST categories. This ensures that whatever code is written, is written to be exensible.

Define what matters and answer questions

This prompt is still pretty vague. Before implementing, you'd normally need answers to questions like:

  • Should data persist in a database, or live temporarily in localStorage or the session?

  • What should the user interface look like?

  • How should the frontend and backend code be structured?

Some of these requirements may already be defined in your CLAUDE.md file, but these questions need answers based on your actual requirements.

A line that I like to add to prompts is:

Before you start, ask me clarifying questions you may have about this implementation.

This helps to flesh out any details that the AI may be confused about when it comes time to writing code.

If you're used to just writing code, this might feel like product owner territory. It kind of is, because when you are using Claude Code, you'll also be wearing both of these hats: programmer AND product owner.

Think through your ask: is it detailed enough? Do you have strong opinions on the implementation? Define whatever specifics matter to you.

Leave room for surprise

Here's the interesting part: sometimes you genuinely don't have opinions on certain details. Maybe you're prototyping, and the user interface design doesn't really matter just yet. Or maybe you're exploring what's possible before committing to the specifics.

This approach does have a significant upside. Claude Code may create something unexpected that gives your app a unique feel -- something you wouldn't have otherwise designed yourself. Without a design team, letting the LLM suggest alternate implementations can help to differentiate your app and build something that you wouldn't normally build yourself.

It might also suggest patterns or designs you haven't yet considered. This helps you see other options before locking down on an approach, which is particularly useful early on when you're still prototyping and figuring out what you need.

The key though is to be intentional about what you leave open. When you're exploring possibilities, let Claude Code surprise you.

But when the requirements matter, define them clearly and up-front. Once your prompt captures both the specifics and the flexibility you need, you're ready to execute the build.

Maggie

Hey, I'm Maggie! 👋

Ask me anything.

Want to chat with Maggie?

Log in for AI tutor access.

Comments

Join the discussion!

Notes

Keep track of what you learn!