Skip to main content

AI Prompt Templates

Template prompts untuk mempercepat development dengan AI assistance (ChatGPT, Claude, Copilot, WindSurf).

๐Ÿ“ Folder Structure Template

Prompt untuk Generate Folder Structure

Tugasmu: buatkan dokumentasi Mintlify untuk proyek "MStore Backend" dengan struktur, gaya, dan konten berikut.

Konteks teknis:
โ€ข Frontend: Flutter
โ€ข Backend: Go (HTTP API, clean architecture)
โ€ข Database: MySQL (OLTP), MongoDB (dokumen)
โ€ข Observability: LGTM (Loki, Grafana, Tempo, Mimir)
โ€ข DevOps stack ringan berbasis Go: Taskfile, Air (live reload), GoReleaser, Caddy, Cosign
โ€ข CI/CD: GitHub Actions

Tujuan dokumentasi:
1. Onboarding cepat (setup lokal โ‰ค15 menit)
2. Pedoman arsitektur dan styleguide API
3. Praktik terbaik schema & migrasi MySQL + pattern Mongo
4. Observability lengkap (logs, metrics, traces) via LGTM
5. Dev workflow Go-native (taskfile, live reload, release)
6. Panduan troubleshoot umum

Struktur & konten yang harus dibuat:
โ€ข /docs/00-getting-started/*: intro, prerequisites, local-setup, project-structure
โ€ข /docs/10-architecture/*: system-overview, request-flow, domain-model, deployment-topology
โ€ข /docs/20-backend-go/*: overview, service-template, api-styleguide, config-secrets, error-handling, testing
โ€ข /docs/30-frontend-flutter/*: overview, state-management, api-client, env-config, testing
โ€ข /docs/40-database/*: mysql-schema, mysql-migrations, mongo-schema, mongo-patterns, data-seeding, backup-restore
โ€ข /docs/50-observability-lgtm/*: lgtm-overview, loki-logs, grafana-dashboards, tempo-traces, mimir-metrics
โ€ข /docs/60-devops-go/*: dev-workflow, taskfile, air-live-reload, goreleaser, caddy-reverse-proxy, container-images, security-cosign
โ€ข /docs/70-ci-cd/*: github-actions, versioning-release, environments
โ€ข /docs/80-guides/*: feature-flags, caching, file-upload, auth-jwt, rate-limiting, troubleshooting
โ€ข /docs/90-features/*: transaction-flow, payment-gateway, inventory-flow, approval-flow
โ€ข /docs/95-technical-specs/*: api-spec-template, erd-template, business-logic-template
โ€ข /docs/99-changelog/changelog.mdx

Persyaratan penulisan:
โ€ข Setiap halaman punya frontmatter: title, description, icon
โ€ข Sertakan code blocks yang runnable
โ€ข Gunakan contoh endpoint: /api/v1/auth/login, /api/v1/users, /api/v1/orders
โ€ข Tambahkan diagram mermaid minimal pada: system-overview, request-flow, deployment-topology
โ€ข Tulis ringkas, to-the-point, dengan checklist praktis

Terakhir:
โ€ข Buat mint.json lengkap dengan navigation
โ€ข Pastikan semua tautan halaman valid
โ€ข Hasilkan konten MDX/MD final (bukan hanya outline)

๐Ÿ“Š Diagram Template

Prompt untuk Generate Mermaid Diagrams

Buatkan diagram Mermaid untuk dokumentasi MStore Backend:

1. System Flow Diagram
- Tunjukkan alur dari Client โ†’ API Gateway โ†’ Services โ†’ Database
- Include: Authentication, Authorization, Request/Response flow
- Format: flowchart TD

2. Sequence Diagram (Login)
- Tunjukkan interaksi: User โ†’ Flutter App โ†’ Go API โ†’ MySQL โ†’ JWT
- Include: Validation, Token generation, Response
- Format: sequenceDiagram

3. Deployment Topology
- Tunjukkan: Docker Compose setup untuk development
- Include: Services (API, MySQL, MongoDB, Redis, LGTM stack)
- Format: graph LR

4. Entity Relationship Diagram
- Tunjukkan relasi: users, transactions, products, inventory
- Include: Foreign keys, cardinality
- Format: erDiagram

Persyaratan:
โ€ข Gunakan syntax Mermaid yang valid
โ€ข Tambahkan comments untuk clarity
โ€ข Gunakan warna untuk grouping (subgraph)
โ€ข Include error paths (dashed lines)

๐ŸŽฏ Feature Documentation Template

Prompt untuk Document New Feature

Buatkan dokumentasi lengkap untuk fitur baru di MStore Backend:

Fitur: [NAMA_FITUR]
Deskripsi: [DESKRIPSI_SINGKAT]

Struktur dokumentasi yang dibutuhkan:

1. Overview
- Deskripsi fitur
- Use cases
- Benefits
- Prerequisites

2. Architecture
- System diagram (Mermaid)
- Components involved
- Data flow
- Integration points

3. API Endpoints
- List all endpoints
- Request/Response examples (cURL, JavaScript, Go)
- Error responses
- Rate limiting

4. Database Schema
- Tables involved
- Relationships (ERD)
- Indexes
- Migrations

5. Implementation Guide
- Backend implementation (Go)
- Frontend implementation (Flutter)
- Configuration
- Environment variables

6. Testing
- Unit test examples
- Integration test scenarios
- E2E test cases
- Performance benchmarks

7. Deployment
- Configuration changes
- Migration steps
- Rollback plan
- Monitoring

8. Troubleshooting
- Common issues
- Error messages
- Solutions
- FAQ

Format:
โ€ข MDX dengan frontmatter
โ€ข Code examples dengan syntax highlighting
โ€ข Mermaid diagrams untuk visualisasi
โ€ข Callout boxes untuk warnings/tips
โ€ข Cross-references ke dokumentasi lain

๐Ÿ”ง API Spec Template

Prompt untuk Generate API Specification

Buatkan spesifikasi API lengkap untuk endpoint baru:

Endpoint: [METHOD] [PATH]
Deskripsi: [DESKRIPSI]

Yang harus di-generate:

1. Endpoint Details
- HTTP Method
- Path dengan parameters
- Authentication required
- Rate limit
- Idempotency support

2. Request
- Headers (required & optional)
- Path parameters
- Query parameters
- Request body schema (JSON)
- Validation rules

3. Response
- Success response (200, 201, dll)
- Error responses (400, 401, 404, 500, dll)
- Response body schema (JSON)
- Pagination format (jika applicable)

4. Examples
- cURL example
- JavaScript (Fetch API) example
- Go example
- Flutter (Dio) example

5. Business Logic
- Validation rules
- Processing steps
- Side effects
- Database operations

6. Error Handling
- Error codes
- Error messages
- Retry logic
- Fallback behavior

7. Testing
- Unit test example
- Integration test example
- Test data
- Expected results

Format output:
โ€ข MDX format dengan frontmatter
โ€ข Code blocks dengan language tags
โ€ข Tables untuk parameters
โ€ข Mermaid sequence diagram untuk flow

๐Ÿ—„๏ธ Database Schema Template

Prompt untuk Document Database Schema

Buatkan dokumentasi database schema untuk tabel baru:

Tabel: [NAMA_TABEL]
Deskripsi: [DESKRIPSI]

Yang harus di-generate:

1. Table Structure
- Column definitions (name, type, constraints)
- Primary key
- Foreign keys
- Indexes
- Unique constraints
- Check constraints

2. Relationships
- Parent tables (FK references)
- Child tables (referenced by)
- Many-to-many relationships
- Cardinality

3. ERD Diagram
- Mermaid erDiagram
- Show relationships
- Include cardinality
- Highlight important fields

4. Sample Data
- INSERT statements
- Realistic examples
- Edge cases

5. Queries
- Common SELECT queries
- JOIN examples
- Aggregation queries
- Performance considerations

6. Migration
- Atlas HCL schema
- Migration SQL (up)
- Rollback SQL (down)
- Data migration (if needed)

7. Indexes Strategy
- Index definitions
- Composite indexes
- Covering indexes
- Performance impact

8. Best Practices
- Naming conventions
- Data types
- Normalization
- Denormalization (when needed)

Format:
โ€ข MDX dengan frontmatter
โ€ข SQL code blocks
โ€ข Mermaid ERD
โ€ข Tables untuk column definitions

๐Ÿงช Testing Template

Prompt untuk Generate Test Cases

Buatkan test cases lengkap untuk:

Feature: [NAMA_FEATURE]
Component: [HANDLER/SERVICE/REPOSITORY]

Yang harus di-generate:

1. Unit Tests
- Test function names
- Test scenarios (happy path, edge cases, errors)
- Mock dependencies
- Assertions
- Go code examples (using testify)

2. Integration Tests
- Test scenarios
- Setup & teardown
- Database fixtures
- API calls
- Expected results

3. E2E Tests
- User scenarios
- Step-by-step flow
- Test data
- Expected outcomes
- Screenshot points (for UI)

4. Performance Tests
- Load test scenarios
- Concurrent requests
- Response time targets
- Resource usage limits

5. Test Data
- Fixtures (JSON, SQL)
- Mock data generators
- Edge case data
- Invalid data for negative tests

Format:
โ€ข Go test code (table-driven tests)
โ€ข Comments untuk clarity
โ€ข Arrange-Act-Assert pattern
โ€ข Error assertions

๐Ÿ“ Code Generation Template

Prompt untuk Generate CRUD Operations

Generate CRUD operations untuk entity baru:

Entity: [NAMA_ENTITY]
Fields: [LIST_FIELDS]

Yang harus di-generate:

1. Model (Go struct)
- GORM tags
- JSON tags
- Validation tags
- Relationships
- Timestamps (gorm.Model)

2. Repository
- Create
- GetByID
- Find (with filters)
- Update
- Delete (soft delete)
- GORM implementations

3. Service
- Business logic
- Validation
- Error handling
- Transaction management
- Logging

4. Handler
- HTTP endpoints
- Request parsing
- Response formatting
- Error mapping
- OpenTelemetry tracing

5. Payload Structs
- CreateRequest
- UpdateRequest
- Response
- ListResponse (with pagination)

6. Routes
- Route registration
- Middleware
- Path parameters
- Query parameters

7. Tests
- Repository tests
- Service tests
- Handler tests
- Test fixtures

Persyaratan:
โ€ข Follow clean architecture
โ€ข Idiomatic Go code
โ€ข Error handling best practices
โ€ข Logging dengan correlation ID
โ€ข OpenTelemetry tracing

๐ŸŽจ Documentation Style Guide

Prompt untuk Consistent Documentation

Pastikan dokumentasi mengikuti style guide ini:

1. Frontmatter
---
title: 'Clear Title'
description: 'One-line description'
icon: 'relevant-icon'
---

2. Headings
- H1 (#): Page title (once)
- H2 (##): Major sections
- H3 (###): Subsections
- H4 (####): Details

3. Code Blocks
- Always specify language
- Include comments
- Use realistic examples
- Show input & output

4. Callouts
<Info>Informational message</Info>
<Warning>Warning message</Warning>
<Tip>Helpful tip</Tip>
<Note>Additional note</Note>

5. Links
- Use Card components untuk related docs
- Cross-reference dengan relative paths
- External links open in new tab

6. Lists
- Use bullet points untuk unordered
- Use numbers untuk sequential steps
- Bold important terms
- Keep items concise

7. Tables
- Use untuk structured data
- Include headers
- Align columns
- Keep cells short

8. Diagrams
- Use Mermaid untuk flow/sequence
- Add titles
- Include legend jika perlu
- Keep simple & readable

Internal Flow Diagrams

Handler & service flow diagrams

Knowledge Base

Quick reference & analogies

API Spec Template

API specification templates

AI Development: Template ini dioptimalkan untuk AI-assisted development dengan ChatGPT, Claude, Copilot, dan WindSurf.