{"slug": "aider-pair-programming-cchringcchangkab-ai-ain-terminal", "title": "Aider — Pair Programming จริงจังกับ AI ใน Terminal", "summary": "Aider is an AI pair programming tool that operates in the terminal, enabling developers to collaborate with AI models like Claude Sonnet and GPT-4o. It automatically creates atomic commits for each feature change, maintains a repo map to understand code structure, and supports voice commands and multiple model backends. The tool aims to solve the challenge of maintaining clean, atomic git commits while providing a seamless pair programming experience.", "body_md": "ผมเชื่อในสองเรื่อง:\n\n`git log`\n\nอ่านแล้วรู้เรื่อง ไม่ใช่ commit เดียวยาว 500 บรรทัดที่แก้ทุกอย่างตั้งแต่ database schema ยัน CSSปัญหาคือหาคนมานั่ง pair ด้วยตลอดเวลามันไม่ง่าย — และการจะรักษา atomic commit ให้สะอาดทุกครั้งก็ต้องใช้ความตั้งใจสูง\n\n**Aider** คือเครื่องมือที่แก้ปัญหาสองเรื่องนี้ได้ในคราวเดียว\n\nAider เป็น AI pair programming tool ที่ทำงานใน terminal — คุณเปิด terminal, `cd`\n\nเข้า project, แล้วพิมพ์ `aider`\n\nสิ่งที่เกิดขึ้น:\n\n``` bash\n$ aider\n──────────────────────────────────────────────────\nAider v0.80.0\nModel: claude-sonnet-4-20250514 (Claude Sonnet 4.6)\nGit repo: .git with 142 files\nRepo map: using 1024 tokens\n──────────────────────────────────────────────────\n>\n```\n\nจากนั้นคุณก็... **คุยกับมันเหมือนคุยกับคนที่นั่งข้าง ๆ**\n\n\"help me add rate limiting to the API — per-user, 100 requests per minute, using Redis\"\n\nAider จะ:\n\n`api/middleware/`\n\nand a Redis client in `pkg/redis/`\n\n\"นี่คือสิ่งที่ผมชอบที่สุด: **มัน commit ให้อัตโนมัติ**\n\nลองดู `git log`\n\nหลังจาก pair กับ Aider สักพัก:\n\n``` bash\n$ git log --oneline\na3f2c1 Add rate limiting middleware with Redis backend\n8b7d4e Refactor auth middleware to use context-based user extraction\n2c1e9f Add user repository with FindByEmail method\nf4a8b2 Create initial project structure with Go modules\n```\n\nทุก commit:\n\nเปรียบเทียบกับการทำงานคนเดียว:\n\n```\n- ❌ \"เขียน API ใหม่\" → แก้ 15 ไฟล์ → commit เดียว \"implement new API\"\n+ ✅ คุยกับ Aider ทีละ feature → 15 commits เล็ก ๆ → แต่ละอันเข้าใจได้ใน 30 วิ\n```\n\nสมมติเรามี Go API ง่าย ๆ แล้วอยากเพิ่ม feature \"search users by email prefix\"\n\n```\n> I need a search endpoint that finds users by email prefix.\n  GET /users/search?q=jo should return users whose email starts with \"jo\"\n  Use existing UserRepo, add the query method there\n```\n\nAider ตอบ:\n\n```\nI'll add:\n1. A `SearchByEmailPrefix` method to `UserRepo` in `internal/repo/user.go`\n2. A search handler in `internal/handler/user.go`\n3. Register the route in `cmd/server/main.go`\n\nLet me start with the repository method.\n// internal/repo/user.go\n+func (r *UserRepo) SearchByEmailPrefix(ctx context.Context, prefix string) ([]User, error) {\n+    rows, err := r.db.QueryContext(ctx,\n+        \"SELECT id, name, email FROM users WHERE email LIKE $1\",\n+        prefix+\"%\")\n+    // ...\n+}\n```\n\nคุณเห็น diff → กด `y`\n\n(yes) → Aider commit → ไปต่อข้อถัดไป\n\n```\n> add input validation — prefix must be at least 2 chars\n```\n\nAider เพิ่ม validation → commit\n\n```\n> wait, the SQL query should use parameterized LIKE properly\n> it's $1 || '%' in PostgreSQL, not prefix+\"%\"\n```\n\nAider แก้ query → commit\n\n```\n> now add a test file for the search handler using httptest\n```\n\nAider สร้าง test → รัน test → test ผ่าน → commit\n\n4 commits — ทุกอันทำเรื่องเดียว — `git log`\n\nสวย\n\nAider สร้าง **repo map** — index ว่าแต่ละไฟล์ define อะไร, ถูก import โดยใคร, ใช้ symbol อะไร — ทำให้มันรู้ว่าต้องอ่านไฟล์ไหนแก้ feature นี้ โดยที่คุณไม่ต้องบอก\n\nไม่ต้อง copy-paste โค้ดให้ AI อ่าน — Aider รู้เองว่าต้องดู `user.go`\n\n, `handler.go`\n\n, `main.go`\n\nAider ไม่ได้ print โค้ดให้คุณ copy-paste — มันใช้ **edit format** — ภาษาที่บอกว่า \"ค้นหา block นี้, แล้วแทนที่ด้วย block นี้\" — เหมือน `sed`\n\nแต่ฉลาดกว่า\n\nข้อดี: เร็วกว่าการ generate ไฟล์ใหม่ทั้งหมด และแม่นยำกว่า — แก้เฉพาะตรงที่ต้องแก้\n\n``` bash\n$ aider --model deepseek/deepseek-chat\n$ aider --model openai/gpt-4o\n$ aider --model anthropic/claude-sonnet-4-20250514\n```\n\nงานง่ายใช้ DeepSeek (ถูก) — งานยากใช้ Claude Opus (เก่ง) — ไม่ต้องเปลี่ยน tool\n\n``` bash\n$ aider --voice\n```\n\nคุยกับ AI เหมือนคุยโทรศัพท์ — \"add error handling for database connection failures\" — Aider เขียนโค้ดให้\n\n| Aider | Copilot | Cursor | Antigravity | |\n|---|---|---|---|---|\nPhilosophy |\nPair programming + atomic commit | Autocomplete + chat | AI-first IDE | Agentic platform |\nInterface |\nTerminal | IDE plugin | IDE (forked VS Code) | IDE, CLI, SDK |\nAtomic Commit |\n✅ อัตโนมัติ | ❌ | ❌ | ❌ |\nModel Choice |\nเปลี่ยนได้ทุกค่าย | จำกัด | จำกัด | Gemini-focused |\nRepo Map |\n✅ | ❌ | ใช้ codebase index | ❌ |\nราคา |\nAPI key ตัวเอง | $10/月 | $20/月 | Free/Paid |\n\nAider ไม่ใช่คู่แข่งโดยตรง — มันคือ **เครื่องมืออีกแบบ** — สำหรับคนที่:\n\n```\n# ติดตั้ง\npip install aider-chat\n\n# หรือใช้ uv\nuv tool install aider-chat\n\n# ตั้ง API key (เลือกค่ายที่ใช้)\nexport ANTHROPIC_API_KEY=\"sk-ant-...\"\nexport DEEPSEEK_API_KEY=\"sk-...\"\n\n# เข้า project ที่มี git แล้ว\ncd ~/my-go-project\naider\n\n# เริ่มคุย!\n> add health check endpoint at /healthz\n```\n\n**Pro tip:** ใช้ DeepSeek V4 Flash ($0.14/M input) สำหรับงาน routine — แล้วเปลี่ยนเป็น Claude Sonnet ($3/M) ตอนงานซับซ้อน — Aider รองรับ `/model deepseek/deepseek-chat`\n\nเปลี่ยนกลาง session ได้เลย\n\n`--browser`\n\nโหมดทดลอง)Aider คือสิ่งที่เกิดขึ้นเมื่อคุณเอา philosophy ของ **pair programming** + **atomic commit** มารวมกับ LLM — ผลลัพธ์คือ AI ที่นั่ง pair กับคุณใน terminal, เขียนโค้ด, โชว์ diff, และ commit ให้ — เหมือนมี senior dev นั่งข้าง ๆ ที่ `git commit`\n\nเก่งเป็นบ้า\n\nและใช่ — ผมกำลังเชียร์ให้คุณลองใช้\n\n```\npip install aider-chat && cd project && aider\n```\n\n📚\n\nSource:[Aider]— AI pair programming in your terminal", "url": "https://wpnews.pro/news/aider-pair-programming-cchringcchangkab-ai-ain-terminal", "canonical_source": "https://dev.to/gophernment/aider-pair-programming-cchringcchangkab-ai-ain-terminal-27a2", "published_at": "2026-06-30 07:24:56+00:00", "updated_at": "2026-06-30 07:48:54.688407+00:00", "lang": "en", "topics": ["artificial-intelligence", "developer-tools", "large-language-models"], "entities": ["Aider", "Claude Sonnet", "GPT-4o", "DeepSeek", "Claude Opus", "Git", "Redis", "PostgreSQL"], "alternates": {"html": "https://wpnews.pro/news/aider-pair-programming-cchringcchangkab-ai-ain-terminal", "markdown": "https://wpnews.pro/news/aider-pair-programming-cchringcchangkab-ai-ain-terminal.md", "text": "https://wpnews.pro/news/aider-pair-programming-cchringcchangkab-ai-ain-terminal.txt", "jsonld": "https://wpnews.pro/news/aider-pair-programming-cchringcchangkab-ai-ain-terminal.jsonld"}}