Nội dung này đã khóa
Vui lòng đăng nhập hoặc đăng ký mua sách để đọc tiếp những kiến thức chuyên sâu này.
Phụ lục A: Prompt Toolkit - Bộ sưu tập câu lệnh "Trấn Phái"
"Một Prompt tốt bằng mười năm kinh nghiệm."
Dưới đây là bộ sưu tập các Prompt mà tôi (Hiền Nguyễn) dùng hàng ngày để xây dựng VibeMaterial. Nó được chia theo đúng các giai đoạn phát triển phần mềm (Software Development Life Cycle - SDLC).
Hãy copy vào file PROMPT_LIBRARY.md của riêng bạn và dùng dần.
13.1 GIAI ĐOẠN 1 – LÊN Ý TƯỞNG (IDEATION)
13.1.1 Định nghĩa bài toán (Business Scope)
- Mục đích: Chặn ngay từ đầu việc AI vẽ app quá to, over-engineering.
You are a product manager.
I want to build a small e-commerce website for [Construction Materials].
Please help me define:
- User roles (client, admin)
- Core features for client (MVP only)
- Core features for admin
- What should NOT be included to avoid over-engineering (e.g., AI Chatbot, Complex Recommendation)
Output format: bullet points, concise.
13.1.2 Phân tách Client vs Admin
- Mục đích: Tránh lỗi sơ đẳng là Client nhìn thấy dữ liệu nhạy cảm của Admin.
You are a system architect.
Given an e-commerce website, split the system into:
- Client-facing features (Public, Fast, SEO)
- Admin-only features (Private, Secure, Data-heavy)
Explain the separation logic and data access boundaries.
13.2 GIAI ĐOẠN 2 – KIẾN TRÚC HỆ THỐNG (ARCHITECTURE)
13.2.1 Tổng thể kiến trúc (Hybrid Model)
- Mục đích: Đặt não AI vào đúng vai trò Kiến trúc sư.
You are a senior software architect.
Design a high-level architecture for a Hybrid System:
1. **Frontend**: Next.js (Web) for Customers.
2. **Internal Tool**: AppSheet/Admin Web for Staff.
3. **Database**: Supabase (Shared Source of Truth).
Constraints:
- Avoid frontend direct access to database. Must use API Layer.
- Explain how data flows when a Customer creates an Order.
Output: architecture explanation + simple flow description.
13.3 GIAI ĐOẠN 3 – THIẾT KẾ DỮ LIỆU (DATABASE)
13.3.1 Thiết kế Schema (JSON/SQL First)
- Mục đích: Chặn bệnh "nghiện cột" của dân AppSheet.
-- You are a data architect.
-- Design a Database Schema for "Orders" and "OrderItems" using SQL (PostgreSQL).
-- Requirements:
-- - Use UUID for Primary Keys.
-- - Ensure Master-Detail relationship.
-- - Add `created_at` and `updated_at` timestamps.
-- - Add a JSONB column `metadata` for flexible attributes.
-- Provide the `CREATE TABLE` scripts.
CREATE TABLE orders (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
customer_name TEXT,
total_amount DECIMAL,
status TEXT DEFAULT 'pending',
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE TABLE order_items (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
order_id UUID REFERENCES orders(id),
product_id UUID,
quantity INTEGER,
price DECIMAL
);
13.3.2 Chuẩn hóa JSON Label (Tiết kiệm Token)
- Mục đích: Khi API gửi data, key ngắn sẽ tiết kiệm băng thông.
You are an AI optimization expert.
I have a JSON object for "Product".
Please optimize the JSON keys to be shorter but still readable (e.g., `product_name` -> `name`, `inventory_quantity` -> `stock`).
Explain why this helps with API performance.
13.4 GIAI ĐOẠN 4 – API & BACKEND
13.4.1 Thiết kế API cho Client
- Mục đích: Chỉ trả về dữ liệu cần thiết.
You are a backend engineer.
Design REST API endpoints for client-side features:
- Get product list (Public)
- Create order (Public)
Constraints:
- Response must NOT include sensitive fields (e.g., `cost_price`, `supplier_contact`).
- Implement Pagination for Product List (Limit 20).
13.4.2 Bảo vệ Backend (Security Layer)
- Mục đích: Không để Frontend chọc thẳng Database.
Explain why querying Database directly from Client-side (Frontend) is dangerous.
Propose a solution using Next.js API Routes (Server-side) to act as a secure proxy.
13.5 GIAI ĐOẠN 5 – FRONTEND & UX
13.5.1 Thiết kế Component (Tailwind + Shadcn)
- Mục đích: Có code đẹp ngay lập tức.
Prompt: You are a Senior Frontend Dev using Next.js, TailwindCSS, and Shadcn/UI. Task: Create a
ProductCardcomponent. Props:title(string),price(number),image(url),onAddToCart(function). Features:
- Format price to VND (e.g., 50.000 đ).
- Show "Out of Stock" badge if
stock === 0.- Hover effect on card.
13.5.2 Quản lý State (Zustand)
- Mục đích: Làm giỏ hàng mượt mà.
Prompt: You are a React expert. Implement a simple Shopping Cart Store using
zustand. Features:
addItem(product)removeItem(id)clearCart()totalPrice(computed). Persist data tolocalStorageso user doesn't lose cart on refresh.
13.6 GIAI ĐOẠN 6 – AUTOMATION & DEPLOY
13.6.1 Automation Workflow (n8n/Webhook)
- Mục đích: Bắn tin nhắn khi có đơn.
Prompt: You are an automation engineer. Design an automation flow: Trigger: Webhook (received JSON from Next.js API when Order is created). Action 1: Format message "New Order #123 - Total: 500k". Action 2: Send to Telegram Bot. Provide the Logic Flow.
13.6.2 Checklist Deploy (An toàn)
- Mục đích: Không để lộ chìa khóa nhà.
Prompt: Provide a deployment checklist for Vercel:
- Which Environment Variables must be set? (SUPABASE_URL, SERVICE_ROLE...)
- How to prevent
console.login production?- How to protect Admin Routes?
13.7 Đúc kết & Giới thiệu chương tiếp theo
Đây là bộ sưu tập Prompt "Trấn Phái" được đúc kết qua nhiều dự án thực tế. Nhưng hãy nhớ: Đừng dùng Prompt như một cái máy.
Hãy chỉnh sửa (Modify) theo ngữ cảnh dự án của bạn - đổi tên bảng, đổi công nghệ, thêm bớt yêu cầu. Prompt chỉ là khung xương, Context của bạn mới là thịt da.
Mẹo sử dụng:
- Copy prompt vào file
PROMPTS.mdtrong dự án - Điền placeholder
[...]bằng thông tin thực - Paste vào Google AI Studio hoặc AntiGravity
- Tinh chỉnh kết quả theo feedback
Bạn đã đi gần hết hành trình. Trong Chương 14: Lời Kết, tôi sẽ gửi lại thông điệp cuối cùng - về triết lý VibeCode, về sự tự do công nghệ, và về cách kết nối với cộng đồng VibeCoder Việt Nam.