
เขียน Architecture Decision Record (ADR) สำหรับการตัดสินใจทางเทคนิค
สร้าง ADR ที่ครบถ้วนและอ่านง่าย บันทึกบริบท ตัวเลือกที่พิจารณา เหตุผลการตัดสินใจ และ trade-off ที่ยอมรับ ช่วยให้ทีมปัจจุบันและนักพัฒนารุ่นต่อไปเข้าใจว่าทำไมจึงตัดสินใจเช่นนั้น
เริ่มต้นที่นี่
ตัวอย่างผลลัพธ์ที่จะได้
ก่อนเริ่มลงมือปรับพรอมต์ ดูตัวอย่างผลลัพธ์ที่คุณจะได้จริงเพื่อให้แน่ใจว่าพรอมต์นี้ตรงกับงานที่ต้องการ
ADR-0012: Use PostgreSQL instead of MongoDB for User and Order Data
Date: 2026-05-01 Status: Accepted Deciders: Engineering Team
Context
The e-commerce platform (~100,000 MAU) requires a primary database to store users, orders, and inventory records. The team of five engineers is preparing for a production launch in Q3 2026. Data access patterns are predominantly relational — orders reference users and products, and checkout operations must atomically update orders, payments, and inventory in a single transaction. The team has existing SQL expertise and no prior production experience with document databases.
Decision Drivers
- Multi-table ACID transactions are required for the order-payment-inventory checkout flow
- Query patterns involve significant JOINs across users, orders, and products
- Team SQL expertise reduces onboarding cost and time-to-production
- Budget constraints favour a cost-effective self-hosted or managed deployment option
Options Considered
Option 1: PostgreSQL
Pros: Full ACID compliance across multi-table transactions; strong JOIN and window function support; JSONB column type handles flexible product attributes without a separate store; mature ecosystem with active community; free and open-source with low-cost managed options (Supabase, RDS) Cons: Schema migrations must be planned and versioned with a tool (e.g., Flyway, Alembic); horizontal write scaling requires extensions or external tooling (e.g., Citus)
Option 2: MongoDB
Pros: Flexible document schema accelerates iteration on product catalog structure; native horizontal scaling via sharding; Atlas managed service is well-supported Cons: Multi-document transactions are supported but add application-level complexity compared to native SQL transactions; team lacks MongoDB production experience, adding ramp-up time; Atlas pricing at an equivalent reliability tier exceeds PostgreSQL managed options
Option 3: MySQL
Pros: Team has prior familiarity; low-cost managed service available on most cloud providers Cons: JSONB support is weaker than PostgreSQL; window functions and CTE support are less complete; fewer ecosystem integrations for the team's Python/Node.js stack
Decision
PostgreSQL is selected as the primary database. The checkout flow requires atomic updates across three tables (orders, payments, inventory) in a single operation — a guarantee PostgreSQL provides natively without additional configuration, unlike MongoDB's multi-document transaction model which requires explicit session management. The team's existing SQL expertise eliminates a learning curve that would otherwise delay the Q3 launch, and PostgreSQL's JSONB type covers the flexible product attribute requirement without introducing a second database.
Consequences
Positive
- ACID transaction integrity is available from day one, eliminating a class of data consistency bugs in the order and payment flow
- No new technology onboarding required; the team can write and review production-grade queries immediately
- Infrastructure cost is lower than an equivalent MongoDB Atlas tier for the same availability SLA
Negative / Trade-offs Accepted
- Every schema change requires a versioned migration file; ad-hoc column additions are not possible after launch without a coordinated migration run
- Horizontal read scaling beyond a single primary requires provisioning and managing read replicas separately — this is not automatic and adds operational overhead when read traffic grows significantly
Risks & Mitigations
| Risk | Mitigation |
|---|---|
| Schema migration applied incorrectly in production causes downtime or data loss | Adopt Flyway from day one; enforce a staging migration dry-run as a required CI gate before any production deploy |
| Read throughput becomes insufficient as the platform scales past 100,000 MAU | Provision a read replica on RDS or Supabase at the start of Q4; monitor read latency weekly via pg_stat_statements before problems surface |
Links & References
- Related: ADR-0008 (Infrastructure and Hosting Strategy)
- Ticket: ENG-441 — Database Selection Research and Decision
- Reference: https://github.com/joelparkerhenderson/architecture-decision-record
ขั้นตอนที่ 1
ปรับให้เข้ากับงานของคุณ
แก้ค่าตัวแปรด้านล่าง พรอมต์ฉบับสมบูรณ์จะอัพเดทอัตโนมัติพร้อมก๊อปไปวางใน Claude หรือ ChatGPT ได้ทันที
You are a senior software architect writing an Architecture Decision Record (ADR) for an important technical decision. Your goal is to produce a document that helps both current team members and future developers understand not just *what* was decided, but *why* — including the trade-offs consciously accepted. **Input:** - ADR number: 0012 - Decision title: Use PostgreSQL instead of MongoDB for User and Order Data - Project/system context: Mid-size e-commerce platform, ~100,000 MAU, team of 5 engineers, targeting production launch in Q3 2026 - Problem being solved: Need a primary database for users, orders, and inventory that supports multi-table ACID transactions and complex relational queries - Options that were evaluated: 1. PostgreSQL — mature relational DB with JSONB support 2. MongoDB — document-oriented with flexible schema 3. MySQL — familiar relational option with weaker JSONB support - Decision made: PostgreSQL - Known consequences and trade-offs: Gains: full ACID guarantee across multi-table transactions, team already has SQL expertise, JSONB covers flexible product attributes. Trade-offs: schema migrations require planning and versioning with a tool like Flyway; horizontal read scaling needs read replicas configured separately **Output — use this exact structure, no extra sections:** --- # ADR-0012: [Decision Title] **Date:** [today's date] **Status:** Accepted **Deciders:** Engineering Team ## Context [2–4 sentences describing the situation, constraints, and why a decision was required. Be specific: mention scale, team size, or system boundaries where relevant.] ## Decision Drivers - [Driver 1 — technical, business, or operational] - [Driver 2] - [Driver 3] ## Options Considered ### Option 1: [Name] **Pros:** [specific advantages] **Cons:** [specific disadvantages] ### Option 2: [Name] **Pros:** ... **Cons:** ... [Repeat for all options provided] ## Decision [2–3 sentences stating the chosen option and the primary reasoning. Reference the decision drivers explicitly. Do not use vague justifications like 'it's simpler' — explain *why* it is simpler in this specific context.] ## Consequences ### Positive - [Concrete benefit 1] - [Concrete benefit 2] ### Negative / Trade-offs Accepted - [Trade-off 1 — be honest and specific] - [Trade-off 2] ### Risks & Mitigations | Risk | Mitigation | |------|------------| | [Risk 1] | [Concrete action to address it] | | [Risk 2] | [Concrete action to address it] | ## Links & References - [Related ADRs, tickets, RFCs, or documentation] --- **Constraints:** - Write entirely in English. ADRs are engineering documents intended for long-term archival; English maximises readability across future team members. - Do NOT omit the "Negative / Trade-offs Accepted" section. Honest documentation of trade-offs is the most valuable part of an ADR. - Do NOT use vague qualitative claims. Every advantage or disadvantage must reference a specific technical property, constraint, or measurable outcome. - Keep tone neutral and factual. Do not retroactively advocate for the decision — document it objectively. - Do not add sections beyond those listed in the format above.
ขั้นตอนที่ 2
เข้าใจเทคนิคที่ซ่อนอยู่
คลิกที่ส่วนไฮไลต์ในพรอมต์เพื่อกระโดดไปดูคำอธิบายเทคนิคแต่ละจุด ใช้ความเข้าใจนี้เพื่อปรับพรอมต์อื่นของคุณเองในภายหลัง
Your goal is to produce a document that helps both current team members and future developers understand not just *what* was decided, but *why* — including the trade-offs consciously accepted. **Input:** - ADR number: {{adr_number}} - Decision title: {{decision_title}} - Project/system context: {{project_context}} - Problem being solved: {{problem_statement}} - Options that were evaluated: {{options_considered}} - Decision made: {{chosen_option}} - Known consequences and trade-offs: {{consequences}} **Output — :** --- # ADR-{{adr_number}}: [Decision Title] **Date:** [today's date] **Status:** Accepted **Deciders:** Engineering Team ## Context [2–4 sentences describing the situation, constraints, and why a decision was required. Be specific: mention scale, team size, or system boundaries where relevant.] ## Decision Drivers - [Driver 1 — technical, business, or operational] - [Driver 2] - [Driver 3] ## Options Considered ### Option 1: [Name] **Pros:** [specific advantages] **Cons:** [specific disadvantages] ### Option 2: [Name] **Pros:** ... **Cons:** ... [Repeat for all options provided] ## Decision [2–3 sentences stating the chosen option and the primary reasoning. Reference the decision drivers explicitly. ] ## Consequences ### Positive - [Concrete benefit 1] - [Concrete benefit 2] ### Negative / Trade-offs Accepted - [Trade-off 1 — be honest and specific] - [Trade-off 2] ### Risks & Mitigations | Risk | Mitigation | |------|------------| | [Risk 1] | [Concrete action to address it] | | [Risk 2] | [Concrete action to address it] | ## Links & References - [Related ADRs, tickets, RFCs, or documentation] --- **Constraints:** - Write entirely in English. ADRs are engineering documents intended for long-term archival; English maximises readability across future team members. - - - Keep tone neutral and factual. Do not retroactively advocate for the decision — document it objectively. - Do not add sections beyond those listed in the format above.
- 1Role assignment
“You are a senior software architect writing an Architecture Decision Record (ADR) for an important technical decision.”
การกำหนด role ที่เจาะจงทำให้โมเดลเลือกใช้ tone และ vocabulary ที่เหมาะกับ engineering documentation แทนที่จะเขียนแบบทั่วไป ส่งผลให้ภาษาที่ออกมามีความเป็น professional และ precise มากขึ้น
- 2Output format constraint
“use this exact structure, no extra sections”
การล็อก template ป้องกันโมเดลจากการเพิ่ม section ที่ไม่จำเป็นหรือจัดรูปแบบต่างออกไปในแต่ละครั้ง ทำให้ ADR ทุกฉบับในทีมมีโครงสร้างเดียวกันและอ่านได้ง่ายในระยะยาว
- 3Negative constraint
“Do NOT omit the "Negative / Trade-offs Accepted" section. Honest documentation of trade-offs is the most valuable part of an ADR.”
โมเดลมีแนวโน้มเขียนเชิงบวกตามสิ่งที่ผู้ใช้ระบุ การห้ามชัดเจนพร้อมอธิบายเหตุผลทำให้โมเดลรักษา section สำคัญที่มักถูกละเลยไว้เสมอ แทนที่จะตัดออกเพื่อความกระชับ
- 4Specificity constraint
“Do NOT use vague qualitative claims. Every advantage or disadvantage must reference a specific technical property, constraint, or measurable outcome.”
การห้ามคำคลุมเครือพร้อมนิยามว่า 'specific' หมายถึงอะไร บังคับให้โมเดลเขียน rationale ที่มีประโยชน์จริงแทนที่จะเขียนแค่ 'ดีกว่า' หรือ 'ง่ายกว่า' ซึ่งไม่ช่วยให้ทีมเรียนรู้อะไรได้
- 5Anti-pattern example
“Do not use vague justifications like 'it's simpler' — explain *why* it is simpler in this specific context.”
การยกตัวอย่าง anti-pattern ที่ชัดเจนพร้อมบอกทางที่ถูกต้องช่วยให้โมเดลเข้าใจระดับความละเอียดที่ต้องการได้ดีกว่าการบอกแค่ 'be specific' เพราะโมเดลมีตัวอย่างรูปแบบที่ผิดให้หลีกเลี่ยงอย่างชัดเจน
ขั้นตอนที่ 3
เห็นความต่าง พรอมต์ทั่วไป vs พรอมต์ที่ใช้เทคนิค
คนส่วนใหญ่เริ่มต้นด้วยคำสั่งสั้นๆ แบบฝั่งซ้าย แต่ผลลัพธ์มักไม่ตรงใจและต้องถามซ้ำหลายรอบ พรอมต์แบบฝั่งขวาแก้ปัญหานี้ด้วยเทคนิคที่อธิบายข้างต้น
พรอมต์แบบที่ใช้กันทั่วไป
ช่วยเขียน ADR สำหรับการเลือก database หน่อย
พรอมต์แบบที่ใช้เทคนิคข้างบน
- กำหนด role เป็น senior software architect และระบุเป้าหมายว่า ADR ต้องอธิบายทั้ง 'what' และ 'why'
- รับ input 7 fields เพื่อ ground โมเดลด้วยข้อมูลจริงของโปรเจกต์ก่อนสร้างเอกสาร
- บังคับโครงสร้าง 7 sections ด้วย template แน่นอน ห้ามเพิ่มหรือลด section
- ห้ามละเว้น Negative/Trade-offs section พร้อมระบุว่าเป็น section ที่มีคุณค่าสูงสุด
- ห้ามใช้คำคลุมเครือและต้องอ้างอิง technical property ที่วัดหรือสังเกตได้
ทำไมแบบที่ใช้เทคนิคถึงดีกว่า
คำสั่งสั้นแบบ before ไม่บอกบริบทใดเลย ทำให้โมเดลต้องสร้างรายละเอียดทุกอย่างขึ้นมาเอง ทั้งตัวเลือก เหตุผล และ trade-off ซึ่งมักออกมาเป็นตัวอย่างสมมติที่ไม่ตรงกับโปรเจกต์จริง Prompt ที่ดีกว่าบังคับให้ผู้ใช้ส่ง context ที่ครบก่อน และล็อก template ไว้ล่วงหน้า ทำให้โมเดลทำหน้าที่เรียบเรียงข้อมูลจริงให้เป็นเอกสารคุณภาพสูงแทนที่จะเดา นอกจากนี้การห้ามละเว้น trade-off section ยังป้องกันปัญหาที่พบบ่อยที่สุดใน ADR ที่เขียนโดย AI นั่นคือเอกสารที่ดูดีแต่ขาดความซื่อสัตย์ต่อข้อเสียของการตัดสินใจ
พรอมต์ที่เกี่ยวข้อง
ลองพรอมต์อื่นในแนวเดียวกัน

งานโค้ด
อธิบาย Legacy Code ให้ทีมใหม่เข้าใจเร็ว พร้อม Flag จุดเสี่ยงและ Tech Debt
ให้ AI วิเคราะห์โค้ดเก่าที่ซับซ้อน สรุปการทำงาน ชี้จุดเสี่ยง และจัดทำ tech debt log พร้อม effort estimate เพื่อให้ทีมใหม่เริ่มต้นได้อย่างปลอดภัยและมีทิศทางชัดเจน

งานโค้ด
สร้าง Test Cases ครอบคลุมจาก Function Spec
สร้าง test suite จาก function specification ที่ครอบคลุมทั้ง happy path, edge cases และ adversarial inputs พร้อม rationale ของแต่ละ test และ runnable code ในภาษาและ framework ที่เลือก ช่วย developer เขียน test อย่างเป็นระบบและตรวจจับ bug ที่ซ่อนอยู่ได้อย่างมีประสิทธิภาพ

งานโค้ด
Code Review Checklist 5 มิติ: Correctness, Security, Performance, Style, Test Coverage
พรอมต์สำหรับ developer ที่ต้องการ code review เชิงลึก ครอบคลุม 5 มิติหลัก พร้อมระบบ status icon และ verdict สรุป ช่วยให้ review ได้ครบถ้วนและสม่ำเสมอทุกครั้ง

งานโค้ด
อธิบาย Error Message ให้เข้าใจง่ายพร้อมแก้ทีละขั้นและป้องกันซ้ำ
พรอมต์สำหรับนักพัฒนาที่ต้องการอ่าน error message ที่ซับซ้อนให้เข้าใจง่าย รับคำแนะนำแก้ไขทีละขั้นตอน และเรียนรู้วิธีป้องกันไม่ให้ปัญหาเดิมเกิดซ้ำในอนาคต