The difference between frustrated developers and productive vibe engineers? Prompting.
Bad Prompting: "Make my game better" -> Vague responses, wasted time
Good Prompting: "Add difficulty selector (Easy/Medium/Hard buttons) that filters word list in Spelling Bee. Click updates currentDifficulty, refreshes word pool." -> Precise code, first-try solutions
For complex features (authentication, databases, multi-component systems), you'll need advanced strategies that break down complexity, maintain consistency, and guide AI through architectural decisions.
You'll master: avoiding anti-patterns, writing specific prompts, managing context, creating agent.md documentation, and orchestrating multi-step workflows.
By the end of this lesson, you will:
Anti-patterns waste time and produce poor results.
❌ "Make my game better" -> AI doesn't know what "better" means.
✅ Better: "Fix the scoring bug where users get negative points after using more than 3 hints. Here's calculateScore(): [paste code]. Expected: Score never goes below 0."
❌ "Debug" -> No error or context provided.
✅ Better: "Getting TypeError: Cannot read property 'toLowerCase' of undefined at checkAnswer (game.js:47) when clicking Submit. Here's checkAnswer(): [paste code]. Expected: Check if answer is correct."
❌ "Add authentication" -> AI assumes OAuth/database when you wanted simple localStorage.
✅ Better: "Add username/password auth using localStorage (no database). Login form with two inputs, persist session on refresh. Files: index.html, chat.js, style.css. Create new auth.js for login logic. This is a student project."
❌ "My code doesn't work. Fix it." -> AI can't see your code or symptoms.
✅ Better: "filterWords() not working-selecting 'Easy' still shows Medium/Hard words. [paste filterWords() and click handler]. Expected: Only easy words. Actual: All difficulties. No console errors."
❌ "Add hints, scoring, timer, difficulty, animations, sounds, profiles, sharing" -> Too much at once.
✅ Better: "Add hint system only (other features later). Requirements: 1) 'Get Hint' button reveals first letter, 2) 3 hints max, 3) Disable button after 3, 4) Track in gameState.hintsUsed. Current gameState: { score: 0, currentWord: {...}, hintsUsed: 0 }."
💡 Tip: If a new teammate wouldn't understand your prompt, neither will AI. AI needs: Specificity, Context, Examples, Constraints.
Three levels: What (goal), How (approach/UX), Where (integration/files).
Example: Adding a Score Display
❌ Vague: "Add scoring"
✅ Specific:
WHAT: Add score display to Spelling Bee game
HOW: Show at top, update real-time, format "Score: 15 points", bold purple text
WHERE: HTML in index.html header, update in checkAnswer() (game.js), style in style.css
Context: Current logic: +5 per correct answer (working)
❌ Overwhelming: "Create difficulty selector with filtering, UI, localStorage, points"
✅ Step-by-Step: (1) Create buttons HTML+CSS, (2) Add click handlers + active styling, (3) Create filterWordsByDifficulty() function
❌ "Create word list" -> Basic array
✅ "Create word list. Each: { word: 'algorithm', difficulty: 'hard', definition: '...' }. 5 per difficulty (15 total)" -> Perfect structure
❌ "Create score function" -> Inconsistent style
✅ "Create calculateScore() as ES6 arrow, params (correct, incorrect, hintsUsed), formula: correctx5 + incorrectx-2 + hintsUsedx-3, JSDoc included" -> Exact format
❌ "Match my style" -> AI guesses
✅ "Match this: startGame = () => { gameState.isPlaying = true; updateUI(); }. Use arrow functions, clear names, helper calls" -> Perfect match
❌ "Add auth" -> 300 lines of backend complexity
✅ "Add simple auth. CONSTRAINTS: NO backend/database (use localStorage), NO libraries, under 50 lines. Requirements: login form, persist session" -> Simple solution
Context is AI's "working memory": chat history, files, code snippets, errors, and documentation. Managing it well makes AI 10x more helpful.
The Context Window (AI's memory limit):
Exceeding it? AI "forgets" older conversation-context management matters!
Best Practices:
Uncaught TypeError at checkAnswer (game.js:47) (not "I'm getting a TypeError")<button>. Goal: Green." (not "Hey there! I hope you're having a great day...")💡 Tip: Context is like recipe ingredients-too little fails, too much confuses, just right produces perfect results.
agent.md is a secret weapon that makes AI feel like it already knows your project.
agent.md (or AGENT.md, .ai/agent.md) is a file you create at the root of your project that documents:
Why it matters:
When you reference agent.md in your prompts (@agent.md), AI reads it and understands your project context instantly-without you explaining everything each time.
One. Project Overview: Name, description, tech stack
2. File Structure: List files with brief descriptions
3. Coding Conventions: Function style, naming, formatting preferences
4. Data Structures: Key object shapes with example formats
5. Known Issues: Documented bugs and planned fixes
6. Setup Instructions: How to run, test, and reset
Example One: Adding a Feature
"@agent.md Add 'Clear History' button below chat input.
Follow project conventions."
AI knows: Arrow functions, const/let, green theme, under 30 lines, localStorage usage
Example 2: Debugging
"@agent.md Knowledge base search not finding responses.
Known issue #2 mentions case-sensitivity. Fix it."
AI knows: Knowledge base structure, keywords array format, exact fix needed
# Smart Farm Chatbot - Agent Instructions
## Project Description
Agricultural chatbot for beginner farmers. Answers questions about crops, watering, pests, and farming techniques.
## Tech Stack
- Vanilla JavaScript (ES6), HTML5, CSS3
- localStorage (no backend)
## File Structure
/smart-farm/
├── index.html (main page)
├── chat.js (chatbot logic)
├── knowledge.js (JSON knowledge base)
├── style.css (styling)
├── utils.js (helpers)
└── agent.md (this file)
## Code Style
- Arrow functions: `const functionName = () => {}`
- No semicolons, CamelCase variables, Template literals, Destructuring
## Data Structures
### chatHistory (localStorage)
[{ id: "1", sender: "user", text: "...", timestamp: 123456 }]
### knowledgeBase (knowledge.js)
[{ topic: "Watering", keywords: ["water"], response: "...", expertise: "beginner" }]
## Key Functions
- `sendMessage()`, `findResponse()`, `displayMessage()`, `saveToHistory()` (chat.js)
- `formatTimestamp()`, `clearHistory()` (utils.js)
## Known Issues
1. Search is case-sensitive (needs toLowerCase())
2. No input validation
3. Knowledge base has only 10 topics
## Important Context
- Student project (keep simple)
- No external APIs (offline-first)
- Focus on educational value
Without agent.md: "Add export chat history" -> AI suggests Node.js + database (wrong tech stack)
With agent.md: "@agent.md Add export chat history" -> AI generates frontend-only solution (arrow functions, localStorage, Blob download, follows conventions)
Update when: adding files/features, discovering patterns, fixing recurring issues, changing data structures, adding dependencies.
Keep it current! Outdated agent.md is worse than none.
💡 Tip: Start agent.md on Day 1. 10 minutes documenting structure/conventions. Update as you go. By Week 2, it's invaluable.
Complex features (authentication, databases, multi-component systems) require advanced strategies that break down complexity, maintain consistency, and guide AI through architectural decisions.
Break features into testable steps:
Example: "User Authentication"
❌ Single prompt: "Add user authentication" -> 300+ untested lines with style conflicts
✅ Decomposed:
| Step | Prompt | Focus |
|---|---|---|
| 1 | "Create auth.ts with User/AuthState interfaces. Empty functions: login(), signup(), logout()" | Structure without implementation |
| 2 | "Add localStorage helpers: saveUser(), loadUser(), clearUser(). No encryption (student project)" | Persistence layer only |
| 3 | "Implement login() with simple validation (non-empty check), generate ID, save via saveUser()" | Core logic, no over-engineering |
| 4 | "Create LoginForm.tsx matching [paste Button component style]. Email/password inputs + error display" | UI with consistent styling |
| 5 | "Add authSlice to Zustand: { user, isAuthenticated }, actions: setUser(), clearUser()" |
State integration |
| 6 | "Create ProtectedRoute wrapper (React Router v6), redirect to /login if unauthenticated" | Protected routing |
| 7 | "Add loading states, friendly errors, success toast to LoginForm" | Polish & UX |
Results: Testable at each step-if Step 5 breaks, you know exactly where vs. debugging 300+ lines.
Ask AI to "think step-by-step" for architectural decisions. Skip for simple code generation.
Example: Choosing State Management
"Help me choose Redux vs Zustand.
Think step-by-step:
1. Key differences?
2. My project: auth, shopping cart, product catalog, order history
3. Team: solo, 3 weeks to MVP
4. Experience: React hooks, never used Redux
Based on this, what's better for my situation?"
AI analyzes: Differences -> needs -> constraints -> recommends Zustand + React Query with reasoning (not generic "use Zustand" advice).
Template:
"[Decision question]
Think step-by-step:
1. [Requirements]
2. [Constraints]
3. [Tradeoffs]
Context: [3 specific details]
What do you recommend?"
Show 2-3 code examples instead of describing style.
Example: Matching Function Style
❌ Without: "Create email validation" -> AI might use function declarations
✅ With examples:
"Create validateEmail matching my style.
Examples from my codebase:
const hashPassword = (password: string): string => {
return btoa(password);
};
const formatDate = (timestamp: number): string => {
return new Date(timestamp).toLocaleDateString();
};
Pattern: Arrow functions, TypeScript types, verbNoun names
Now create validateEmail following this pattern."
AI generates: const validateEmail = (email: string): boolean => { ... } (perfect match!)
Template: Show 2-3 examples -> List patterns -> Request new code
Step 1 (Chain-of-Thought): "Think step-by-step: cart state, refresh handling, guest users. Context: Zustand, Firebase, guest checkout." -> AI recommends Zustand + localStorage for guests, Firebase sync for logged-in.
Step 2 (Decompose): 7 prompts: Cart types -> Zustand slice -> localStorage -> Firebase sync -> CartDrawer UI -> Add to Cart button -> Checkout flow.
Step 3 (Few-Shot): "Create cartSlice matching [paste authSlice/productSlice examples]" -> Consistent style.
Results: Architecturally sound, manageable scope, consistent, testable-70% faster than single prompts.
You mastered AI communication from basics to advanced multi-step orchestration:
Anti-Patterns (What NOT to Do):
Best Practices:
Context Management:
agent.md Documentation:
@agent.mdAdvanced Strategies:
In Activity 10, you'll practice these techniques on real scenarios-from basic debugging to advanced feature decomposition.
💡 Remember: Good prompting = right information at the right level of detail.
Prompting Mindset:
The 3 C's:
For Complex Features:
Practice makes perfect. Pay attention to which prompts get first-try results-and learn from them!