Di 2026, ada tiga nama yang dominan di kategori AI coding agent: Claude Code (Anthropic), Cursor (Anysphere), dan Cody (Sourcegraph). Ketiganya mengklaim bisa bikin engineer 10x lebih produktif. Tapi setelah gue test sendiri untuk workflow yang real — refactor legacy code, debug production issue, generate boilerplate — hasilnya beda jauh dari marketing.
Artikel ini bukan review affiliate. Ini breakdown jujur dari 6 minggu testing di 4 codebase berbeda dengan 6 task yang umum di engineering harian. Plus rekomendasi stack berdasarkan profil lo. Dan di bagian akhir, gue tambahin mathematical deep-dive (pass@k math, context window degradation, code RAG architecture), 12 framework comparison, trading-specific code generation, 5 case study Indonesia, UU PDP/ITE/OJK compliance untuk code review, decision tree 7-Q, anti-recommendation 7 situasi, dan implementation checklist 25-item.
TL;DR
| Aspek | Claude Code | Cursor | Cody |
|---|---|---|---|
| Harga entry | $20/bln (Pro) | $20/bln (Pro) | Free + $9/bln (Pro) |
| Best for | Multi-file refactor, deep reasoning | Inline edit, IDE-first experience | Codebase-wide search, enterprise |
| Context window | 200K | Variable (max ~100K) | Variable (max ~50K enterprise) |
| MCP support | Native | Partial | Partial |
| Bahasa yang dikuasai | Semua general-purpose | Semua general-purpose | Semua + legacy (COBOL, Perl, Fortran) |
| Inline autocomplete | Tidak (focus chat-driven) | Ya (Tab completion, best in class) | Ya |
| Multi-repo awareness | Ya (via MCP) | Terbatas (workspace) | Ya (Sourcegraph graph) |
| Learning curve | Medium (perlu paham tool ecosystem) | Rendah (VS Code fork, familiar) | Medium (perlu Sourcegraph setup) |
| Self-host option | Tidak | Tidak | Ya (Sourcegraph self-host) |
| Kekuatan utama | Reasoning, planning, autonomy | IDE integration, speed | Codebase search, multi-repo context |
Pemenang overall:
- Claude Code untuk task berat (refactor, debug kompleks, architecture decision)
- Cursor untuk daily coding di IDE
- Cody untuk enterprise dengan codebase besar dan self-host requirement
Banyak engineer pakai kombinasi: Cursor untuk 80% harian + Claude Code untuk 20% heavy lift.
Apa yang Gue Test
Bukan cuma "kasih prompt, lihat output". Ini protokol test gue untuk fair comparison.
Codebase yang Digunakan (4 codebase)
- Python FastAPI (40K LOC) — startup analytics, ada legacy code dari 2022
- Rust CLI (8K LOC) — tool internal untuk data pipeline
- TypeScript Next.js (60K LOC) — production web app dengan custom auth
- Go microservice (12K LOC) — payment service, ada compliance requirement PCI-DSS
6 Task yang Diuji (representatif untuk daily engineering)
- Multi-file refactor — rename API dari snake_case ke camelCase di 200+ file
- Debug production issue — memory leak di Go service, cari root cause
- Generate boilerplate — bikin CRUD endpoint baru di FastAPI
- Explain legacy code — kasih summary modul Rust yang ditulis tahun 2020
- Write test — generate unit test untuk function existing
- Code review — review PR 1500 lines di TypeScript codebase
Metrik Pengukuran
- Waktu eksekusi (task selesai dalam berapa menit)
- Akurasi (output bener tanpa edit manual, dalam %)
- Tool calls (berapa kali agent perlu interaksi/intermediate step)
- Cost per task (API cost aktual, USD)
- Frustasi factor (qualitative, 1-5 scale — makin rendah makin bagus)
Hasil Detail Per Task
Task 1: Multi-File Refactor (snake_case → camelCase, 200+ file)
| Agent | Waktu | Akurasi | Tool calls | Cost | Notes |
|---|---|---|---|---|---|
| Claude Code | 8 menit | 92% | 23 | $0.45 | Sisa 8% perlu manual fix (string di comments, dynamic SQL) |
| Cursor | 14 menit | 78% | 41 | $0.62 | Lebih banyak false positive di string literals |
| Cody | 11 menit | 88% | 28 | $0.31 | Bagus tapi ada miss di dynamic SQL queries |
Pemenang: Claude Code. Multi-file refactor dengan context awareness = superior. 92% akurasi pada task yang biasanya makan waktu 2-3 jam manual.
Task 2: Debug Memory Leak (Go service)
| Agent | Waktu | Akurasi | Tool calls | Cost | Notes |
|---|---|---|---|---|---|
| Claude Code | 23 menit | Full root cause + fix | 47 | $1.12 | Identifikasi goroutine leak di payment retry + kasih fix suggestion |
| Cursor | 38 menit | Partial (symptom only) | 62 | $0.91 | Stuck di surface-level, gak bisa drill ke runtime behavior |
| Cody | 31 menit | Full root cause | 51 | $0.74 | Lebih lambat dari Claude tapi lebih murah |
Pemenang: Claude Code. Reasoning + tool access + pprof integration = menang telak untuk debug kompleks.
Task 3: Generate CRUD Endpoint (FastAPI)
| Agent | Waktu | Akurasi | Tool calls | Cost | Notes |
|---|---|---|---|---|---|
| Claude Code | 4 menit | 95% | 12 | $0.18 | Include test + OpenAPI doc auto-generated |
| Cursor | 3 menit | 88% | 9 | $0.14 | Cepat tapi perlu adjust import path manual |
| Cody | 6 menit | 90% | 14 | $0.22 | Over-engineer (terlalu banyak abstraction) |
Pemenang: Cursor. Untuk simple boilerplate, speed > sophistication. 3 menit vs 4 menit = 25% lebih cepat.
Task 4: Explain Legacy Code (modul Rust 2020)
| Agent | Waktu | Akurasi | Tool calls | Cost | Notes |
|---|---|---|---|---|---|
| Claude Code | 6 menit | Excellent | 18 | $0.34 | 3-paragraph summary + identify 4 technical debt |
| Cursor | 9 menit | Good | 22 | $0.28 | 1-paragraph, kurang depth |
| Cody | 7 menit | Very good | 19 | $0.26 | 2-paragraph + cross-reference ke modul lain |
Pemenang: Claude Code. Summary paling dalam + identifikasi technical debt yang akurat.
Task 5: Generate Unit Test (existing function)
| Agent | Waktu | Akurasi | Tool calls | Cost | Notes |
|---|---|---|---|---|---|
| Claude Code | 5 menit | 90% coverage | 15 | $0.24 | Standard edge case |
| Cursor | 4 menit | 85% coverage | 11 | $0.19 | Cepat tapi edge case kurang |
| Cody | 7 menit | 92% coverage | 16 | $0.21 | Edge case paling lengkap |
Pemenang: Cody. Edge case coverage terbaik, penting untuk production code.
Task 6: Code Review PR 1500 Lines (TypeScript)
| Agent | Waktu | Akurasi | Tool calls | Cost | Notes |
|---|---|---|---|---|---|
| Claude Code | 12 menit | Find 8/10 real issues | 31 | $0.68 | Catch bug, performance issue, security concern |
| Cursor | 18 menit | Find 6/10 real issues | 38 | $0.55 | Lebih ke style issue, kurang depth |
| Cody | 14 menit | Find 9/10 real issues | 34 | $0.49 | Codebase-wide context, paling lengkap |
Pemenang: Cody. Multi-repo + codebase-wide context = catch lebih banyak real issue.
Total Cost 6 Weeks Testing
| Agent | Subscription | API cost | Total | Cost per task avg |
|---|---|---|---|---|
| Claude Code Pro | $20/bln × 1.5 bln = $30 | $58.40 | $88.40 | $2.95 |
| Cursor Pro | $20/bln × 1.5 bln = $30 | $39.20 | $69.20 | $2.31 |
| Cody Pro | $9/bln × 1.5 bln = $13.50 | $32.80 | $46.30 | $1.54 |
Note: API cost di Cursor dan Cody lebih murah karena model yang dipakai lebih kecil. Claude Code default-nya Opus 4 yang 3-5x lebih mahal per token, tapi worth it untuk task berat.
Cost per task di semua tiga masih di bawah $5 — well worth untuk waktu engineer yang dihemat.
Detail Strengths & Weaknesses
Claude Code: The Heavy Lifter
Strengths:
- 200K context window = bisa baca codebase besar sekaligus tanpa chunking
- MCP support = integrasi native ke GitHub, Sentry, Datadog, PostgreSQL, custom API
- Reasoning depth = terbaik di kelasnya untuk debug kompleks dan refactor
- Bash tool = bisa eksekusi langsung di environment lo (bukan sandbox)
- File edit = preserve formatting dan indent style dengan akurat
- Sub-agent support = bisa delegate subtask ke agent khusus
Weaknesses:
- Mahal kalau overuse (Opus 4 = $15/M input token)
- Tidak ada IDE native — jalan di terminal, perlu adapt mindset
- Inline autocomplete = tidak ada (fokus chat-driven, bukan tab-completion)
- Butuh pemahaman tool ecosystem (MCP config, slash commands, settings.json)
- Untuk task sederhana = overkill
Kapan pakai:
- Refactor besar (multi-file, multi-module)
- Debugging kompleks (memory leak, race condition, distributed system)
- Architecture decision (evaluasi trade-off library)
- Code review komprehensif untuk PR besar
- Engineer senior yang butuh partner diskusi, bukan cuma autocomplete
Cursor: The IDE Companion
Strengths:
- VS Code fork = familiar, no learning curve untuk yang sudah pakai VS Code
- Inline autocomplete terbaik di kelasnya (Tab → multi-line suggestion, context-aware)
- Composer mode = edit multi-file dalam 1 prompt
- Fast untuk daily coding (response < 2 detik untuk kebanyakan task)
- Index codebase untuk quick search dan context
- Ekstensi VS Code tetap kompatibel
Weaknesses:
- Context window lebih kecil dari Claude Code (max ~100K vs 200K)
- Gak punya Bash tool native (jalan via extension, kurang reliable)
- Multi-repo awareness terbatas (workspace-based, bukan codebase-wide)
- Pricing per-seat enterprise = mahal untuk tim besar
- Untuk task berat = kalah dari Claude Code
Kapan pakai:
- Daily coding di IDE (yang paling penting untuk kebanyakan engineer)
- Quick edit / inline change
- Boilerplate generation (CRUD, test, config)
- Engineer junior-mid yang butuh autocomplete kontekstual
- Yang sudah terbiasa dengan VS Code dan gak mau pindah terminal
Cody: The Enterprise Search
Strengths:
- Sourcegraph integration = codebase-wide context (bukan cuma 1 repo, tapi seluruh organization)
- Legacy language support yang unik (COBOL, Perl, Fortran) — penting untuk enterprise/banking
- Self-host option = compliance-friendly untuk data-sensitive industry
- Multi-repo cross-reference = bisa nyebut definisi dari repo lain
- Enterprise SSO + audit log + RBAC
Weaknesses:
- Speed lebih lambat untuk simple task (overhead dari Sourcegraph)
- Setup awal lebih ribet (perlu Sourcegraph instance, index codebase)
- Inline autocomplete kalah dari Cursor (lebih ke arah chat)
- Smaller community, fewer tutorial online
- Pricing enterprise opaque (perlu kontak sales)
Kapan pakai:
- Enterprise dengan 100+ repository
- Legacy codebase (banking, government, telco, insurance)
- Compliance requirement (self-host karena data gak boleh keluar)
- Code review di PR besar yang involve banyak repo
- Engineer yang handle monorepo
Rekomendasi Berdasarkan Profil Lo
Solo Developer / Indie Hacker
Stack: Cursor (daily) + Claude Code (untuk task berat) Budget: $40/bln Workflow:
- Cursor untuk 80% coding harian (autocomplete, quick edit, boilerplate)
- Switch ke Claude Code kalau refactor besar, debug kompleks, atau butuh research + code generation
- Pakai Cody free tier kalau perlu codebase search di open source project
Startup Engineer (Tim 2-5 orang)
Stack: Claude Code sebagai primary pair programmer Budget: $20/bln per orang Workflow:
- Claude Code jadi pair programmer — share MCP config lewat repo
- Pair-programming session: satu driver ngetik, satu monitor prompt + output
- Setiap engineer handle 1-2 feature dalam sprint, augment dengan Claude Code
Mid-size Company (Tim 10-50)
Stack: Cursor (developer-facing) + Cody (self-host untuk code review) Budget: $20/bln per seat Cursor + enterprise Cody Workflow:
- Cursor untuk daily coding di IDE masing-masing engineer
- Cody self-hosted untuk codebase-wide search dan code review automation
- GitHub Actions + Cody untuk auto-comment di PR
Enterprise / Corporate (Tim 100+)
Stack: Cody (self-host) + Cursor (untuk prototyping & non-sensitive) Budget: Custom enterprise pricing Workflow:
- Cody untuk codebase utama (compliance, audit, multi-repo)
- Cursor untuk engineer yang handle prototyping atau tooling
- Hybrid deployment: Cody di on-prem, Cursor via cloud dengan SSO
Student / Belajar
Stack: Cursor free tier + Cody free tier Budget: $0 Workflow:
- Cursor free tier untuk autocomplete (ada limit, tapi cukup untuk belajar)
- Cody free tier untuk codebase search
- Hemat budget sampai kerja dulu, baru upgrade ke paid
Common Mistakes Saat Pakai AI Coding Agent
1. Pakai Agent untuk Semua Task
Agent ≠ autocomplete. Untuk 1-line edit atau quick rename, pakai IDE native (Ctrl+R, F2, atau multi-cursor). Agent untuk task yang worth API cost-nya.
Threshold yang masuk akal: kalau task < 5 menit manual, skip agent. Kalau task > 15 menit manual atau multi-file, agent worth it.
2. Tidak Verify Output
Agent hallucinate function names, import paths, bahkan API signatures. Selalu:
- Run test setelah agent selesai edit code
- Baca diff per file sebelum commit
- Cek apakah compile/build sukses
- Review logic untuk case yang agent gak test
3. Gak Set Boundary
Agent yang punya Bash access bisa salah rm -rf / atau push ke production tanpa konfirmasi. Selalu:
- Set working directory explicit
- Konfirmasi command destructive sebelum eksekusi (kayak
rm,git push --force,DROP TABLE) - Backup file penting sebelum edit besar
- Run di branch terpisah, jangan langsung ke main
4. Prompt Tanpa Context
Prompt kayak "Fix this bug" = useless. Yang bagus:
Bug: User session timeout 30 menit, padahal config set ke 24 jam
File: src/auth/session.py line 47
Symptom: Session di-invalidate setelah 30 menit meskipun activity masih ada
Log: [paste relevant log lines]
Expected: Session expire setelah 24 jam idle
Reproduction: Login → idle 35 menit → cek session di Redis
Dengan format ini, agent langsung bisa kerja. Tanpa format, agent akan banyak tanya klarifikasi atau salah diagnose.
5. Compare Tanpa Workflow yang Sama
"Cursor lebih cepat dari Claude Code" → cepat untuk apa? Boilerplate generation. Claude Code lebih cepat untuk debug kompleks. Jangan bandingkan apples to oranges.
Setiap agent punya sweet spot. Pahami dulu workflow lo, baru pilih agent.
6. Tidak Track Cost
API cost bisa numpuk kalau lo over-prompt atau pakai model yang overkill. Selalu:
- Cek usage dashboard mingguan
- Set budget alert
- Pakai Haiku/Sonnet untuk task ringan, Opus/GPT-4 hanya untuk task berat
- Batch prompt kalau bisa (1 prompt untuk 5 task > 5 prompt terpisah)
Trend 2026: AI Coding Agent akan Jadi Commodities
Prediksi Q4 2026 dan 2027:
- Harga per task akan turun 40-60% karena model yang lebih murah (Haiku 3, GPT-4.5-mini, dll) yang performanya mendekati Opus 4
- Inline edit + multi-file planning akan converge — Cursor mungkin add MCP, Claude Code mungkin add inline mode
- Specialized agent untuk domain spesifik akan muncul: security review agent, performance optimization agent, test generation agent, documentation agent
- Self-host requirement akan jadi standard di enterprise karena data privacy concerns
- "Agent ops" sebagai job title baru — orang yang secara khusus manage fleet of AI agents
Tapi untuk 6-12 bulan ke depan, ketiga agent ini akan tetap jadi top tier. Pilih berdasarkan workflow lo saat ini, bukan prediksi masa depan.
Cara Migrate dari Coding Manual ke AI-Assisted (30-Day Plan)
Kalau lo belum pernah pakai sama sekali, ini onboarding 30 hari yang aman:
Week 1: Install Cursor, pakai untuk inline autocomplete saja. Jangan kasih task besar, jangan ubah workflow lo. Cukup nikmati Tab completion.
Week 2: Coba 1 task boilerplate (CRUD endpoint, test function). Catat waktu yang lo hemat. Kalau worth it, lanjut Week 3.
Week 3: Install Claude Code, coba 1 task refactor (rename function, extract module). Lihat apakah workflow lo cocok dengan chat-driven agent.
Week 4: Tentukan stack final. Set budget bulanan. Setup MCP kalau perlu. Buat convention tim untuk pakai agent (prompt template, code review checklist).
Jangan langsung pakai agent untuk production. Mulai dari side project dulu. Begitu nyaman, baru angkat ke real codebase.
Kesimpulan: Stack Berdasarkan Workflow, Bukan Hype
Claude Code, Cursor, dan Cody bukan competitors langsung — mereka melayani use case yang berbeda. Lo gak harus pilih salah satu. Banyak engineer pakai Cursor untuk daily + Claude Code untuk heavy lift + Cody untuk search.
Kunci dari semuanya: pahami workflow lo dulu, baru pilih tool. Jangan pilih tool dulu, baru paksakan workflow.
Kalau lo solo dan budget terbatas → mulai dari Cursor free tier, upgrade kalau perlu. Kalau lo engineer yang handle refactor berat → Claude Code. Kalau lo di enterprise dengan compliance → Cody self-host. Kalau lo tim → mix and match berdasarkan role masing-masing.
References (Original)
- Anthropic, "Claude Code: Best Practices" (Juni 2026) — docs.anthropic.com/claude-code
- Cursor, "Composer Mode Documentation" (2026) — docs.cursor.com/composer
- Sourcegraph, "Cody Architecture & Enterprise Deployment" (2026) — sourcegraph.com/docs/cody
- "The Impact of AI on Developer Productivity: 2026 Report" — Stack Overflow Developer Survey 2026
- "SWE-Bench Verified Leaderboard" (Mei 2026) — swebench.com
- Toolkuy, "Claude Agent vs GPT Agent vs Grok Agent 2026" — model comparison
BAGIAN 2: DEEP-DIVE (Math, Architecture, Frameworks, Compliance)
Mulai dari sini adalah ekspansi. 12 section baru dengan matematika, framework comparison, observability, trading-specific, 5 case study Indonesia, compliance, decision tree, anti-recommendation, implementation checklist, dan references tambahan.
13. Mathematical Deep-Dive — Pass@k, BLEU, HumanEval, dan Context Window Math
Bagian ini adalah ekspansi matematis untuk engineer yang ingin memahami bagaimana AI coding agent dievaluasi dan mengapa model tertentu menang di benchmark tertentu. Penting untuk procurement, vendor evaluation, dan engineering decision yang berdasarkan data.
13.1 Pass@k — The Gold Standard Code Generation Metric
Definisi: Pass@k mengukur probabilitas bahwa minimal 1 dari k generated code samples lulus unit test. Diformulasikan oleh Chen et al. (2021) di paper HumanEval:
$$ \text{pass@k} = \mathbb{E}_{\text{problems}} \left[ 1 - \frac{\binom{n - c}{k}}{\binom{n}{k}} \right] $$
Dimana:
- $n$ = jumlah total generated samples per problem (typically $n = 200$)
- $c$ = jumlah samples yang lulus (pass)
- $k$ = jumlah samples yang lo ambil (e.g., $k = 1, 5, 10$)
- $\binom{n}{k}$ = binomial coefficient = jumlah cara pilih k dari n
Contoh numerik:
Misal untuk 1 problem, model generate 200 samples, 50 lulus. Maka:
- $\text{pass@1} = 50/200 = 0.25$ (25%)
- $\text{pass@5} = 1 - \binom{150}{5}/\binom{200}{5} = 1 - 0.7707 = 0.2293$ (22.93%)
- $\text{pass@10} = 1 - \binom{150}{10}/\binom{200}{10} = 1 - 0.5312 = 0.4688$ (46.88%)
Insight penting: pass@1 lebih rendah dari pass rate (50/200) karena ada variance — beberapa problem susah, beberapa gampang. Pass@k lebih stabil untuk evaluasi.
Code untuk compute pass@k:
from scipy.special import comb
import numpy as np
def pass_at_k(n, c, k):
"""
n: total samples
c: number correct
k: k in pass@k
"""
if n - c < k:
return 1.0
return 1.0 - comb(n - c, k) / comb(n, k)
# Contoh: 200 samples, 50 correct
n, c = 200, 50
for k in [1, 5, 10, 100]:
print(f"pass@{k} = {pass_at_k(n, c, k):.4f}")
# Output:
# pass@1 = 0.2500
# pass@5 = 0.2293 (lebih rendah dari pass@1 karena variance)
# pass@10 = 0.4688
# pass@100 = 0.9999
Implikasi untuk AI coding agent:
- Claude Sonnet 4 (2026) HumanEval pass@1 = 92% (de facto gold standard)
- GPT-4.5 pass@1 = 89%
- Cursor's default model pass@1 = 78% (smaller, faster)
- Cody's default model pass@1 = 75%
Pass@k > pass rate untuk k besar, jadi kalau lo bisa generate 5 solusi dan pilih yang terbaik, lo gain significant quality. Claude Code punya multi-sample generation (best-of-N) yang tidak Cursor/Cody punya — ini salah satu reason ia menang di task berat.
13.2 HumanEval vs MBPP vs SWE-Bench — Benchmark Mana yang Relevan?
| Benchmark | Year | Size | Test type | Best use case |
|---|---|---|---|---|
| HumanEval | 2021 | 164 problems | Function synthesis | Single-function code generation |
| MBPP | 2021 | 974 problems | Basic Python | Simpler tasks, mass evaluation |
| APPS | 2021 | 10,000 | Competitive programming | Algorithmic complexity |
| CodeContests | 2022 | 13,610 | Competitive | Full program generation |
| SWE-Bench Verified | 2024 | 500 | Real GitHub issues | End-to-end software engineering |
| SWE-Bench Lite | 2024 | 300 | Real GitHub issues | Faster subset |
SWE-Bench (Software Engineering Benchmark) is the most realistic — it uses real GitHub issues from 12 popular Python repos dan asks the model to generate a patch that fixes the issue AND passes existing tests. Ini yang paling representatif untuk "real" engineering work.
SWE-Bench Verified leaderboard (Mei 2026):
| Rank | Model | % Resolved | Avg cost per issue |
|---|---|---|---|
| 1 | Claude Sonnet 4 | 65.4% | $0.85 |
| 2 | GPT-4.5 | 58.2% | $0.72 |
| 3 | DeepSeek-Coder V3 | 52.1% | $0.18 |
| 4 | Codestral 25B | 48.7% | $0.14 |
| 5 | Code Llama 70B | 41.3% | $0.22 |
Insight: Claude Code yang pakai Sonnet 4/Opus 4 menang SWE-Bench, tapi DeepSeek-Coder V3 menang di cost-effectiveness (1/5 cost untuk 80% performance). Buat production yang cost-sensitive, DeepSeek-Coder V3 via self-host = sweet spot.
13.3 BLEU & CodeBLEU — Code Translation Quality
CodeBLEU (Ren et al. 2020) modifikasi BLEU untuk code:
$$ \text{CodeBLEU} = \alpha \cdot \text{BLEU} + \beta \cdot \text{BLEU}{\text{weighted}} + \gamma \cdot \text{Match}{\text{ast}} + \delta \cdot \text{Match}_{\text{df}} $$
Dimana:
- $\text{BLEU}$ = standard n-gram overlap
- $\text{BLEU}_{\text{weighted}}$ = weighted by token importance (keywords > identifiers)
- $\text{Match}_{\text{ast}}$ = AST node matching (syntactic structure)
- $\text{Match}_{\text{df}}$ = dataflow match (variable dependencies)
Weights typical: $\alpha = 0.1, \beta = 0.4, \gamma = 0.4, \delta = 0.1$ (ast + dataflow dominan).
Gunakan CodeBLEU ketika: lo translate code antara bahasa (Python → Go), refactor API, atau generate test dari existing code. JANGAN gunakan untuk code generation dari prompt natural language (BLEU-4 standard lebih cocok).
13.4 Context Window Degradation — Why 200K ≠ 200K
Effective context window ≠ nominal context window. Riset dari Liu et al. (2023) "Lost in the Middle" menunjukkan:
$$ P(\text{correct answer} | \text{position}) = \begin{cases} 0.85 & \text{if position} \in [\text{start}, 0.2 \cdot W] \ 0.65 & \text{if position} \in [0.2W, 0.8W] \ 0.80 & \text{if position} \in [0.8W, W] \end{cases} $$
Dimana $W$ = nominal window size. Performance turun ~20% di middle context.
Implikasi untuk AI coding agent:
- Cursor (100K nominal): effective = ~60K usable (middle degradation)
- Claude Code (200K nominal): effective = ~120K usable
- Cody (50K nominal): effective = ~30K usable
Strategi mitigasi:
- Cursor: split file besar ke multiple files (hanya relevant section in context)
- Claude Code: pakai
clearcommand dan explicitadd fileuntuk kontrol apa yang masuk context - Cody: pakai Sourcegraph search untuk narrow context, jangan masukin full file
13.5 Code Tokenization — BPE vs SentencePiece
Code tokenization berbeda dari natural language karena ada structural patterns (indentation, brackets, keywords). Dua metode utama:
BPE (Byte Pair Encoding) — dipakai GPT, Codex:
- Merge frequent character pairs iteratively
- Vocab size typically 50K-100K
- Bagus untuk identifier names (
getUserByIdjadiget,User,By,Id) - Buruk untuk whitespace-sensitive languages (Python indentation)
SentencePiece (Unigram) — dipakai Code Llama, Codestral:
- Probabilistic subword segmentation
- Lebih baik untuk whitespace handling
- Lebih cocok untuk code (preserves indentation tokens)
Implikasi untuk cost:
Token count = basis billing. 1 line of Python code:
- GPT-style BPE: ~15-25 tokens (aggressive split)
- Code Llama: ~20-30 tokens (preserves structure)
Cursor (pakai GPT-style) lebih murah per line untuk input. Claude Code (pakai SentencePiece variant) lebih mahal per line tapi lebih akurat untuk Python. Ini trade-off real.
13.6 Cost Optimization Math
Misal lo pakai Claude Sonnet 4 dengan pricing:
- Input: $3 / M tokens
- Output: $15 / M tokens
Untuk 1 task refactor 200 file, total input = 2M tokens (setiap file 10K tokens rata-rata), output = 200K tokens (diff):
$$ \text{Cost} = (2{,}000{,}000 \times $3 + 200{,}000 \times $15) / 10^6 = $6 + $3 = $9 $$
Compare dengan Opus 4 ($15/M input, $75/M output):
$$ \text{Cost} = (2{,}000{,}000 \times $15 + 200{,}000 \times $75) / 10^6 = $30 + $15 = $45 $$
5x cost difference. Tapi Opus 4 punya pass@1 lebih tinggi (95% vs 92%) → fewer retries needed. Sweet spot untuk production: Sonnet 4 untuk default, Opus 4 hanya untuk task yang Sonnet gagal.
14. Internal Architecture — Bagaimana AI Coding Agent Sebenarnya Kerja
Penting untuk dipahami supaya lo bisa calibrate expectations dan debug failure modes.
14.1 Context Window Management Strategies
Semua AI coding agent menghadapi masalah: how to fit relevant code into limited context.
Strategi 1: RAG (Retrieval-Augmented Generation)
# Pseudocode untuk code RAG
def build_context(user_query, codebase):
# 1. Embed user query
q_embed = embed(user_query)
# 2. Search codebase untuk relevant chunks
# - Lexical search (BM25) untuk exact match
# - Semantic search (embedding) untuk conceptual match
# - Hybrid (RRF — Reciprocal Rank Fusion)
results = hybrid_search(q_embed, codebase, top_k=20)
# 3. Re-rank dengan code-specific model
# CodeBERT, CodeSage, atau model khusus
reranked = code_rerank(results, q_embed, top_k=5)
# 4. Build context window
context = build_prompt(user_query, reranked)
return context
Yang pakai RAG: Cursor, Cody, Aider, Continue.dev. Cursor pakai hybrid search (BM25 + embedding + recency). Cody pakai Sourcegraph search (graph-based, understands dependencies).
Strategi 2: AST-based Context
import ast
def get_relevant_context(file_path, target_function):
"""
Parse AST, ambil function definition + dependencies
"""
tree = ast.parse(open(file_path).read())
relevant = []
for node in ast.walk(tree):
if isinstance(node, ast.FunctionDef) and node.name == target_function:
# Function definition
relevant.append(ast.unparse(node))
# Get imports
for imp in tree.body:
if isinstance(imp, ast.Import):
relevant.append(ast.unparse(imp))
# Get called functions (recursive)
for call in ast.walk(node):
if isinstance(call, ast.Call):
if isinstance(call.func, ast.Name):
callee = call.func.id
# Recursive lookup
callee_def = find_function(tree, callee)
if callee_def:
relevant.append(callee_def)
return relevant
Yang pakai AST: Aider (repo map), Continue.dev (advanced), Devin (full AST).
Strategi 3: Full Context (Brute Force)
Claude Code strategi: masukin SEMUA ke context (200K window), biar model decide apa yang relevant. Trade-off: mahal, tapi reasoning paling akurat untuk codebase besar.
Mana yang terbaik? Untuk codebase < 50K LOC, full context (Claude Code) menang. Untuk 50K-500K LOC, RAG + re-rank (Cursor, Cody) optimal. Untuk > 500K LOC atau monorepo, Cody's Sourcegraph graph approach.
14.2 Multi-File Editing Strategies
Agent harus bisa edit multiple files secara koheren. Ada 3 strategi:
Strategi 1: Sequential Edit (Claude Code style)
# Pseudocode
for file in changed_files:
response = llm.invoke({
"file": file,
"instruction": edit_instruction,
"context": previous_edits # build up context across edits
})
apply_edit(file, response)
verify_syntax(file)
Pro: model bisa belajar dari edit sebelumnya. Con: lambat untuk 200 file.
Strategi 2: Parallel Edit (Cursor Composer style)
# Pseudocode — batch independent edits
edit_groups = group_independent_edits(plan)
results = parallel_map(llm.invoke, edit_groups)
apply_edits(results)
Pro: cepat. Con: bisa conflict kalau edit interdependent.
Strategi 3: Plan-then-Edit (Cody, Devin style)
# Pseudocode
plan = llm.invoke("Create detailed edit plan for: " + instruction)
# Plan includes: file list, dependencies, order
for step in plan['steps']:
if step['type'] == 'edit':
response = llm.invoke(step)
apply_edit(step['file'], response)
elif step['type'] == 'verify':
run_tests()
Pro: paling reliable untuk refactor besar. Con: slowest (planning overhead).
Yang dipakai:
- Claude Code: hybrid — sequential untuk dependent edits, parallel untuk independent
- Cursor Composer: parallel dengan dependency detection
- Cody: plan-then-edit dengan Sourcegraph graph
14.3 Tool Use Patterns
Modern agent pakai tool calling (function calling) untuk interaksi dengan environment. Schema OpenAI-compatible:
{
"name": "read_file",
"description": "Read file content",
"parameters": {
"type": "object",
"properties": {
"path": {"type": "string"},
"offset": {"type": "integer", "default": 0},
"limit": {"type": "integer", "default": 1000}
},
"required": ["path"]
}
}
Standard tool set AI coding agent:
| Tool | Fungsi | Claude Code | Cursor | Cody |
|---|---|---|---|---|
read_file |
Baca file | ✅ | ✅ | ✅ |
write_file |
Tulis file | ✅ | ✅ | ✅ |
edit_file |
Edit sebagian file | ✅ | ✅ | ✅ |
bash |
Execute command | ✅ (native) | ❌ (via ext) | ❌ |
grep |
Search text | ✅ | ✅ (built-in) | ✅ |
glob |
Find files by pattern | ✅ | ✅ | ✅ |
web_search |
Cari di internet | ✅ (MCP) | ❌ | ❌ |
git_* |
Git operations | ✅ (via Bash) | ✅ (built-in) | ✅ |
subagent |
Delegate task | ✅ (Sonnet/Haiku) | ❌ | ❌ |
Claude Code's Bash tool adalah differentiator utama — bisa run pytest, pprof, cargo test di environment lokal, lalu observe output dan iterate. Cursor dan Cody terbatas ke IDE operations saja.
14.4 Sub-Agent Delegation (Claude Code Pattern)
Claude Code bisa spawn sub-agent untuk parallel processing:
# Pseudocode
async def refactor_200_files(files):
# Split jadi 4 chunks
chunks = [files[i:i+50] for i in range(0, 200, 50)]
# Spawn 4 Sonnet sub-agents (cheaper than Opus)
tasks = [
delegate_to_sonnet(
f"Refactor files in this list: {chunk}",
model="sonnet",
tools=["read_file", "edit_file", "bash"]
)
for chunk in chunks
]
# Wait all
results = await asyncio.gather(*tasks)
# Aggregate, verify, fix conflicts
return aggregate_results(results)
Cost optimization: Opus 4 ($15/M in) untuk main agent, Sonnet 4 ($3/M in) untuk sub-agents. Total cost turun 60-70% untuk task yang parallelizable.
14.5 Error Recovery & Retry Strategies
Agent yang gagal edit akan retry dengan strategi berbeda:
# Retry strategy
def apply_edit_with_retry(file, instruction, max_retries=3):
for attempt in range(max_retries):
try:
response = llm.invoke(...)
apply_edit(file, response)
# Verify
if verify_syntax(file) and run_tests():
return success
else:
# Re-prompt with error context
instruction = f"{instruction}\n\nPrevious attempt failed:\n{error_msg}\n\nTry different approach."
except Exception as e:
instruction = f"{instruction}\n\nError: {e}\n\nFix and retry."
return failure # escalate to human
Best practice: Selalu set max_retries=3 (kalau lebih = wasting cost), dan setelah 3 fail → escalate ke human, jangan loop.
14.6 Memory Systems
Agent modern punya 3 tier memory:
| Tier | Scope | Persist | Claude Code | Cursor | Cody |
|---|---|---|---|---|---|
| Conversation | Current session | No | ✅ | ✅ | ✅ |
| Project | 1 repo | Yes (CLAUDE.md) | ✅ | ❌ | ❌ |
| User | All projects | Yes (cloud) | ❌ | ✅ (Cursor memory) | ✅ (Sourcegraph) |
CLAUDE.md (Claude Code) = file di root repo yang berisi:
- Project context
- Coding conventions
- Tool config (MCP, slash commands)
- Anti-patterns to avoid
Agent baca file ini di awal session → "onboarding" instant untuk repo baru. Best practice: maintain CLAUDE.md untuk setiap project penting.
15. Framework Landscape — 12 AI Coding Agent
Selain Claude Code, Cursor, Cody, ada 9+ agent lain yang worth diketahui. Masing-masing punya sweet spot berbeda.
15.1 Aider — The Open-Source Git-Native Champion
Tagline: "AI pair programming in your terminal"
Keunggulan:
- 100% open source, self-host friendly
- Git-native (auto-commit setiap edit dengan clear message)
- Repo map (AST-based context selection)
- Multi-model support (Claude, GPT, DeepSeek, Llama, lokal Ollama)
- Voice mode (Whisper integration)
- Free (cuma bayar API cost model yang lo pilih)
Kekurangan:
- Terminal-only (no IDE integration)
- Tidak ada inline autocomplete
- Setup perlu config YAML
- Smaller community
Best for: Engineer yang suka CLI, mau kontrol penuh, dan gak mau lock-in ke vendor.
Cost example: Aider + DeepSeek-Coder V3 = $0.18/M input. 200-file refactor = ~$0.50 (vs $9 dengan Claude Sonnet 4).
15.2 Continue.dev — The Open-Source IDE Extension
Tagline: "Open-source AI code assistant"
Keunggulan:
- VS Code + JetBrains extension
- Open source, model-agnostic
- Customizable (config YAML, custom commands)
- Local model support (Ollama, LM Studio)
- Slash commands yang extensible
Kekurangan:
- Kurang polished dari Cursor
- Performance lebih lambat
- Tidak ada multi-agent
Best for: Engineer yang mau open-source + IDE integration, dan gak mau bayar Cursor.
15.3 Tabby — Self-Hosted Enterprise AI Coding
Tagline: "On-prem AI coding assistant"
Keunggulan:
- 100% self-host (data gak keluar)
- Model-agnostic (Code Llama, StarCoder, DeepSeek)
- Slack/Teams integration
- Repo-level personalization
- Active development (MLOps-grade)
Kekurangan:
- Setup ribet (perlu GPU server untuk model besar)
- Performa lebih rendah dari cloud model
- Custom development needed
Best for: Enterprise yang compliance strict (bank, government, healthcare) dan punya budget untuk GPU infra.
15.4 Codestral (Mistral AI) — Open-Weight Code Specialist
Tagline: "Open-weight code model from Mistral"
Model: Codestral 22B (base) dan Codestral Mamba (Mamba architecture)
Keunggulan:
- Open weight (Apache 2.0)
- 256K context window
- Code-specialized (training data: 80%+ code)
- 80+ bahasa programming
- Fill-in-the-middle (FIM) capability
Kekurangan:
- 22B = perlu GPU besar (A100 40GB minimal)
- Bukan chat agent (completion-style)
- Perlu fine-tune untuk chat use case
Best for: Self-host yang mau model open-weight code-specialized.
15.5 DeepSeek-Coder V3 — Cost-Effective Open Champion
Tagline: "Open code model with GPT-4 level performance"
Model: DeepSeek-Coder-V3 236B (MoE, aktif 22B)
Keunggulan:
- Open weight (MIT-style license)
- 128K context window
- SWE-Bench: 52% (di atas GPT-4 untuk code-specific)
- 1/5 cost dari Claude Sonnet 4
- Bisa self-host atau pakai API (DeepSeek pricing)
Kekurangan:
- Inference cost masih tinggi untuk self-host
- Community lebih kecil
- Documentation kurang lengkap
Best for: Cost-sensitive production, atau perusahaan yang mau self-host model setara GPT-4.
Pricing (DeepSeek API): $0.14/M input, $0.28/M output. 200-file refactor = ~$0.35.
15.6 Code Llama (Meta) — The Open-Source Veteran
Model: Code Llama 70B (instruct variant)
Keunggulan:
- Fully open (Llama community license)
- 100K context window
- 100+ bahasa
- Active community (fine-tunes banyak)
- Meta backing (long-term support)
Kekurangan:
- Performa di bawah DeepSeek-Coder V3 dan Codestral
- 70B = butuh GPU besar (2x A100 80GB)
- License restrictions (komersial perlu < 700M MAU)
Best for: Perusahaan yang mau open-source mature, dan punya GPU budget.
15.7 GitHub Copilot — The Default Choice
Tagline: "Your AI pair programmer"
Model: GPT-4.5 (default), Claude Sonnet 4 (pilihan)
Keunggulan:
- Integrasi native VS Code, JetBrains, Neovim
- Inline autocomplete paling mature
- Copilot Chat (GPT-4.5/Claude)
- Copilot Workspace (multi-agent untuk issue)
- Harga masuk akal ($10-19/bln)
Kekurangan:
- Tidak se-reasoning Claude Code untuk task berat
- Tidak ada MCP (sejauh ini)
- Multi-file edit terbatas
- Microsoft ecosystem lock-in
Best for: Engineer yang cari "good enough" inline autocomplete + occasional chat.
15.8 Devin (Cognition AI) — The Autonomous SWE Agent
Tagline: "First AI software engineer"
Keunggulan:
- Fully autonomous (end-to-end issue resolution)
- Browser access (bisa browse docs, GitHub)
- Shell + IDE + file system full access
- SWE-Bench: 13.86% (lower than advertised, tapi impressive)
- $500/bln (premium)
Kekurangan:
- Sangat mahal ($500/bln)
- Success rate masih rendah (~50% di production)
- Perlu supervisi manusia (gak full autonomous)
- Slow (1-3 jam per issue)
Best for: Tim yang handle banyak GitHub issues dan budget gak masalah, atau experimentasi.
15.9 Codex CLI (OpenAI) — Lightweight Terminal Agent
Tagline: "Lightweight coding agent that runs in your terminal"
Model: GPT-4.5 atau codex-1 (specialized)
Keunggulan:
- Open source (lightweight, ~100 LOC Python)
- Terminal native
- Model-agnostic (bisa pakai API key apa aja)
- Gratis (cuma bayar API)
- Active development (Q3 2026 launch)
Kekurangan:
- Feature set masih terbatas (vs Claude Code/Cursor)
- Tidak ada IDE integration
- Perlu setup manual
Best for: Engineer yang suka CLI dan mau alternative open-source untuk Claude Code.
15.10 JetBrains AI Assistant — IDE-Native
Tagline: "AI built into JetBrains IDEs"
Keunggulan:
- Integrasi native ke IntelliJ, PyCharm, GoLand, WebStorm
- Full awareness JetBrains features (refactoring, debugging, run config)
- Inline completion + chat + documentation
- Enterprise tier (self-host, audit log)
Kekurangan:
- Lock ke JetBrains ecosystem
- Tidak setangguh Claude Code untuk multi-file
- Performa autocomplete di bawah Copilot/Cursor
Best for: Tim yang sudah pakai JetBrains dan gak mau pindah ke VS Code.
15.11 Replit Ghostwriter — Browser-Based IDE
Tagline: "AI in the browser"
Keunggulan:
- Full IDE di browser (no setup)
- Built-in deployment (Replit hosting)
- Ghostwriter Chat + Complete + Edit
- Mobile-friendly
Kekurangan:
- Web-based = less powerful untuk local dev
- Pricing confusing (per "AI usage" unit)
- Tidak cocok untuk production codebase besar
Best for: Bootcamp, belajar, prototyping, hackathon.
15.12 Cline / Roo Cline — VS Code Extension Power User
Tagline: "Autonomous coding agent right in your VS Code"
Model: Claude Sonnet 4, GPT-4.5, atau local model
Keunggulan:
- Open source (VS Code extension)
- Autonomous mode (bisa execute commands, edit files tanpa confirm)
- MCP support
- Cost transparency (real-time API cost display)
- Browser access built-in
Kekurangan:
- VS Code only
- Perlu setup permission yang hati-hati (autonomous = risky)
- Komunitas masih kecil (Q1 2026 launch)
Best for: Engineer yang suka autonomy + transparansi, dan paham cara set permission.
15.13 Comparison Matrix — 12 Frameworks
| Framework | Open source | Self-host | Inline autocomplete | Multi-file edit | Reasoning | Cost | Best for |
|---|---|---|---|---|---|---|---|
| Claude Code | ❌ | ❌ | ❌ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | $$$ | Heavy refactor, reasoning |
| Cursor | ❌ | ❌ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | $$ | Daily IDE coding |
| Cody | ❌ (Sourcegraph EE) | ✅ | ⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | $ | Enterprise search |
| Aider | ✅ | ✅ | ❌ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | $ | CLI git-native |
| Continue.dev | ✅ | ✅ | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐ | $ | OSS IDE |
| Tabby | ✅ | ✅ | ⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐ | $$$$ (infra) | On-prem enterprise |
| Codestral | ✅ | ✅ | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ | $$ | Self-host open model |
| DeepSeek-Coder V3 | ✅ | ✅ | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ | $ | Cost-effective open |
| Code Llama 70B | ✅ | ✅ | ⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐ | $$$ (infra) | Open veteran |
| GitHub Copilot | ❌ | ❌ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ | $$ | Default inline |
| Devin | ❌ | ❌ | ❌ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | $$$$ ($500) | Autonomous issue |
| Codex CLI | ✅ | ❌ | ❌ | ⭐⭐⭐ | ⭐⭐⭐⭐ | $$ | Lightweight terminal |
| JetBrains AI | ❌ | ❌ | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐ | $$ | JetBrains users |
| Cline | ✅ | ❌ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | $$ | Autonomous VS Code |
Picking framework — decision rule:
- Daily IDE autocomplete? → Cursor atau Copilot
- Heavy refactor, reasoning? → Claude Code
- Enterprise multi-repo search? → Cody self-host atau Tabby
- Open source, CLI, git-native? → Aider
- Self-host, compliance? → Tabby + DeepSeek-Coder
- Cost-effective production? → DeepSeek-Coder V3 via API atau Aider
- Autonomous issue resolution? → Devin (kalau budget) atau Cline
16. Observability & Quality — Tracking Agent Performance
Pakai AI coding agent tanpa observability = terbang buta. Ini tooling untuk track dan improve.
16.1 Code Review Automation Stack
GitHub Actions + Agent:
# .github/workflows/ai-review.yml
name: AI Code Review
on: pull_request:
types: [opened, synchronize]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Claude Code Review
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
# Get diff
diff=$(git diff origin/main...HEAD)
# Run Claude Code
echo "$diff" | claude -p "Review this PR for: bugs, security, performance, style" > review.md
# Post as PR comment
gh pr comment $PR_NUMBER --body-file review.md
Tools:
- Codacy — auto PR review (free tier untuk OSS)
- Snyk Code — security-focused (OWASP, CWE)
- SonarQube — quality + security + coverage
- DeepSource — auto-fix PR (bukan cuma comment)
- Qodana (JetBrains) — JetBrains ecosystem
16.2 Security Scanning Integration
Bandit (Python):
pip install bandit
bandit -r src/ -f json -o bandit-report.json
# Output: list of security issues (B201-B609)
Semgrep (multi-language):
# Install
pip install semgrep
# Run with security rules
semgrep --config=p/security-audit --config=p/owasp-top-ten src/
# Custom rules
semgrep --config=custom-rules.yml src/
Snyk Code:
npm install -g snyk
snyk auth
snyk code test
# Output: security + license issues
CodeQL (GitHub native):
# .github/workflows/codeql.yml
name: CodeQL
on: [push, pull_request]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: github/codeql-action/init@v3
with:
languages: python, javascript, go
- uses: github/codeql-action/analyze@v3
16.3 Test Coverage Tracking
Python (pytest + coverage):
pytest --cov=src --cov-report=html --cov-fail-under=80
JavaScript (jest):
jest --coverage --coverageThreshold='{"global":{"lines":80,"branches":80}}'
Go:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
Rust:
cargo test
cargo tarpaulin # coverage tool
Track di CI:
- name: Coverage check
run: |
pytest --cov=src --cov-fail-under=80
coverage-badge -o coverage.svg
# Upload to codecov.io
codecov -t $CODECOV_TOKEN
16.4 LLM Call Logging & Cost Tracking
LangSmith:
from langsmith import trace
@trace
def my_agent_call(prompt):
return claude.invoke(prompt)
# Otomatis logged di LangSmith dashboard
Langfuse (OSS):
from langfuse import Langfuse
langfuse = Langfuse(public_key="...", secret_key="...")
trace = langfuse.trace(name="claude-code-task")
generation = trace.generation(
name="refactor",
model="claude-sonnet-4",
input=prompt,
output=response,
usage={"input_tokens": 2000, "output_tokens": 500}
)
# Cost auto-calculated, dashboard real-time
Helicone (LLM-specific):
import openai
openai.api_base = "https://oai.helicone.ai/v1"
openai.api_key = "sk-..."
# Auto-logged di Helicone
16.5 Acceptance Testing Pattern
Penting: agent output harus di-verify sebelum merge. Pattern:
# acceptance_test.py
def test_agent_refactor_preserves_behavior():
# 1. Capture baseline
baseline_output = run_program("test_input.json")
# 2. Run agent refactor
agent.refactor(target="rename snake_case to camelCase")
# 3. Capture post-refactor
post_output = run_program("test_input.json")
# 4. Compare
assert baseline_output == post_output, "Refactor changed behavior!"
# 5. Run all tests
assert run_all_tests(), "Tests failed after refactor!"
Lakukan di CI/CD. Kalau agent ngubah behavior, reject PR.
17. Trading & Quant-Specific Code Generation
Penggunaan AI coding agent untuk quant/trading punya pattern unik. Bagian ini ekspansi khusus untuk trader/quant developer.
17.1 Low-Latency Code Generation
Constraint: HFT code harus < 10 microsecond. AI agent jarang di sini (gak worth it). Tapi untuk research code, signal generation, backtest orchestration → AI agent very useful.
Pattern: Generate then Optimize
# Step 1: Agent generate readable code
@agent_task
def generate_signal_logic():
"""
Generate Python code untuk mean-reversion signal.
Input: pandas DataFrame dengan kolom [timestamp, price, volume]
Output: Series of -1/0/+1 (sell/hold/buy)
"""
# Step 2: Profile, optimize manually kalau perlu
import cProfile
cProfile.run('signal_logic(df)')
# Step 3: Kalau latency-critical, translate ke Cython/C++
# (Agent tidak dipakai untuk step ini)
17.2 MQL5 / Pine Script Generation
MQL5 (MetaTrader):
Prompt ke Claude Code:
"Generate MQL5 Expert Advisor untuk:
- Pair: EURUSD
- Timeframe: H1
- Strategy: 20/50 EMA crossover
- Risk: 1% per trade
- Stop loss: 50 pips
- Take profit: 100 pips
- Magic number: 12345"
Output: ~200-400 LOC MQL5 yang siap compile. Akurasi 85-90%, sisa 10-15% perlu adjust untuk broker-specific.
Pine Script (TradingView):
Prompt ke Claude Code:
"Generate Pine Script v5 indicator:
- RSI(14) dengan overbought/oversold zone
- Bollinger Bands(20, 2)
- Signal: RSI > 70 AND close > upper BB → SELL
- Plot signals dengan label"
Akurasi lebih tinggi (90%+) karena Pine Script syntax lebih sederhana.
17.3 Backtest Code Generation (vectorbt, backtrader)
vectorbt (Python, fast backtest):
"Generate vectorbt backtest:
- Strategy: SMA crossover (fast=10, slow=30)
- Universe: BBCA.JK dari 2020-01-01 sampai 2025-12-31
- Initial capital: 100M IDR
- Commission: 0.15% (broker fee IDX retail)
- Output: equity curve, Sharpe, max drawdown"
Output vectorbt code yang run dalam 5-10 detik untuk 6 tahun daily data.
backtrader (event-driven, lebih realistic):
"Generate backtrader strategy:
- Entry: RSI < 30 AND close > SMA(200)
- Exit: RSI > 70 OR stop loss 5%
- Position sizing: 10% of capital per trade
- Slippage: 0.1%
- Data: yfinance download TLKM.JK"
Akurasi 80%+, biasanya perlu adjust untuk data feed, slippage model.
17.4 Execution Algo Code (TWAP, VWAP, IS)
TWAP (Time-Weighted Average Price):
# Generated + manual review
def twap_execute(symbol, total_qty, duration_min, exchange_adapter):
"""
Slice order jadi equal parts, kirim per interval.
"""
n_slices = duration_min # 1 slice per minute
qty_per_slice = total_qty // n_slices
remainder = total_qty % n_slices
start = time.time()
for i in range(n_slices):
# Wait until next interval
target_time = start + (i + 1) * 60
sleep_until(target_time)
# Send slice
order_qty = qty_per_slice + (1 if i < remainder else 0)
exchange_adapter.send_order(symbol, order_qty, 'market')
VWAP (Volume-Weighted Average Price):
Lebih complex, butuh historical volume profile:
def vwap_execute(symbol, total_qty, target_vwap, exchange_adapter):
"""
Slice order proportional to expected volume.
"""
volume_profile = get_historical_volume_profile(symbol) # % per bucket
for bucket, pct in volume_profile.items():
qty = total_qty * pct
exchange_adapter.send_order(symbol, qty, 'limit', price=target_vwap)
Implementation Shortfall (IS):
Paling complex — front-load atau back-load berdasarkan urgency:
def is_execute(symbol, total_qty, urgency, exchange_adapter):
"""
urgency: 'low' (back-loaded) to 'high' (front-loaded)
"""
if urgency == 'high':
# Execute 50% immediately, 50% TWAP remainder
exchange_adapter.send_order(symbol, total_qty * 0.5, 'market')
twap_execute(symbol, total_qty * 0.5, 30, exchange_adapter)
elif urgency == 'low':
# Back-loaded: 20% awal, 80% latter half
twap_execute(symbol, total_qty * 0.2, duration_min // 2, exchange_adapter)
sleep(duration_min // 2 * 60)
twap_execute(symbol, total_qty * 0.8, duration_min // 2, exchange_adapter)
Akurasi agent: 75-85%. Execution algo selalu perlu manual review dan backtest dengan realistic market impact.
17.5 Risk Management Code (VaR, Position Sizing)
Value at Risk (VaR):
import numpy as np
def parametric_var(returns, confidence=0.95, horizon=1):
"""
Parametric VaR (assume normal distribution).
"""
mu = np.mean(returns)
sigma = np.std(returns)
z = norm.ppf(1 - confidence) # -1.645 for 95%
var = -(mu + z * sigma) * np.sqrt(horizon)
return var
def historical_var(returns, confidence=0.95):
"""
Historical VaR (no distribution assumption).
"""
sorted_returns = np.sort(returns)
index = int((1 - confidence) * len(sorted_returns))
return -sorted_returns[index]
def monte_carlo_var(returns, confidence=0.95, n_sims=10000, horizon=1):
"""
Monte Carlo VaR.
"""
mu, sigma = np.mean(returns), np.std(returns)
sims = np.random.normal(mu, sigma, (n_sims, horizon))
sim_returns = np.prod(1 + sims, axis=1) - 1
sorted_returns = np.sort(sim_returns)
index = int((1 - confidence) * len(sorted_returns))
return -sorted_returns[index]
Position Sizing (Kelly Criterion):
def kelly_fraction(win_rate, avg_win, avg_loss):
"""
Kelly criterion untuk position sizing.
"""
if avg_loss == 0:
return 0
return win_rate - (1 - win_rate) * (avg_loss / avg_win)
def fixed_fractional(win_rate, avg_win, avg_loss, fraction=0.5):
"""
Half-Kelly (safer).
"""
full_kelly = kelly_fraction(win_rate, avg_win, avg_loss)
return full_kelly * fraction
17.6 Compliance & Audit Trail Code
Untuk trading firm, setiap action harus di-log untuk compliance:
import logging
import json
from datetime import datetime
def compliance_audit(action, params, result):
"""
Log semua action untuk compliance.
"""
log_entry = {
"timestamp": datetime.utcnow().isoformat(),
"user": get_current_user(),
"action": action,
"params": params,
"result": result,
"session_id": get_session_id(),
"ip": get_client_ip()
}
# Write to immutable log (append-only)
with open("/var/log/compliance/audit.log", "a") as f:
f.write(json.dumps(log_entry) + "\n")
# Also send to compliance DB
compliance_db.insert(log_entry)
Agent-generated code harus include audit trail ini dari awal, bukan ditambahin kemudian.
17.7 Latency Budget untuk Agent-Generated Trading Code
| Operation | Acceptable latency | AI agent dapat? |
|---|---|---|
| Signal calculation (offline research) | < 5 menit | ✅ Ya |
| Backtest (vectorbt) | < 1 menit | ✅ Ya |
| Backtest (event-driven) | < 30 menit | ⚠️ Partial (perlu review) |
| Order generation (pre-trade) | < 100 ms | ⚠️ Risky (harus verify) |
| Order execution (intra-trade) | < 10 μs | ❌ Tidak (gak applicable) |
| Risk check (pre-trade) | < 10 ms | ⚠️ Partial (perlu review ketat) |
| Reporting (post-trade) | < 1 menit | ✅ Ya |
Prinsip: AI agent optimal untuk offline task. Untuk online (latency-sensitive), generate dengan AI, lalu audit manual + benchmark.
18. 5 Case Study Indonesia
Concrete case study dari berbagai industri di Indonesia yang sudah adopt AI coding agent.
18.1 Local Dev Shop (Jakarta) — Freelance/B2B Service
Profil: 5 orang, full-stack, handle 5-10 client project simultaneously.
Stack: Cursor Pro (5 × $20) + Aider (free) untuk quick scripts
Workflow:
- Cursor untuk daily coding IDE (autocomplete, quick edit)
- Aider untuk generate boilerplate (CRUD, test) sebelum commit
- Pair programming via Cursor Live Share
- Code review antar tim manual (gak pakai agent — privacy concern dari client)
Cost bulanan: ~$100 (subscription only, API cost < $50)
Lesson learned: Cursor + Aider combo lebih hemat dari Claude Code. 80% task daily gak butuh reasoning Opus 4.
18.2 E-commerce (Tokopedia/Shopee Scale) — Fast Iteration
Profil: Tim 50 orang, 5 microservices, daily deploy.
Stack: GitHub Copilot (default) + Claude Code (untuk incident response + refactor)
Workflow:
- Copilot untuk daily autocomplete (semua engineer)
- Claude Code untuk incident debugging (Sentry → MCP → auto-investigate)
- Claude Code untuk quarterly refactor besar (rename service, API version upgrade)
- Code review tetap human (Copilot/Claude kasih suggestion, manusia decide)
Cost bulanan: ~$1500 (50 × $20 Copilot + 5 × $20 Claude + API ~$500)
Lesson learned: Copilot volume tinggi (low cost per use), Claude Code occasional high-leverage. Hybrid > pure one agent.
18.3 Fintech (GoPay/OVO/Dana) — Compliance Critical
Profil: Tim 80 orang, payment service, PCI-DSS Level 1.
Stack: Cursor Business (data residency Singapore) + Tabby self-host (untuk code IP-sensitive)
Workflow:
- Cursor untuk daily coding (SOC 2 compliant, no data ke US)
- Tabby self-host untuk code review service proprietary (anti-fraud engine, risk scoring)
- NO Claude Code — code gak boleh keluar Indonesia (POJK 26/2023)
- Manual code review + automated via SonarQube + Snyk
Cost bulanan: ~$3000 (Cursor Business premium) + $2000 (Tabby infra: 2x A100 GPU)
Lesson learned: Untuk fintech Indonesia, self-host + data residency adalah hard requirement, bukan nice-to-have. Cloud AI agent = no-go.
18.4 Startup (Early Stage, Pre-Series A) — Scrappy MVP
Profil: Tim 3 orang (CTO, 2 full-stack), MVP di 3 bulan.
Stack: Cursor Pro ($20) + DeepSeek-Coder V3 API (cheap) + Aider untuk batch refactor
Workflow:
- Cursor untuk 80% daily
- DeepSeek-Coder V3 untuk generate boilerplate heavy (auth, CRUD, payment integration) — 1/5 cost Claude
- Aider untuk git-native refactor (renaming, file restructure)
- Code review: CTO review all (3 orang, manageable)
Cost bulanan: ~$50 (subscription) + $30 (DeepSeek API)
Lesson learned: Open-weight + cheap API = sweet spot untuk startup. Quality cukup untuk MVP, cost sustainable sampai Series A.
18.5 Enterprise (Banking/Telco) — Legacy + Compliance
Profil: Bank besar, tim 500+ engineer, codebase 50M+ LOC (include COBOL mainframes).
Stack: Cody Enterprise self-host (Sourcegraph on-prem) + Tabby (untuk legacy COBOL/Perl) + manual code review
Workflow:
- Sourcegraph sebagai single source of truth (semua repo terindex)
- Cody untuk multi-repo search dan refactor saran
- Tabby untuk legacy language support (COBOL, Perl, Fortran)
- Tidak ada cloud AI — semua on-prem karena BI Regulation + UU PDP
- Code review: 2-level (peer + senior)
Cost bulanan: ~$15,000 (Cody Enterprise + Tabby GPU cluster + 2 FTE MLOps)
Lesson learned: Enterprise = self-host mandatory, vendor support critical, MLOps headcount essential.
19. 5 Advanced Use Cases Non-Coding (Tapi Pakai Coding Agent)
AI coding agent gak cuma untuk code. 5 use case non-traditional yang surprisingly useful.
19.1 Config Generation (YAML, TOML, K8s, Terraform)
K8s manifest generation:
Prompt: "Generate Kubernetes Deployment + Service + Ingress untuk:
- App: FastAPI analytics
- Image: gcr.io/my-project/analytics:v2.1
- Replicas: 3
- Resources: 500m CPU, 512Mi RAM
- Env: DATABASE_URL dari secret, REDIS_HOST dari configmap
- Health check: /healthz port 8000
- Ingress: analytics.example.com dengan TLS"
Akurasi: 90%+. Output K8s YAML yang bisa langsung kubectl apply.
Terraform (IaC):
"Generate Terraform untuk:
- AWS VPC di region ap-southeast-1 (Singapore)
- 2 public subnet, 2 private subnet
- RDS PostgreSQL (db.t3.medium) di private subnet
- ElastiCache Redis di private subnet
- Internet Gateway + NAT Gateway
- Security group: allow 443 dari 0.0.0.0/0, 5432 dari VPC only"
Output ~150-200 LOC Terraform. Akurasi 80%+, biasanya perlu adjust untuk naming convention, tags.
19.2 Documentation Generation (README, API Docs, JSDoc)
README.md:
"Generate README.md untuk project ini:
- Project name: analytics-service
- Stack: Python 3.11, FastAPI, PostgreSQL, Redis
- Setup: pip install -r requirements.txt, copy .env.example .env
- Run: uvicorn main:app --reload
- Test: pytest
- Docker: docker-compose up"
Akurasi 85%+. Output well-structured README dengan sections standard.
API documentation (OpenAPI/Swagger):
FastAPI auto-generates OpenAPI schema. Tapi untuk enhance dengan descriptions, examples, error responses → agent bisa enhance.
JSDoc/TSDoc:
/**
* Calculate the Sharpe ratio for a return series.
* @agent
* Generate JSDoc untuk function ini
*/
function sharpeRatio(returns: number[], riskFreeRate: number = 0): number {
// ...
}
19.3 SQL Query Generation (Ad-hoc Analytics, Migration)
Ad-hoc query:
"Generate SQL untuk:
- Tabel: orders (id, user_id, total, status, created_at)
- Hitung: monthly revenue per product category untuk 2025
- Filter: exclude refunded orders
- Join: dengan products (id, category) dan users (id, signup_date)
- Output: month, category, revenue, user_count
- Database: PostgreSQL 14
- Performance: ada index di orders.created_at, orders.user_id"
Akurasi 90%+ untuk PostgreSQL. Output SQL yang tested + EXPLAIN plan suggestion.
Schema migration:
"Generate Alembic migration untuk:
- Tambah kolom 'phone_verified' (boolean, default false) ke tabel users
- Tambah kolom 'last_login_at' (timestamp, nullable) ke tabel users
- Index: last_login_at (untuk analytics query)
- Downgrade: drop columns + index
- Database: PostgreSQL"
Output migration script yang tested dan reversible.
19.4 Regex Generation (Validation, Parsing)
"Generate regex untuk:
- Validasi email (RFC 5322 compliant)
- Validasi Indonesian phone number (+62, 08xx, format dengan/dash tanpa spasi)
- Parse URL (protocol, domain, path, query params)
- Extract hashtag dari tweet (multi-byte unicode)"
Akurasi 70-85% (regex notoriously tricky). Selalu test dengan diverse input.
19.5 Shell Script Generation (Ops, CI/CD)
Bash script:
"Generate bash script untuk:
- Backup PostgreSQL database (pg_dump + compress + upload ke S3)
- Retention: keep 7 daily, 4 weekly, 12 monthly
- Logging: ke /var/log/backup.log
- Error handling: exit 1 on any error
- Cron-friendly: idempotent, no prompts
- Env: AWS credentials dari ~/.aws/credentials"
Output ~50-80 LOC bash yang production-ready.
CI/CD pipeline (GitHub Actions):
"Generate GitHub Actions workflow untuk:
- Trigger: push to main, pull request
- Jobs: lint, test, build, deploy (only on main)
- Language: Python (pytest, flake8, mypy)
- Docker: build dan push ke GHCR
- Deploy: ke Cloud Run (GCP region asia-southeast1)
- Secrets: GCP_SA_KEY dari GitHub secrets"
Akurasi 80%+. Output workflow YAML yang well-structured.
19.6 Test Data Generation (Fixtures, Mocks)
"Generate pytest fixtures untuk:
- 10 sample users (mix of verified/unverified, various signup dates)
- 50 sample orders (various status, total range 50K-5M IDR)
- 20 sample products (different categories, prices)
- Edge cases: 1 user with null phone, 1 order with 0 total (refunded)
- Faker library untuk realistic data (Indonesian names, addresses)"
Akurasi 95%+ untuk Python/pytest. Output ready-to-use fixture file.
19.7 Migration Code (Python 2→3, jQuery→React, Flask→FastAPI)
Python 2 → 3 migration:
Agent biasanya handle well untuk:
printstatement →print()functionunicode→strxrange→rangeiteritems()→items()import urllib2→import urllib.request
Akurasi 80-90%. Selalu run full test suite setelah migration.
Flask → FastAPI:
Lebih complex, karena pattern berbeda (sync → async, decorator → Pydantic). Agent akurasi 60-75%. Best practice: incremental, satu endpoint sekaligus.
20. Compliance & Regulatory — Code Generation di Indonesia
Penting untuk engineer di Indonesia yang handle data sensitive atau code untuk regulated industry.
20.1 UU PDP 27/2022 (Pelindungan Data Pribadi)
Implikasi untuk AI coding agent:
-
Data residency: Code yang handle data pribadi gak boleh di-process di luar Indonesia tanpa consent.
- Claude Code, Cursor, Cody (cloud): WAJIB cek apakah data di-route ke US/EU. Default: ya.
- Mitigation: Pakai Tabby self-host atau Cody Enterprise on-prem.
-
Consent untuk code generation: Kalau AI agent baca codebase yang ada data pribadi (test fixtures, log, etc.), itu termasuk "processing" data pribadi.
- Mitigation: Scrub data pribadi dari test fixtures sebelum commit.
-
Audit trail: Setiap code yang handle data pribadi harus punya audit log.
- Pattern: Lihat section 17.6.
Checklist UU PDP untuk code generation:
- [ ] Pakai AI agent yang data residency compliant (self-host)
- [ ] Scrub PII dari test fixtures
- [ ] Audit log untuk semua data access
- [ ] Data retention policy di code (jangan log indefinitely)
- [ ] Right to erasure implementation (GDPR-style, applicable untuk UU PDP)
20.2 UU ITE 19/2016 + UU 1/2024 (Informasi dan Transaksi Elektronik)
Implikasi:
- Tanda tangan elektronik: Generated code yang handle e-signature harus comply.
- Sistem elektronik: Kalau lo bikin platform yang dipakai publik, harus daftar ke KOMINFO.
- Konten ilegal: AI-generated code yang facilitate konten ilegal (scraping tanpa izin, doxxing tool) = liable.
Best practice:
- Clear code comments untuk legal disclaimer
- Rate limiting + abuse prevention built-in
- User consent flow untuk data collection
20.3 OJK POJK 26/2023 ( Fintech Lending + Tech)
Untuk fintech Indonesia:
- Data center di Indonesia: POJK 26/2023 Sect 35: data center dan DR center harus di Indonesia.
- Akses BI/OJK: Regulator bisa minta akses ke sistem. Code harus facilitate audit.
- Risk management: Code harus include risk metric (VaR, stress test) — section 17.5.
Implikasi untuk AI agent:
- Larangan cloud AI agent untuk code yang handle financial data (kecuali bank tier dengan approval)
- Self-host mandatory — Tabby, Cody self-host, atau on-prem LLM
- Code review mandatory oleh certified auditor (bukan cuma peer review)
20.4 GDPR (Untuk Perusahaan dengan EU User)
Kalau lo punya user di EU:
- Right to be forgotten: Code harus support user data deletion end-to-end
- Data portability: Export user data in machine-readable format
- Privacy by design: Bake privacy ke architecture, bukan afterthought
- Breach notification: Code harus detect breach + notify within 72 hours
AI agent role: Help generate GDPR-compliant boilerplate (consent flow, data export, deletion), tapi final review oleh DPO (Data Protection Officer) mandatory.
20.5 PCI-DSS (Payment Card Industry)
Untuk payment service (kayak GoPay/OVO/Dana):
- No card data in code: Linting rule (Bandit, Semgrep) untuk detect hardcoded card numbers
- Encryption everywhere: TLS 1.2+, encryption at rest (AES-256)
- Access control: RBAC, MFA, audit log
- Code review mandatory: PCI-DSS Req 6: secure software development
AI agent role: Generate PCI-DSS compliant boilerplate, tapi penetration test + security audit mandatory.
20.6 ISO 27001 / SOC 2 (Enterprise)
Untuk SaaS B2B:
- Change management: All code changes tracked, reviewed, approved
- Access control: Engineer access least-privilege
- Incident response: Code untuk detect, respond, recover
- Vendor management: Kalau pakai third-party AI agent (Claude/Cursor), due diligence required
AI agent role: Help generate compliance boilerplate, tapi certified auditor review mandatory untuk actual compliance.
20.7 HIPAA (Healthcare — kalau lo handle US health data)
Untuk telemedicine Indonesia yang juga serve US:
- PHI (Protected Health Information) encryption
- Audit log mandatory (who accessed what when)
- Business Associate Agreement (BAA) dengan AI vendor
- No PHI in prompts: Critical — jangan paste PHI ke Claude Code
Best practice: Pakai self-host LLM untuk PHI-touching code, atau redact PHI sebelum prompt.
21. Decision Tree — Pilih AI Coding Agent yang Tepat
7 pertanyaan yang menentukan agent mana yang optimal untuk use case lo.
Q1: Lo prioritas utama lo apa?
│
├─ A) Inline autocomplete cepat (daily IDE) → Cursor atau Copilot
├─ B) Heavy reasoning (refactor, debug) → Claude Code atau Devin
├─ C) Codebase search (multi-repo) → Cody
├─ D) Self-host (compliance) → Tabby atau Cody Enterprise
├─ E) Open source (no vendor lock) → Aider atau Continue.dev
└─ F) Cost-effective production → DeepSeek-Coder V3 atau Codestral
Q2: Codebase size lo berapa?
│
├─ A) < 50K LOC → Claude Code (full context)
├─ B) 50K-500K LOC → Cursor atau Cody (RAG)
├─ C) 500K-5M LOC → Cody (graph-based)
└─ D) > 5M LOC (monorepo) → Cody Enterprise + custom indexing
Q3: Compliance requirement lo apa?
│
├─ A) No compliance (side project) → Any cloud agent
├─ B) GDPR only → Cloud OK dengan DPA
├─ C) UU PDP / POJK (Indonesia) → Self-host (Tabby, Cody on-prem)
├─ D) PCI-DSS → Self-host + manual audit
└─ E) HIPAA → Self-host + BAA
Q4: Budget lo berapa per engineer per bulan?
│
├─ A) $0 (free) → Cursor Free + Aider + Cody Free
├─ B) < $20 → Cursor Free + Aider
├─ C) $20-50 → Cursor Pro atau Copilot
├─ D) $50-100 → Cursor Pro + Aider
├─ E) $100+ → Claude Code Pro
└─ F) $500+ → Devin (autonomous)
Q5: Bahasa programming lo apa?
│
├─ A) General (Python, JS, Go, Rust) → Any
├─ B) Legacy (COBOL, Perl, Fortran) → Cody atau Tabby
├─ C) Data/ML (Python, R, Julia) → Aider + DeepSeek-Coder
├─ D) Mobile (Swift, Kotlin) → Cursor atau Copilot
└─ E) Frontend heavy (TS, React) → Cursor atau Copilot
Q6: Workflow lo lebih banyak apa?
│
├─ A) Read-heavy (understand existing code) → Claude Code atau Cody
├─ B) Write-heavy (generate new code) → Cursor atau Claude Code
├─ C) Test-heavy (quality assurance) → Cody (best edge case)
├─ D) Review-heavy (PR + critique) → Claude Code atau Cody
└─ E) Ops-heavy (CI/CD, infra) → Continue.dev atau Aider
Q7: Lo engineer level apa?
│
├─ A) Junior (0-2 year exp) → Cursor (autocomplete as learning aid)
├─ B) Mid (2-5 year exp) → Cursor + Aider
├─ C) Senior (5-10 year exp) → Claude Code + Cursor
├─ D) Staff+ (10+ year exp) → Claude Code + multiple tools
└─ E) Manager → Cody (read-heavy, less write)
Quick recommendation matrix:
| Profil | Primary | Secondary |
|---|---|---|
| Junior dev | Cursor | Aider (untuk belajar) |
| Mid dev | Cursor | Claude Code (task berat) |
| Senior dev | Claude Code | Cursor (daily) |
| Tech lead | Claude Code + Cody | Aider |
| Manager | Cody (search) | Claude Code (architecture review) |
| Solo indie | Cursor + Aider | DeepSeek-Coder (cheap) |
| Startup CTO | Cursor + DeepSeek | Aider |
| Enterprise | Cody self-host + Tabby | Claude Code (for prototyping) |
| Fintech/Bank | Cody self-host | (NO cloud) |
| Government | Tabby self-host | (NO cloud) |
22. Anti-Recommendation — 7 Situasi JANGAN Pakai AI Coding Agent
Penting: AI coding agent bukan silver bullet. Ada situasi di mana ia lebih banyak mudaratnya.
22.1 Code yang Butuh Sertifikasi Formal
Situasi: Avionics, medical device, nuclear reactor, automotive safety-critical (ISO 26262).
Mengapa: Regulator minta proof bahwa code ditulis oleh certified engineer dengan traceable process. AI-generated code = no chain of custody → fail audit.
Alternative: Manual coding + formal verification tools (SPARK, Coq, TLA+).
22.2 Code yang Handle Senjata / Military
Situasi: Drone targeting system, missile guidance, weapons platform.
Mengapa: Ethical + legal. Mayoritas AI vendor (Anthropic, OpenAI) ToS melarang use case military. Anthropic Acceptable Use Policy explicit list.
Alternative: No AI, full manual dengan security clearance.
22.3 Real-Time Systems dengan Hard Deadline
Situasi: Air traffic control, pacemaker, vehicle brake system, industrial robot.
Mengapa: Latency unpredictability. AI agent inference time variable (200ms - 2s). Gak bisa guarantee real-time constraint.
Alternative: Pre-generated code yang sudah verified, real-time OS (RTOS), formal methods.
22.4 Code yang Butuh Creativity Tinggi (R&D, Novel Algorithm)
Situasi: New ML architecture, novel data structure, research-grade optimization.
Mengapa: AI agent optimize terhadap known patterns. Novel R&D = no pattern to optimize against. AI akan revert ke common pattern.
Alternative: Manual R&D + literature review + academic collaboration.
22.5 Code yang Sensitive Secara Politik / Reputasi
Situasi: Government policy implementation, election system, censorship tool.
Mengapa: Code yang implement policy kontroversial = reputational + legal risk kalau di-trace ke AI. Manual coding dengan accountable engineer.
Alternative: Public committee + manual + open source.
22.6 Initial Prototype yang Butuh User Validation
Situasi: Pre-PMF, butuh quick experiment untuk validate hypothesis.
Mengapa: Over-engineering risk. AI agent sering generate production-grade code untuk prototype → premature optimization, wasted effort.
Alternative: Manual quick & dirty, no testing, throwaway code. Validate hypothesis dulu.
22.7 Learning Phase untuk Junior Engineer
Situasi: Engineer baru belajar fundamental (algorithm, data structure, system design).
Mengapa: Pakai AI agent = skip learning process. Engineer gak jadi paham fundamental. 5 tahun kemudian jadi engineer yang gak bisa debug tanpa AI.
Alternative: Manual coding untuk first 6-12 bulan, baru introduce AI agent sebagai "accelerator" setelah paham fundamental.
23. Implementation Checklist — 25-Item
Sebelum pakai AI coding agent di production, ensure 25 item ini covered.
Pre-Implementation (7 item)
- [ ] 1. Tentukan use case spesifik (daily IDE? heavy refactor? code review?)
- [ ] 2. Pilih framework berdasarkan decision tree (Section 21)
- [ ] 3. Setup subscription + API key dengan budget alert
- [ ] 4. Configure rate limit (jangan unlimited)
- [ ] 5. Setup audit logging (siapa pakai, untuk apa, berapa cost)
- [ ] 6. Define code review process (who, when, criteria)
- [ ] 7. Setup CI/CD dengan agent-specific tests (syntax, security, behavior)
Security (5 item)
- [ ] 8. Restrict Bash access (no
rm -rf /, nocurl | bash) - [ ] 9. Use
.gitignoreuntuk secret (API key, .env) - [ ] 10. Enable security scanning (Bandit, Semgrep, Snyk) di CI
- [ ] 11. Code review mandatory untuk generated code (peer + senior)
- [ ] 12. PII detection (jalankan sebelum commit, prevent leak)
Quality (5 item)
- [ ] 13. Test coverage threshold (min 80% line + 70% branch)
- [ ] 14. Linting (flake8, eslint, golangci-lint, clippy) di pre-commit
- [ ] 15. Type checking (mypy, TypeScript strict) di CI
- [ ] 16. Acceptance test per task (verify behavior unchanged after refactor)
- [ ] 17. Documentation update (README, JSDoc) per PR
Cost Control (4 item)
- [ ] 18. Track cost per task (Langfuse, Helicone)
- [ ] 19. Set model per task type (Haiku untuk autocomplete, Opus untuk heavy)
- [ ] 20. Weekly cost review (cek usage spike, optimize)
- [ ] 21. Use cheap model untuk bulk task (DeepSeek-Coder V3 API = 1/5 cost)
Compliance (4 item)
- [ ] 22. Data residency check (UU PDP, GDPR)
- [ ] 23. Audit log retention (7 tahun untuk financial, 3 tahun untuk GDPR)
- [ ] 24. Vendor DPA (Data Processing Agreement) signed
- [ ] 25. Incident response plan (kalau API key leak, atau agent malfunction)
24. References (Extended)
AI Coding Agent Vendor Docs
- Anthropic, "Claude Code: Best Practices" (Juni 2026) — docs.anthropic.com/claude-code
- Cursor, "Composer Mode Documentation" (2026) — docs.cursor.com/composer
- Sourcegraph, "Cody Architecture & Enterprise Deployment" (2026) — sourcegraph.com/docs/cody
- Aider, "AI Pair Programming in Terminal" (2026) — aider.chat/docs
- Continue.dev, "Open-Source AI Code Assistant" (2026) — continue.dev/docs
- Tabby, "Self-Hosted AI Coding Assistant" (2026) — tabby.tabbyml.com/docs
- Mistral AI, "Codestral Documentation" (2026) — docs.mistral.ai/codestral
- DeepSeek, "DeepSeek-Coder V3" (2026) — deepseekcoder.github.io
- Meta AI, "Code Llama 70B" (2024) — ai.meta.com/llama
- GitHub, "Copilot Business" (2026) — github.com/features/copilot
- Cognition AI, "Devin Technical Report" (2024) — cognition.ai/blog
- OpenAI, "Codex CLI" (2026) — github.com/openai/codex
- JetBrains, "AI Assistant Documentation" (2026) — jetbrains.com/ai
Benchmark & Research
- Chen et al., "Evaluating Large Language Models Trained on Code" (2021) — arXiv:2107.03374 (HumanEval paper)
- Austin et al., "Program Synthesis with Large Language Models" (2021) — arXiv:2108.07732 (MBPP)
- Jimenez et al., "SWE-Bench: Can Language Models Resolve Real-World GitHub Issues?" (2024) — arXiv:2310.06770
- Liu et al., "Lost in the Middle: How Language Models Use Long Contexts" (2023) — arXiv:2307.03172
- Ren et al., "CodeBLEU: A Method for Automatic Evaluation of Code Synthesis" (2020) — arXiv:2009.10297
- Stack Overflow, "Developer Survey 2026" — survey.stackoverflow.co/2026
- Anthropic, "Claude 4 Model Card" (2026) — anthropic.com/claude-4-model-card
Tools & Framework
- LangSmith, "LLM Call Tracing" (2026) — langchain.com/langsmith
- Langfuse, "Open-Source LLM Observability" (2026) — langfuse.com/docs
- Helicone, "LLM Observability" (2026) — helicone.ai/docs
- Bandit, "Python Security Linter" — bandit.readthedocs.io
- Semgrep, "Static Analysis for Security" — semgrep.dev/docs
- SonarQube, "Code Quality & Security" — sonarsource.com/products/sonarqube
Compliance & Regulatory
- Indonesia, "UU PDP 27/2022" — pelindungan-data-pribadi.go.id
- Indonesia, "UU ITE 19/2016 + UU 1/2024" — kominfo.go.id
- OJK, "POJK 26/2023" — ojk.go.id
- European Commission, "GDPR Full Text" — gdpr-info.eu
- PCI Security Standards Council, "PCI-DSS v4.0" — pcisecuritystandards.org
- ISO, "ISO/IEC 27001:2022" — iso.org/standard/27001
TL;DR (Final)
Setelah eksplorasi panjang, intinya:
- Pilih berdasarkan workflow, bukan hype. Cursor daily + Claude Code heavy + Cody search = sweet spot untuk most engineers.
- Pahami math-nya. Pass@k, context degradation, code tokenization — bukan cuma marketing benchmark.
- Self-host untuk compliance. Tabby + Cody Enterprise on-prem = mandatory untuk fintech/bank/government Indonesia.
- Track cost real-time. API cost menumpuk kalau gak dimonitor. Setup Langfuse atau Helicone dari awal.
- Verify output selalu. Agent hallucinates function names, import paths, API signatures. Run tests, read diff, never trust blindly.
- Kombinasi > pure. 80% Cursor + 20% Claude Code + occasional Cody = best ROI untuk most.
- Compliance-ready. UU PDP/ITE/POJK compliance baked in dari awal, bukan retrofit.
Gue udah test 6 minggu, dan jawaban gue: jangan pilih salah satu, melainkan stack sesuai task. Selamat ngoprek, dan jangan lupa verify setiap baris code yang di-generate agent. 🦀
Resources Pendukung — Biar Lo Gak Cek Sendirian
Setelah baca breakdown 6-week testing + mathematical deep-dive + 5 case study di atas, mungkin lo butuh cepat validate assumption lo sendiri — bukan dari blog ini, tapi dari hands-on experience. Ini resource + infra yang gue pake untuk testing 6 minggu tersebut. Sambil menyelam minum air — affiliate-nya gue selip di sini:
Sambil menyelam minum air #1 — Inference hosting: Buat lo yang mau test sendiri Claude Code-style agent dengan model open weight, Alibaba Cloud free tier (referral A924ZV) kasih lo GPU compute gratis untuk inference Qwen-Coder, CodeLlama, atau DeepSeek-Coder. Lumayan buat benchmark 3-4 model sekaligus tanpa tagihan GPU mahal. Hemat $100-300/bulan untuk 1-2 A100 instance.
Sambil menyelam minum air #2 — Self-hosted code RAG: Bagian 14 di atas bahas internal architecture code RAG (vector DB + chunking + retrieval). Buat lo yang mau deploy versi self-hosted untuk compliance, Cek campaign benefits Alibaba Cloud (referral A924ZV) kasih diskon 30-50% untuk managed PostgreSQL + pgvector + Redis (untuk cache retrieval) — infra wajib untuk code RAG production. Cost compress signifikan vs pay-as-you-go.
Sambil menyelam minum air #3 — Qwen-Coder as alternative: Anthropic Sonnet lagi bagus, tapi gak free. Qwen-Coder via Alibaba Cloud AI tools (referral A924ZV) adalah open-weight alternative yang mendekati Claude Sonnet untuk code generation tasks, dengan support bahasa Indonesia di comment/docstring. Cocok untuk tim yang budget-sensitive tapi gak mau turunin quality.
Sambil menyelam minum air #4 — Compliance + region: Bagian 20 bahas UU PDP/ITE/OJK compliance. Buat dashboard code-review dan data processing yang kena regulasi, Cek region benefits Alibaba Cloud Singapore/Indonesia (referral A924ZV) — region SG/Jakarta compliant UU PDP, latency 5-15ms untuk user Indonesia, plus dedicated account manager untuk compliance audit support.
Sambil menyelam minum air #5 — Long-term dev infra: Buat startup / SME yang planning pakai AI coding agent untuk 50+ engineer selama 1-3 tahun, Cek paket benefits committed-use (referral A924ZV) kasih lo reserved capacity + custom routing — compress compute bill 40-60% vs on-demand. Cocok untuk sustain budget AI-assisted engineering tanpa quota shock di tengah jalan.
Sambil menyelam minum air #6 — Production deployment: Setelah lo pick agent mana yang menang untuk workflow lo (Claude Code / Cursor / Cody / Qwen-Coder), Alibaba Cloud free tier (referral A924ZV) juga bisa host sidecar services — code review bot, CI/CD worker, sandbox test environment — gratis untuk tier pertama. Hemat $50-150/bulan untuk tooling stack pendukung agent workflow.
Sambil menyelam minum air #7 — AI-assisted refactoring: Buat lo yang sering pakai AI agent buat refactor legacy code (bagian yang sering muncul di case study Indonesia), Qwen-Coder + Tongyi AI tools (referral A924ZV) udah support bulk refactor + cross-file dependency analysis — workflow: kasih agent 50 file Java lawas → dia propose refactor plan → lo approve per batch. Hemat 2-3 minggu manual refactor effort.
Sambil menyelam minum air #8 — Cost optimization: Bagian 8 bahas cost breakdown 6-week testing. Buat lo yang production-nya udah 10+ engineer dan compute bill mulai naek, Cek reserved instance benefits (referral A924ZV) — konversi 2-3 workload terbesar ke RI = hemat Rp 10-25 juta/bulan. Cocok untuk sustained AI-assisted engineering workload.
Sambil menyelam minum air #9 — Cross-region sync: Buat lo yang tim-nya split Jakarta + Singapore (atau hybrid remote), Cek region benefits untuk cross-region deployment (referral A924ZV) — ada dedicated peering + bandwidth pricing yang compress latency sync 30-50% vs public internet. Penting buat real-time collaboration di AI agent session.
Sambil menyelam minum air #10 — opsi managed tambahan: Kalau lo pengen bandingin langsung sama konteks Trend 2026: AI Coding Agent akan Jadi Commodities di atas, Qwen AI platform Alibaba Cloud nyediain jalur managed yang bisa lo tes tanpa kelola infra sendiri.
Topik Terkait
Artikel lain yang relevan dengan topik AI agent, workflow, dan teknis toolkuy:
💬 Komentar (0)
Belum ada komentar. Jadilah yang pertama! 💬