๐ŸŽฏ Prompting Fundamentals

๐Ÿ“
Basic Structure
[ROLE] Kamu adalah senior web developer [TASK] Buatkan [komponen/fitur] [CONTEXT] Untuk [jenis website/app] [REQUIREMENTS] - [fitur 1] - [fitur 2] [CONSTRAINTS] - [batasan 1] - [batasan 2] [FORMAT] Output dalam format [format]
Selalu gunakan struktur ini untuk hasil terbaik
๐ŸŽฏ
Specific vs General
โŒ "buatkan navbar" โœ… "buatkan navbar responsive dengan: - Logo di kiri - Menu items: Home, About, Products, Contact - Mobile hamburger menu - Dropdown untuk Products - Warna primary: #3b82f6 - Gunakan Flexbox"
Semakin spesifik, semakin baik hasilnya
๐Ÿ”„
Iterative Prompting
Prompt 1: "Buatkan card component" Prompt 2: "Tambahkan hover effects" Prompt 3: "Buat responsive untuk mobile" Prompt 4: "Tambahkan dark mode support"
Bangun secara bertahap, jangan semua sekaligus
๐Ÿ’ก Pro Tip: Selalu spesifik dengan requirements dan constraints. AI bekerja lebih baik dengan batasan yang jelas.

๐ŸŽจ HTML5 & CSS3

๐Ÿ—๏ธ
Semantic HTML
"Buatkan struktur HTML5 semantic untuk blog post dengan: SECTIONS: 1. Header dengan navigation 2. Main article dengan: - Title (h1) - Meta info (author, date) - Featured image - Article content (multiple paragraphs) - Tags section 3. Sidebar dengan: - Author bio - Related posts 4. Footer dengan copyright REQUIREMENTS: - Gunakan semantic tags (header, nav, main, article, aside, footer) - Accessible (ARIA labels dimana perlu) - SEO friendly - Valid HTML5"
HTML5
CSS3
๐Ÿ“ฑ
Responsive Design
"Buatkan CSS untuk responsive layout dengan: BREAKPOINTS: - Mobile: < 768px (1 column) - Tablet: 768px - 1024px (2 columns) - Desktop: > 1024px (3 columns) REQUIREMENTS: - Mobile-first approach - Fluid typography - Flexible images - CSS Grid untuk layout - Flexbox untuk components"
CSS3
๐ŸŽจ
CSS Grid Layout
"Buatkan CSS Grid layout untuk dashboard: LAYOUT: - Header (full width) - Sidebar (fixed 250px) - Main content (fluid) - Widget area (right sidebar) - Footer (full width) REQUIREMENTS: - 12-column grid system - Gap: 1.5rem - Responsive: sidebar collapse di mobile - Min-height: 100vh - Use CSS variables untuk spacing"
CSS3

CSS Framework Prompts

Tailwind CSS

"Buatkan component dengan Tailwind CSS: - bg-blue-600 hover:bg-blue-700 - px-4 py-2 rounded-lg - flex items-center gap-2 - Responsive: md:flex-row flex-col - Dark mode: dark:bg-gray-800"

Bootstrap

"Buatkan Bootstrap 5 component: - container-fluid untuk full width - row dengan g-4 gutter - col-md-6 col-lg-4 untuk responsive - btn btn-primary dengan icon - card component dengan shadow"

โšก JavaScript

๐Ÿงฉ
DOM Manipulation
"Buat fungsi untuk dynamic content loading: FUNCTIONS: 1. loadData(apiUrl) - Fetch data dari API 2. renderList(items) - Render array ke DOM 3. addEventListener untuk interactive elements 4. debounce function untuk search input REQUIREMENTS: - Gunakan async/await - Error handling dengan try/catch - Loading states - No jQuery, vanilla JS only"
JavaScript
๐Ÿ“
Form Validation
"Buat form validation real-time: FIELDS: - Email (format validation) - Password (strength: 8+ chars, uppercase, number) - Confirm Password (match validation) - Phone (format validation) FEATURES: - Real-time validation on input - Show/hide error messages - Submit button enable/disable - Debounce validation (300ms)"
JavaScript
๐Ÿ”„
Event Handling
"Implement event handling patterns: PATTERNS: 1. Event delegation untuk dynamic elements 2. Debounce untuk search input 3. Throttle untuk scroll events 4. Custom events untuk component communication EXAMPLE: - parent.addEventListener('click', (e) => { if(e.target.matches('.delete-btn')) { // handle delete } });"
JavaScript

Modern JavaScript Features

// ES6+ Features to request: const promiseExample = async () => { try { const response = await fetch('/api/data'); const data = await response.json(); return data.map(item => ({ ...item, processed: true })); } catch (error) { console.error('Error:', error); } };

โš›๏ธ React & Frameworks

โš›๏ธ
React Components
"Buatkan React functional component dengan: PROPS: - title (string, required) - items (array of objects) - onSelect (function) - isLoading (boolean) FEATURES: - useState untuk local state - useEffect untuk data fetching - Custom hooks jika perlu - PropTypes untuk type checking - Memoization dengan React.memo STYLING: - CSS Modules atau styled-components - Responsive design - Dark mode support"
React
๐Ÿ”„
State Management
"Implement state management untuk todo app: STATE STRUCTURE: { todos: [], filter: 'all', loading: false, error: null } ACTIONS: - ADD_TODO - TOGGLE_TODO - DELETE_TODO - SET_FILTER USING: - React Context API - useReducer untuk complex state - LocalStorage persistence - Optimistic updates"
React
๐Ÿ”Œ
Custom Hooks
"Buat custom hook useFetch: FEATURES: - Data fetching dengan fetch API - Loading, error, data states - Refetch functionality - Cache dengan useRef - Dependency array untuk re-fetch IMPLEMENTATION: function useFetch(url, options) { const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); // implementation... }"
React

๐ŸŸข Node.js & Backend

๐Ÿš€
Express.js API
"Buat REST API dengan Express.js: ENDPOINTS: - GET /api/users - GET /api/users/:id - POST /api/users - PUT /api/users/:id - DELETE /api/users/:id FEATURES: - Middleware untuk auth, logging, cors - Error handling middleware - Request validation dengan Joi - Database integration (MongoDB/PostgreSQL) - Environment variables dengan dotenv"
Node.js
๐Ÿ”
Authentication
"Implement JWT authentication: FEATURES: - User registration (/auth/register) - User login (/auth/login) - Protected routes middleware - Token refresh mechanism - Password hashing dengan bcrypt - Input validation MIDDLEWARE: function authenticateToken(req, res, next) { const token = req.header('Authorization'); // verify token... }"
Node.js
๐Ÿ—„๏ธ
Database Operations
"Buat CRUD operations dengan MongoDB: MODEL: User { name: String, email: String (unique), password: String (hashed), createdAt: Date } OPERATIONS: - createUser(userData) - findUserById(id) - findUserByEmail(email) - updateUser(id, updates) - deleteUser(id) USING: - Mongoose ODM - Async/await - Error handling - Data validation"
Node.js

๐ŸŒ API Integration

๐Ÿ“ก
Fetch API Patterns
"Buat service class untuk API calls: FEATURES: - Base URL configuration - GET, POST, PUT, DELETE methods - Request/response interceptors - Error handling - Retry logic dengan exponential backoff - Timeout handling (10 seconds) IMPLEMENTATION: class ApiService { constructor(baseURL) { this.baseURL = baseURL; } async get(endpoint) { // implementation... } }"
API
๐Ÿ›ก๏ธ
Error Handling
"Handle API errors secara komprehensif: ERROR TYPES: 1. Network errors (offline, CORS) 2. HTTP errors (400, 401, 403, 404, 500) 3. Timeout errors 4. JSON parsing errors HANDLING: - User-friendly error messages - Retry mechanism (max 3 attempts) - Fallback data jika available - Logging untuk debugging - Toast notifications"
API
๐Ÿ’พ
Caching Strategies
"Implement caching untuk API responses: STRATEGIES: 1. Memory cache (Map/WeakMap) 2. LocalStorage untuk offline data 3. Cache with expiry (TTL) 4. Stale-while-revalidate pattern IMPLEMENTATION: - Cache key generation - Cache invalidation - Background refresh - Cache size limits"
API

๐Ÿ› Debugging Prompts

๐Ÿ”
Error Diagnosis
[DEBUG REQUEST] Error: "TypeError: Cannot read properties of undefined" Code: function getUserData(users) { return users.map(user => user.profile.name); } Context: Data dari API response Task: Identifikasi dan perbaiki error Steps: 1. Check users array structure 2. Check if user.profile exists 3. Add null checks 4. Test dengan berbagai data scenarios"
Berikan error message dan code context
โšก
Performance Issues
[PERFORMANCE DEBUG] Issue: "App lag saat scroll, banyak re-renders" Code: Large React component dengan banyak state Analysis request: 1. Identify unnecessary re-renders 2. Suggest optimization techniques 3. Implement memoization 4. Code splitting suggestions 5. Bundle size optimization"
Jelaskan symptoms dan berikan code untuk analysis
๐Ÿงช
Testing Prompts
"Buat unit tests untuk fungsi berikut: FUNCTION: function calculateTotal(items) { return items.reduce((sum, item) => { return sum + (item.price * item.quantity); }, 0); } TEST CASES: 1. Empty array returns 0 2. Single item calculation 3. Multiple items calculation 4. Decimal prices handling 5. Invalid input handling USING: Jest testing framework"
Minta AI buat tests untuk kode kamu

โšก Performance Optimization

Issue Bad Prompt Good Prompt
Image Optimization "optimize images" "Convert images to WebP format with 80% quality, add srcset for responsive (400w, 800w, 1200w), implement lazy loading dengan Intersection Observer"
Bundle Size "reduce bundle size" "Implement code splitting dengan React.lazy() untuk routes, analyze bundle dengan webpack-bundle-analyzer, remove unused imports, add tree shaking"
Rendering "make it faster" "Optimize React rendering dengan useMemo untuk expensive calculations, useCallback untuk event handlers, implement virtual scrolling untuk long lists"
๐Ÿ’ก Performance Prompt Template: "Optimize [aspect] untuk mencapai [target metric]. Current issues: [describe issues]. Requirements: [specific optimizations needed]."

๐Ÿš€ Deployment & DevOps

๐Ÿณ
Docker Configuration
"Buat Dockerfile untuk Node.js + React app: REQUIREMENTS: - Multi-stage build - Production optimization - Nginx untuk static files - Health checks - Environment variables - Security best practices OUTPUT: - Dockerfile - docker-compose.yml - .dockerignore - Deployment instructions"
โš™๏ธ
CI/CD Pipeline
"Buat GitHub Actions workflow: STAGES: 1. Lint & Type check 2. Unit tests 3. Build optimization 4. Docker build & push 5. Deploy to staging 6. E2E tests 7. Deploy to production FEATURES: - Cache dependencies - Parallel jobs - Environment secrets - Manual approval untuk production"
๐Ÿ“ฆ
Environment Setup
"Buat environment configuration: FILES: - .env.example (template) - .env.development - .env.staging - .env.production - env-validation.js VARIABLES: - NODE_ENV - DATABASE_URL - API_KEYS (encrypted) - FEATURE_FLAGS - MONITORING_KEYS"

๐Ÿ“‹ Prompt Templates Library

Code Generation

[ROLE] Senior [technology] developer [TASK] Create [component/feature] for [purpose] [REQUIREMENTS] - Feature 1: [description] - Feature 2: [description] [CONSTRAINTS] - Use [specific technology] - Follow [coding standards] - No [restrictions] [FORMAT] [language] with comments

Code Review

[CODE REVIEW REQUEST] Language: [JavaScript/TypeScript/etc] Purpose: [functionality description] Code: [paste code] Review focus: 1. Code quality & best practices 2. Performance optimizations 3. Security vulnerabilities 4. Bug identification 5. Alternative approaches

Learning & Explanation

[LEARNING REQUEST] Topic: [technology/concept] My level: [beginner/intermediate/advanced] Format: [step-by-step/analogy/comparison] Include: 1. Core concepts 2. Practical examples 3. Common pitfalls 4. Best practices 5. Resources for further learning

Debugging

[DEBUGGING REQUEST] Error: [error message] Code context: [relevant code] Expected behavior: [what should happen] Actual behavior: [what's happening] Debug steps taken: [what you've tried] Environment: [browser/Node version/etc]
โš ๏ธ Common Mistakes:
  • โŒ Terlalu umum/vague
  • โŒ Tidak ada context/constraints
  • โŒ Permintaan terlalu banyak sekaligus
  • โŒ Tidak spesifik dengan format output
  • โŒ Lupa mention teknologi yang digunakan