Prompt Patterns & Interaction
After this lesson, you will be able to:
- Write specific, detailed prompts that get the right result on the first try
- Structure a CLAUDE.md file that teaches Claude Code your project's rules and patterns
- Use plan mode when you need Claude Code to think before it acts on big tasks
- Break large tasks into smaller, clear subtasks that Claude Code can handle reliably
Before you start
#The Anatomy of a Great Prompt
This lesson is possibly the highest-ROI lesson in the entire track. The difference between a vague prompt and a great prompt is the difference between 5 minutes of iteration and getting it right the first time. The patterns here will make every future Claude Code interaction faster.
Which prompt will produce better results from Claude Code?
Try it! Take a task you recently did manually in your code. Write two versions of the prompt: a vague one ("fix the bug") and a specific one (with the file name, the error, the expected behavior). Run the specific one in Claude Code and notice how it nails the task on the first try. Save the specific prompt as a template for next time.
#Bad vs Good Prompts
Tests: Verify that each good prompt contains WHAT, WHERE, HOW, and VERIFY components.
#The Four Components of Effective Prompts
#1. WHAT: State the Task Clearly
Be specific about what you want. "Fix the bug" is not a task description, it is a hope. "The signup form allows passwords shorter than 8 characters, which violates the requirement in auth-spec.md" is a task description.
#2. WHERE: Point to the Right Files
src/auth/validate.ts" prevents Claude Code from looking in the wrong places.#3. HOW: Set Constraints and Patterns
Tell Claude Code what patterns to follow, what to avoid, and what conventions to respect. "Follow the existing error handling pattern in the other controllers" or "Use the cn() utility for conditional classes, not template literals."
#4. VERIFY: Specify How to Check the Work
npm run test after the change" or "Make sure the build passes" tells Claude Code to verify its own work, catching errors before you review.#Providing Context in CLAUDE.md
#What to Include in CLAUDE.md
- Tech stack with versions, not just "React" but "React 19 with Server Components"
- File naming conventions: "kebab-case for files, PascalCase for components"
- Commands: exact commands for build, test, lint, deploy
- Architecture patterns: "all API routes go in src/app/api/"
- Anti-patterns: "NEVER use any type, NEVER use CSS modules"
- Common mistakes to avoid: "This project uses Tailwind v4 with CSS-based config, NOT tailwind.config.ts"
#What NOT to Include
- Implementation details that change frequently (Claude Code can read the code)
- Long explanations of business logic (keep it concise)
- Duplicate information that is already in README.md or package.json
#Using Plan Mode for Complex Tasks
claude --permission-mode plan), or simply ask for a plan in your prompt (key bindings can change, so check /help):> Plan how you would add WebSocket support for real-time notifications.
> Don't write any code yet -- just outline the approach.
Claude Code will produce a plan listing:
- Which files need to change
- What new files need to be created
- The order of operations
- Potential risks or breaking changes
Review the plan, adjust if needed, then say "Execute the plan."
You want Claude Code to build a complete user authentication system with registration, login, password reset, and email verification. Should you give this as one prompt or break it down?
The best approach is plan mode first, then phased execution. A single prompt for the entire auth system risks context overflow and makes it hard to review changes. Four completely separate prompts loses the architectural coherence. Plan mode gives you the big picture, then you can execute in logical phases ("First, build the registration flow. Then, add login."), with each phase building on the previous one.
#Breaking Large Tasks into Subtasks
Complex features should be decomposed into subtasks that each produce a working, testable increment:
#Bad Decomposition (Too Large)
- "Build the entire e-commerce checkout flow"
#Good Decomposition (Incremental)
- "Create the CartItem type and CartStore with Zustand"
- "Build the CartPage component showing items, quantities, and totals"
- "Add the CheckoutForm with shipping and payment fields using react-hook-form"
- "Create the /api/checkout endpoint that processes the order"
- "Connect the frontend form to the API endpoint"
- "Add form validation and error handling"
- "Write tests for the CartStore and checkout API"
Each subtask is small enough for Claude Code to handle reliably, produces a testable result, and builds on the previous step.
#Key Takeaways
- Specific prompts get specific results: always include WHAT (the task), WHERE (the files), HOW (the constraints), and VERIFY (the check) in your prompts
- CLAUDE.md is your highest-ROI investment: a well-crafted project instruction file prevents the most common mistakes across every interaction with Claude Code
- Plan mode before complex tasks: see the full plan before any code is written, then execute in phased increments
- Break large tasks into small, testable subtasks, each subtask should produce a working increment that builds on the previous step
#Quick Check
What is the most important component of an effective Claude Code prompt?
Pick the prompt most likely to give a correct, ready-to-merge result on the first try.