**Then (2023–24)**
- "Think step by step" unlocked reasoning
- Best for complex logic, math, multi-step tasks
- You hand-wrote the steps:
```text
1. Inputs and outputs?
2. Edge cases?
3. Algorithm approach?
4. Now write the code.
```
**Now (current models)**
- The model **reasons on its own** (adaptive thinking)
- "Think thoroughly" often beats a hand-written plan
- Write explicit steps when you need a **specific process** or want to **inspect intermediate outputs**
## Role Prompting
**Give the AI a persona:**
```text
You are a senior software
engineer at a FAANG company
doing a code review. Be
critical and thorough.
Review this function for:
- Performance issues
- Security vulnerabilities
- Code style problems
```
**Effective roles:**
- Senior engineer (quality focus)
- Security expert (vulnerability focus)
- Technical writer (documentation focus)
> A role in the **system prompt** focuses behavior and tone — "even a single sentence makes a difference." Does it improve *correctness* for your task? Test it (HW1 myth test).
## Structured Output
**Request specific formats:**
```text
Return your analysis as JSON:
{
"summary": "one sentence",
"issues": ["list", "of", "issues"],
"severity": "low|medium|high",
"fix": "suggested code"
}
```
| Format | Best For |
| --- | --- |
| JSON | Parsing, APIs, structured data |
| YAML | Config files, readable without closing tags |
| XML | Nested data; XML **tags** also structure your *prompts* |
| Markdown | Documentation, readable output |
## Combining Patterns
**Real-world prompt using multiple patterns:**
```text
[Role] You are a TypeScript expert focused on clean code.
[Process] First, analyze what this function does.
Then identify any bugs or improvements.
Finally, provide the fixed version.
[Few-shot example]
Input: function add(a,b){return a+b}
Analysis: Missing types, no validation
Fixed: function add(a: number, b: number): number {...}
[Your task]
Input: function fetchUser(id){...}
[Format] Return as JSON with fields: analysis, issues, fixed_code
```
## Measure, Don't Guess
1. **Write the checklist first** — 4–6 pass/fail items, before you see any output
2. **Run each prompt 3×** in fresh chats — outputs vary run to run
3. **Score each item** — see *which* failures a change fixed
4. **Small gaps are noise** — under 1 item across 3 runs = no clear difference
> This is HW1 — and, at scale, how evals work (Weeks 10 & 13).
---
## Artifacts in Claude Web
> "Interactive apps that emerge from your conversations with Claude."
## What Are Artifacts?
**Artifacts are live, interactive outputs:**
- Web apps and prototypes
- Data visualizations
- Interactive tools and calculators
- Games and simulations
- Documents and diagrams
**No coding required** — describe what you want, Claude builds it.
## Artifact Use Cases
- **Prototypes** — Landing pages, signup flows
- **Tools** — Calculators, converters, trackers
- **Visualizations** — Charts, diagrams, dashboards
- **Educational** — Interactive tutorials, quizzes
- **Business** — Inventory systems, project boards
**Perfect for:** Validating ideas before writing "real" code.
## Creating Artifacts
**The workflow:**
```text
1. Describe your problem/idea
↓
2. Let Claude ask clarifying questions
↓
3. Request: "Can you create this for me?"
↓
4. Artifact appears in sidebar
↓
5. Iterate through conversation
```
**Trigger phrases:** "Create an app that...", "Build me a...", "Make an interactive..."
## Iterating on Artifacts
**Refinement through conversation:**
- "Make the button bigger"
- "Add a dark mode toggle"
- "The calculation is wrong when X happens"
**Debugging tip:** Describe what's wrong, not the technical error.
```text
Bad: "I get TypeError: undefined is not a function"
Good: "When I click submit with empty fields, nothing happens"
```
## Sharing Artifacts
**Once created, you can:**
- **View** — Anyone with link can see it
- **Remix** — Claude users can copy and modify
**Great for:**
- Showing prototypes to stakeholders
- Sharing tools with teammates
- Getting feedback before building "for real"
> "Build the demo in 5 minutes, not 5 days."
---
## Hands-On Lab
Time to practice!
## Exercise 1: Email Validator
**Challenge:** Write a prompt that generates an email validation function.
**Requirements:**
- TypeScript
- Handle edge cases (plus addressing, subdomains)
- Return `{ valid: boolean, reason?: string }`
- Include test cases
**Time:** 10 minutes
**Share:** Best prompts get discussed!
## Exercise 2: Iterate & Improve
**Take your v1 prompt and improve it:**
1. Run your prompt
2. Find issues in the output
3. Add constraints to fix them
4. Run again
5. Repeat until satisfied
**Document:**
- What issues did you find?
- What prompt changes fixed them?
- How many iterations did it take?
## Discussion: What Worked?
**Share your findings:**
- What made prompts better?
- What patterns did you use?
- What surprised you?
- What's still hard?
---
## What to Remember
1. **Good prompts:** Context + Task + Format + Constraints + Examples
2. **Patterns:** Few-shot, chain-of-thought, role prompting, structured output
3. **Iterate:** Expect 2-5 rounds for complex prompts
4. **Verify:** AI output needs human validation
5. **Measure:** Tips vary by model — test them against a checklist
---
## Looking Ahead
**Next class: User Research & Prototyping**
- Mom Test & Design Thinking workshop
- Claude Web Artifacts for rapid prototyping
- User story writing & PRD refinement
**HW1 due Mon Oct 5:** Prompt Pairs, Proven
---
## Resources
**Claude Web & Artifacts:**
- [Claude Artifacts Guide](https://support.claude.com/en/articles/11649427-use-artifacts-to-visualize-and-create-ai-apps-without-ever-writing-a-line-of-code)
**Prompt Engineering:**
- [Prompt Engineering Overview](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview)
- [Prompting Best Practices (current models)](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices)
- [Prompting Claude Opus 5.5](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-opus-5-5)
- [Anthropic Prompt Engineering Tutorial](https://github.com/anthropics/courses/tree/master/prompt_engineering_interactive_tutorial)
---
# Questions?