# Aider — Pair Programming จริงจังกับ AI ใน Terminal

> Source: <https://dev.to/gophernment/aider-pair-programming-cchringcchangkab-ai-ain-terminal-27a2>
> Published: 2026-06-30 07:24:56+00:00

ผมเชื่อในสองเรื่อง:

`git log`

อ่านแล้วรู้เรื่อง ไม่ใช่ commit เดียวยาว 500 บรรทัดที่แก้ทุกอย่างตั้งแต่ database schema ยัน CSSปัญหาคือหาคนมานั่ง pair ด้วยตลอดเวลามันไม่ง่าย — และการจะรักษา atomic commit ให้สะอาดทุกครั้งก็ต้องใช้ความตั้งใจสูง

**Aider** คือเครื่องมือที่แก้ปัญหาสองเรื่องนี้ได้ในคราวเดียว

Aider เป็น AI pair programming tool ที่ทำงานใน terminal — คุณเปิด terminal, `cd`

เข้า project, แล้วพิมพ์ `aider`

สิ่งที่เกิดขึ้น:

``` bash
$ aider
──────────────────────────────────────────────────
Aider v0.80.0
Model: claude-sonnet-4-20250514 (Claude Sonnet 4.6)
Git repo: .git with 142 files
Repo map: using 1024 tokens
──────────────────────────────────────────────────
>
```

จากนั้นคุณก็... **คุยกับมันเหมือนคุยกับคนที่นั่งข้าง ๆ**

"help me add rate limiting to the API — per-user, 100 requests per minute, using Redis"

Aider จะ:

`api/middleware/`

and a Redis client in `pkg/redis/`

"นี่คือสิ่งที่ผมชอบที่สุด: **มัน commit ให้อัตโนมัติ**

ลองดู `git log`

หลังจาก pair กับ Aider สักพัก:

``` bash
$ git log --oneline
a3f2c1 Add rate limiting middleware with Redis backend
8b7d4e Refactor auth middleware to use context-based user extraction
2c1e9f Add user repository with FindByEmail method
f4a8b2 Create initial project structure with Go modules
```

ทุก commit:

เปรียบเทียบกับการทำงานคนเดียว:

```
- ❌ "เขียน API ใหม่" → แก้ 15 ไฟล์ → commit เดียว "implement new API"
+ ✅ คุยกับ Aider ทีละ feature → 15 commits เล็ก ๆ → แต่ละอันเข้าใจได้ใน 30 วิ
```

สมมติเรามี Go API ง่าย ๆ แล้วอยากเพิ่ม feature "search users by email prefix"

```
> I need a search endpoint that finds users by email prefix.
  GET /users/search?q=jo should return users whose email starts with "jo"
  Use existing UserRepo, add the query method there
```

Aider ตอบ:

```
I'll add:
1. A `SearchByEmailPrefix` method to `UserRepo` in `internal/repo/user.go`
2. A search handler in `internal/handler/user.go`
3. Register the route in `cmd/server/main.go`

Let me start with the repository method.
// internal/repo/user.go
+func (r *UserRepo) SearchByEmailPrefix(ctx context.Context, prefix string) ([]User, error) {
+    rows, err := r.db.QueryContext(ctx,
+        "SELECT id, name, email FROM users WHERE email LIKE $1",
+        prefix+"%")
+    // ...
+}
```

คุณเห็น diff → กด `y`

(yes) → Aider commit → ไปต่อข้อถัดไป

```
> add input validation — prefix must be at least 2 chars
```

Aider เพิ่ม validation → commit

```
> wait, the SQL query should use parameterized LIKE properly
> it's $1 || '%' in PostgreSQL, not prefix+"%"
```

Aider แก้ query → commit

```
> now add a test file for the search handler using httptest
```

Aider สร้าง test → รัน test → test ผ่าน → commit

4 commits — ทุกอันทำเรื่องเดียว — `git log`

สวย

Aider สร้าง **repo map** — index ว่าแต่ละไฟล์ define อะไร, ถูก import โดยใคร, ใช้ symbol อะไร — ทำให้มันรู้ว่าต้องอ่านไฟล์ไหนแก้ feature นี้ โดยที่คุณไม่ต้องบอก

ไม่ต้อง copy-paste โค้ดให้ AI อ่าน — Aider รู้เองว่าต้องดู `user.go`

, `handler.go`

, `main.go`

Aider ไม่ได้ print โค้ดให้คุณ copy-paste — มันใช้ **edit format** — ภาษาที่บอกว่า "ค้นหา block นี้, แล้วแทนที่ด้วย block นี้" — เหมือน `sed`

แต่ฉลาดกว่า

ข้อดี: เร็วกว่าการ generate ไฟล์ใหม่ทั้งหมด และแม่นยำกว่า — แก้เฉพาะตรงที่ต้องแก้

``` bash
$ aider --model deepseek/deepseek-chat
$ aider --model openai/gpt-4o
$ aider --model anthropic/claude-sonnet-4-20250514
```

งานง่ายใช้ DeepSeek (ถูก) — งานยากใช้ Claude Opus (เก่ง) — ไม่ต้องเปลี่ยน tool

``` bash
$ aider --voice
```

คุยกับ AI เหมือนคุยโทรศัพท์ — "add error handling for database connection failures" — Aider เขียนโค้ดให้

| Aider | Copilot | Cursor | Antigravity | |
|---|---|---|---|---|
Philosophy |
Pair programming + atomic commit | Autocomplete + chat | AI-first IDE | Agentic platform |
Interface |
Terminal | IDE plugin | IDE (forked VS Code) | IDE, CLI, SDK |
Atomic Commit |
✅ อัตโนมัติ | ❌ | ❌ | ❌ |
Model Choice |
เปลี่ยนได้ทุกค่าย | จำกัด | จำกัด | Gemini-focused |
Repo Map |
✅ | ❌ | ใช้ codebase index | ❌ |
ราคา |
API key ตัวเอง | $10/月 | $20/月 | Free/Paid |

Aider ไม่ใช่คู่แข่งโดยตรง — มันคือ **เครื่องมืออีกแบบ** — สำหรับคนที่:

```
# ติดตั้ง
pip install aider-chat

# หรือใช้ uv
uv tool install aider-chat

# ตั้ง API key (เลือกค่ายที่ใช้)
export ANTHROPIC_API_KEY="sk-ant-..."
export DEEPSEEK_API_KEY="sk-..."

# เข้า project ที่มี git แล้ว
cd ~/my-go-project
aider

# เริ่มคุย!
> add health check endpoint at /healthz
```

**Pro tip:** ใช้ DeepSeek V4 Flash ($0.14/M input) สำหรับงาน routine — แล้วเปลี่ยนเป็น Claude Sonnet ($3/M) ตอนงานซับซ้อน — Aider รองรับ `/model deepseek/deepseek-chat`

เปลี่ยนกลาง session ได้เลย

`--browser`

โหมดทดลอง)Aider คือสิ่งที่เกิดขึ้นเมื่อคุณเอา philosophy ของ **pair programming** + **atomic commit** มารวมกับ LLM — ผลลัพธ์คือ AI ที่นั่ง pair กับคุณใน terminal, เขียนโค้ด, โชว์ diff, และ commit ให้ — เหมือนมี senior dev นั่งข้าง ๆ ที่ `git commit`

เก่งเป็นบ้า

และใช่ — ผมกำลังเชียร์ให้คุณลองใช้

```
pip install aider-chat && cd project && aider
```

📚

Source:[Aider]— AI pair programming in your terminal
