Skip to content
Semua Tulisan

7 Advanced AI Prompts untuk Development Production-Ready Code

3 Juni 202614 menit baca
#ai-prompting#prompt-engineering#full-stack#system-design#code-quality#performance-optimization#best-practices
7 Advanced AI Prompts untuk Development Production-Ready Code

Pendahuluan

Prompt generik menghasilkan code generik. Ketika Anda bekerja dengan Claude untuk development, kualitas output sangat bergantung pada kualitas prompt.

Sebagai developer yang telah membangun multiple production systems—dari platform AI EMR (Sembuh.AI), sistem manajemen apotek (Apotik App), hingga real-time maritime docking system (BAS)—saya telah mengembangkan 7 advanced prompts yang konsisten menghasilkan production-ready code.

Artikel ini membagikan prompt templates yang dapat Anda adaptasi untuk project Anda sendiri. Setiap prompt dirancang untuk mendorong Claude berpikir seperti senior engineer dalam konteks spesifik.


1. Complete Application from Scratch (Full-Stack Production Ready)

Kapan gunakan: Ketika Anda ingin develop aplikasi lengkap dari nol dengan architecture yang solid.

Prompt Template:

[CONTEXT - Sesuaikan dengan use case Anda]
- Tech Stack: [Next.js 15 + TypeScript + PostgreSQL + Prisma + TailwindCSS]
- Domain: [Healthcare / Finance / E-commerce / Logistics]
- Scale: [Single-tenant / Multi-tenant]
- User capacity: [10 users / 10K concurrent users]
- Key requirements: [Real-time updates / Offline support / Third-party integrations]
- Compliance: [GDPR / PDP (Indonesia) / HIPAA]

[TASK]
Kamu adalah senior full-stack engineer. Design dan develop complete, production-ready application.

Deliverables:
1. **System Architecture** - Diagram layered architecture (presentation → API → business logic → data)
2. **Database Schema** - Normalized schema dengan relationships dan constraints
3. **File Structure** - Production-grade folder organization dengan clear separation of concerns
4. **API Endpoints** - RESTful endpoints dengan request/response examples dan error handling
5. **UI Architecture** - Component breakdown, state management strategy (Redux, Zustand, Context API)
6. **Security** - Authentication, authorization, input validation, data sanitization
7. **Deployment** - Docker Dockerfile, docker-compose, environment configuration
8. **Code Implementation** - Minimal tapi scalable, production-ready

Jangan buang waktu. Code harus siap deploy.

Contoh Real Context (dari Clinic Management System):

- Tech Stack: Next.js 14 + TypeScript + PostgreSQL + Prisma + TailwindCSS
- Domain: Multi-tenant Clinic Management (patients, appointments, EMR, billing)
- Scale: Multi-tenant (support 50+ clinics)
- User capacity: 1000 concurrent users
- Key requirements: Real-time appointment status, offline EMR draft, BPJS integration
- Compliance: UU PDP, health data privacy

Output yang diharapkan:

  • Architecture diagram (ASCII atau Mermaid)
  • Complete folder structure
  • Database schema dengan 5-10 core tables
  • 10+ API endpoints (POST patient, GET appointments, etc)
  • React component architecture (3-5 core components)
  • Docker setup siap production
  • Minimal implementasi untuk happy path

2. Codebase Understanding & Refactoring

Kapan gunakan: Ketika Anda inherit codebase besar dan perlu understand serta improve tanpa breaking functionality.

Prompt Template:

[CONTEXT - Project Existing Anda]
- Codebase size: [5K LOC / 50K LOC / 100K+ LOC]
- Tech Stack: [Laravel 12 / Next.js / Django]
- Age: [Months / Years old]
- Pain points observed: [Slow page load / Complex state management / Duplicate validation]
- Team composition: [Solo developer / 5 engineers / Distributed team]
- Current issues reported: [Hard to test / Maintenance nightmare / New features take too long]

[TASK]
Kamu adalah senior engineer yang baru joined project ini. Analyze, understand, dan refactor.

Workflow:
1. **Architecture Understanding** 
   - Identify layers dan responsibilities
   - Map data flow dari request hingga response
   - Identify dependency patterns dan coupling issues

2. **Problem Discovery** - Find dan kategorisasi:
   - **Structural issues**: Tight coupling, god classes, missing abstractions
   - **Code duplication**: Repeated logic across modules (validation, auth, error handling)
   - **Performance bottlenecks**: N+1 queries, unnecessary renders, slow endpoints
   - **Maintainability risks**: Unclear naming, missing error handling, magic numbers, hard-to-test code

3. **Refactoring Strategy** 
   - Prioritize high-impact improvements (effort vs. benefit)
   - Suggest concrete refactoring patterns (extract method, extract class, strategy pattern)

4. **Implementation** 
   - Provide before/after code comparison
   - Maintain 100% backward compatibility
   - Include test cases untuk critical paths

Output: Architecture summary, problem areas breakdown, refactoring strategies, improved code samples

Contoh Real Context (dari Apotik App):

- Codebase: Pharmacy management app (Laravel 12 + PHP 8.3 + MySQL + Bootstrap 5)
- Size: 25K LOC across 15 controllers
- Pain points: 
  * Inventory checking endpoint (GET /api/inventory) slow (3-4 seconds) karena query 5 tables
  * Validation logic diulang di 8 controller methods
  * Stock opname module tightly coupled ke inventory module
- Issues: Hard to add new features, tests coverage <30%

3. Senior Debugging Engineer (Root Cause Analysis)

Kapan gunakan: Ketika ada bug critical di production yang perlu deep investigation.

Prompt Template:

[CONTEXT - Bug Report Detail]
- Environment: [Production / Staging / Local]
- Symptoms: [Error message / Unexpected behavior / Performance degradation]
- Frequency: [Always reproducible / Intermittent / Only under specific conditions]
- User impact: [Critical (system down) / High (core feature broken) / Medium / Low]
- Affected system: [Payment / Real-time sync / Authentication / Report generation]
- First occurrence: [Specific timestamp]

[ERROR LOGS & CODE]
[Paste error stack trace, relevant code snippets, database logs]

[TASK]
Kamu adalah senior debugging engineer. Investigate bug production ini step-by-step.

Methodology:
1. **Symptom Analysis** - Apa exactly yang user observe
2. **Code Flow Trace** - Step-by-step execution path dari request hingga error
3. **Data State Analysis** - Inspect data di setiap tahap (logs, database snapshots)
4. **Root Cause Identification** - **WHY** failure terjadi, bukan hanya **WHERE**
5. **Edge Case Discovery** - Kondisi specific yang trigger bug ini
6. **Solution Design** - Robust fix yang handle edge cases, bukan just band-aid
7. **Testing Strategy** - Cara verify fix dan prevent regresi

Output: Detailed problem explanation, root cause analysis, fixed code, test cases, deployment checklist

Contoh Real Context (dari SIMRS Integration):

[CONTEXT]
- Environment: Production SIMRS (Pusat Jantung Nasional)
- Bug: SATUSEHAT integration fails silently on 30% of ANA documentation submissions
- Frequency: Intermittent, happens untuk specific patient profiles
- User impact: Critical - nurses harus manually re-enter data
- Error logs: "FHIR mapping error - null reference exception in address field"

[CODE SNIPPET]
[Paste mapping logic, error handler, related database query]

4. System Design + Implementation (Architectural Thinking)

Kapan gunakan: Ketika Anda perlu design system besar yang scalable dan production-ready.

Prompt Template:

[CONTEXT - Business Requirements]
- Problem statement: [Apa yang kita solve?]
- Scale targets: [1K / 100K / 1M users]
- Performance SLAs: [Response time <200ms / 99.9% uptime / P99 latency <500ms]
- Data volume: [GB / TB / PB scale]
- Integration requirements: [Third-party APIs / Event streaming / Real-time sync / Legacy systems]
- Infrastructure constraints: [Budget / Cloud provider / On-premise / Hybrid]
- Compliance requirements: [GDPR / UU PDP / HIPAA / Financial regulations]

[TASK]
Design scalable system architecture end-to-end, kemudian implement minimal production version.

**Design Phase:**
1. **System Architecture** - Layered architecture dengan clear responsibilities
2. **Component Breakdown** - Microservices vs monolith tradeoffs, identify critical components
3. **Data Flow Design** - How data moves melalui system, identify hot paths
4. **API Contracts** - Define clear boundaries dan communication protocols
5. **Caching Strategy** - Redis caching, CDN strategy, client-side caching decisions
6. **Database Strategy** - Normalization vs denormalization, partitioning strategy
7. **Failure Handling** - Graceful degradation, retry logic, circuit breakers
8. **Monitoring & Observability** - Logging, metrics, tracing strategy

**Implementation Phase:**
1. Setup core infrastructure (database, cache, message queue)
2. Implement critical path (happy path first, MVP)
3. Add comprehensive error handling & logging
4. Define monitoring alerts & SLI/SLO

Output: Architecture diagrams, component design, implementation code, scaling strategy, deployment guide

Contoh Real Context (dari BAS - Berthing Assistance System):

- Problem: Real-time maritime vessel docking system untuk 50+ ships
- Scale: 50 ships, 100 sensors per ship, 1 update/second = 5K events/second
- Performance SLA: <100ms latency untuk real-time display, 99.95% uptime
- Data volume: 5M+ sensor data points/day, 10 years retention
- Integrations: MQTT sensor network, legacy port management system, mobile app
- Infrastructure: Cloud-based, high availability required

5. Performance Optimization Engineer

Kapan gunakan: Ketika aplikasi sudah berjalan tapi performance-nya perlu improvement.

Prompt Template:

[CONTEXT - Performance Baseline]
- Current metrics: [Page load: 3s / API response: 800ms / Memory: 500MB / CPU: 75%]
- Bottlenecks observed: [Slow endpoint X / High memory usage / Database queries slow]
- Tech stack: [Next.js / Laravel / React / PostgreSQL]
- Scale: [Current 1K users / Target 100K users]
- Profiling data available: [CPU flame graph / Memory snapshots / DB query logs / APM traces]

[PERFORMANCE DATA & CODE]
[Paste slow code, slow queries, memory profiles, APM screenshots]

[TASK]
Optimize untuk: speed ⚡, memory efficiency 🎯, scalability 📈

**Analysis Phase:**
1. **Bottleneck Discovery** - Identify dimana waktu dihabiskan:
   - **Code-level**: Inefficient algorithms, unnecessary computations, bad loops
   - **Database**: N+1 queries, missing indexes, full table scans, slow joins
   - **Frontend**: Excessive re-renders, large bundle size, unoptimized images
   - **Infrastructure**: Inefficient caching, poor load balancing, resource contention

2. **Root Cause Analysis** - Kenapa setiap bottleneck exists
3. **Impact Assessment** - Prioritize dengan effort vs. benefit ratio

**Implementation Phase:**
1. Database optimization (strategic indexing, query rewriting, connection pooling)
2. Backend caching strategy (Redis, query result caching, HTTP caching)
3. Frontend optimization (code splitting, lazy loading, virtual scrolling, image optimization)
4. Infrastructure optimization (CDN, edge caching, load balancing, autoscaling)

Output: Performance issues breakdown, optimization strategies, improved code, before/after metrics

Contoh Real Context (dari Clinic Patient Search):

- Current: Patient search endpoint = 2.5s load time (unacceptable)
- Issue: Full table scan pada patient_medical_records (200K records)
- Tech: Laravel 12 + PostgreSQL + Vue.js 3
- Target: <300ms search response time
- Current queries: 5 separate database calls untuk 1 search

6. Claude Multi-Agent Workflow (Collaborative Design)

Kapan gunakan: Untuk project kompleks yang butuh perspective multiple senioritas (architecture, engineering, quality, performance).

Prompt Template:

[CONTEXT - Complex Project Requirements]
- Scope: [New feature / System redesign / Complex integration / Critical infrastructure]
- Stakeholders: [Product / Engineering / DevOps / Security]
- Constraints: [Timeline (weeks) / Budget / Technical debt]
- Success criteria: [Measurable outcomes - latency, uptime, user satisfaction]
- Risks identified: [Technical risks / Integration risks / Scaling risks]

[TASK]
Deploy 4-agent collaborative workflow:

🏗️ **ARCHITECT** (System Design):
- Design comprehensive system architecture
- Define component boundaries dan communication patterns
- Plan data flow & integrations
- Document assumptions, tradeoffs, dan alternative approaches
→ Output: Architecture document, component diagrams, data flow diagrams

👨‍💻 **ENGINEER** (Implementation):
- Develop based on architect's design (strictly follow specs)
- Implement core functionality untuk happy path
- Write unit tests untuk critical logic
- Write documentation (code comments, README, API docs)
→ Output: Production-ready code, test suite, deployment guide

🔍 **REVIEWER** (Quality Control):
- Verify architecture alignment - apakah code follow architect's design?
- Code quality check - standards, patterns, security best practices
- Test coverage verification - sufficient tests untuk critical paths?
- Identify design flaws atau implementation issues
→ Output: Review report, feedback items, risk assessment

⚡ **OPTIMIZER** (Performance & Scalability):
- Identify bottlenecks dalam design & implementation
- Propose optimization strategies dengan metrics
- Review database efficiency, caching strategy, algorithm complexity
- Suggest scalability improvements
→ Output: Optimization report, improved code, performance projections

**Workflow:**
1. Architect designs dan presents ke reviewer (iterasi sampai aligned)
2. Engineer implements berdasarkan final architecture
3. Reviewer quality-gates code (feedback loop with engineer)
4. Optimizer reviews untuk performance (suggest improvements)
5. Final iteration hingga semua agents approve

Output: Final architecture, production-ready code, quality report, optimization analysis, deployment checklist

Contoh Real Context (dari Sembuh.AI):

- Scope: AI EMR documentation platform (Sembuh.AI)
- Stakeholders: Hospital (Pusat Jantung Nasional), clinical staff, IT department
- Timeline: 12 weeks ke pilot phase
- Success criteria: 80% of SOAP/ANA forms auto-filled, <3s response time, 99% accuracy
- Risks: Privacy compliance (UU PDP), integration dengan legacy SIMRS, clinical validation

7. Production-Level UI Component Builder

Kapan gunakan: Ketika Anda perlu build reusable, accessible, production-grade UI components.

Prompt Template:

[CONTEXT - Component Requirements]
- Component type: [Form input / Data table / Modal / Chart / Real-time feed / List with filtering]
- Use cases: [Desktop / Mobile / Both]
- Design system: [Existing component library / Brand guidelines / Accessibility requirements]
- Framework & version: [React 19 / Next.js 15 / Vue 3]
- Browser support: [Modern browsers / IE11]
- Accessibility level: [WCAG 2.1 Level AA / AAA]
- Performance constraints: [Virtual scrolling for 10K+ items? / Real-time updates?]

[TASK]
Build production-ready UI component dengan depth & polish.

**Component Design:**
1. **Props Interface**
   - Type-safe (TypeScript interfaces)
   - Flexible API (composition over props hell)
   - Well-documented dengan JSDoc
   - Support untuk common variants (size, color, state, etc)

2. **State Management**
   - Normal state (default)
   - Loading state (skeleton, spinner)
   - Error state (error message, retry button)
   - Empty state (no data message)
   - Disabled state (visual + interaction feedback)
   - Selected/active state

3. **Edge Cases**
   - Very long text (truncation, tooltip)
   - No data / empty state
   - Mobile/responsive viewports
   - Keyboard navigation
   - Screen reader compatibility
   - High-contrast mode support

4. **Accessibility (a11y)**
   - ARIA labels & roles
   - Keyboard navigation (Tab, Enter, Escape, Arrow keys)
   - Screen reader support
   - Focus management & visual focus indicators
   - Semantic HTML

5. **Performance**
   - Virtualization untuk list (jika 1000+ items)
   - React.memo untuk expensive computations
   - Lazy loading untuk images
   - Debouncing untuk search/filter inputs

6. **Responsive Design**
   - Mobile-first approach
   - Touch-friendly (min 44px tap target)
   - Flexible layouts (Flexbox, Grid)
   - Breakpoint strategy

**Implementation Requirements:**
1. Component structure (composition-focused)
2. Prop validation & TypeScript types
3. Error boundaries & fallback UI
4. Storybook stories untuk setiap state
5. Unit tests (Jest) & integration tests (React Testing Library)
6. Comprehensive documentation & usage examples

Output: Component code (production-ready), Props documentation, Storybook stories, Usage examples, Test suite

Contoh Real Context (dari EMR System):

- Component: PatientDataTable dengan inline edit & real-time sync
- Use cases: Desktop EMR system (doctors, nurses viewing patient medical records)
- Framework: Next.js 14 + TypeScript + TailwindCSS + shadcn/ui
- Accessibility: WCAG 2.1 Level AA
- Data scale: 10K+ patient records (need virtual scrolling)
- Features: Inline edit, sort, filter, multi-select, keyboard navigation, real-time sync dari multiple doctors

Pro Tips & Best Practices

1. Context adalah Segalanya Semakin detail context yang Anda berikan, semakin baik output Claude. Include:

  • Tech stack specifics (framework versions, databases, libraries)
  • Real constraints (scale, performance targets, compliance requirements)
  • Business context (why build ini? siapa user-nya?)
  • Existing systems yang perlu integrate

2. Role-Based Thinking Prompt Claude dengan role spesifik ("Think like senior full-stack engineer") memicu thinking pattern yang lebih sophisticated.

3. Iterasi & Feedback Prompts pertama jarang perfect. Berikan feedback:

  • "Ini approach bagus, tapi kurang consider untuk X"
  • "Refactor ini, prioritas readability dibanding performance"
  • "Add error handling untuk edge case Y"

4. Combine Prompts Gunakan multiple prompts dalam workflow:

  1. Design → System Design prompt → architecture
  2. Implement → Complete App prompt → initial code
  3. Improve → Refactoring prompt → code quality
  4. Optimize → Performance prompt → final optimization

5. Validate Output Jangan blind trust. Always:

  • Review code untuk security issues
  • Test di staging sebelum production
  • Verify architecture decisions dengan team

Kesimpulan

Sebagai developer yang membangun production systems di healthcare (Sembuh.AI, SIMRS integration), e-commerce (Apotik App), dan real-time systems (BAS), saya confirm bahwa prompt quality sangat impact output quality.

Prompts di atas bukan hanya "good prompts"—ini adalah thinking frameworks yang telah proven di production systems. Setiap prompt mengubah Claude dari generic chatbot menjadi specialized engineer dengan expertise spesifik.

Next steps:

  1. Adaptasi prompts ini untuk project Anda
  2. Add context real dari codebase/requirements Anda
  3. Iterasi berdasarkan output quality
  4. Build library custom prompts untuk team Anda

Production-ready code bukan accident—ini hasil dari clarity dalam thinking. Prompts ini adalah tools untuk clarify thinking Anda dan maximize AI assistance.

Happy coding!