Module 4: Building Your First AppLesson 2 of 6
0%
Lesson 2ยท5 min

Writing Good Prompts

Learn to communicate effectively with Claude

Writing Good Prompts

The quality of Claude's output depends on the quality of your input. Let's learn to write effective prompts.

The Anatomy of a Good Prompt

A great prompt includes:

  1. What you want to build
  2. How it should work (behavior)
  3. Constraints (tech choices, requirements)
  4. Context (who it's for, why it matters)

Examples

โŒ Bad Prompt

Terminal
> Make a website
โ–Œ

โœ… Good Prompt

Terminal
> Create a single-page landing website for "Byron Beans" coffee shop.
>
> Include:
> - Hero section with shop photo and tagline
> - Menu section with coffee prices in AUD
> - Location section with address: 123 Beach Road, Byron Bay NSW 2481
> - Contact form that validates email
>
> Tech: HTML, CSS (no frameworks), vanilla JavaScript
> Style: Modern, beach vibes, mobile-first
โ–Œ

Prompt Patterns

The Feature Request

Terminal
> Add [FEATURE] that [DOES WHAT] so that [WHY/FOR WHOM]
Example:
> Add a dark mode toggle that saves preference to localStorage so users can switch between themes
โ–Œ

The Bug Fix

Terminal
> The [COMPONENT] is [DOING WRONG THING] when [CONDITION]. It should [CORRECT BEHAVIOR].
Example:
> The price calculator is showing NaN when quantity is empty. It should default to 0 or show validation error.
โ–Œ

The Refactor

Terminal
> Refactor [FILE/COMPONENT] to [IMPROVEMENT] while maintaining [REQUIREMENTS]
Example:
> Refactor the fetchData function to use async/await instead of .then() while keeping the same error handling behavior
โ–Œ

Tip

Include the "why" when possible. Claude makes better decisions when it understands the purpose.

Being Specific

Vague vs Specific

VagueSpecific
"Make it look better""Add 16px padding, round corners to 8px, use the site's blue (#3B82F6) for the button"
"Add validation""Validate email format and show error message below the input if invalid"
"Make it faster""Add caching to the API calls with a 5-minute expiry"

Iterating on Results

Claude rarely gets it perfect first try. That's okay!

Terminal
> [Initial prompt - builds the feature]
> The button is too small on mobile. Make it full-width on screens under 640px.
> Also add a loading spinner while the form submits.
> Change the success message from green to our brand color.
โ–Œ

Aussie Note

Think of prompting like ordering at a coffee shop. "Coffee" gets you something. "Large flat white, extra hot, one sugar" gets you exactly what you want. โ˜•

Context Through Conversation

Claude remembers your conversation:

Terminal
> Build a coffee shop menu component
Claude: [Creates menu component]
> Use those same prices in the checkout flow
Claude: I'll use the prices from the menu component:
- Flat White: $4.50
- Long Black: $4.00
...
โ–Œ

Warning

Long conversations can lose context. Use /compact or start a new session for unrelated tasks.

Key Takeaways

  • Be specific about what you want
  • Include how it should work
  • Provide constraints and context
  • Iterate with follow-up prompts
  • Reference previous work in conversation