Code-Graph-RAG, เปลี่ยน Codebase ทั้งหมดให้เป็น Knowledge Graph ให้ AI เข้าใจโค้ดของคุณอย่างแท้จริง Code-Graph-RAG, an open-source project by Vitali Avagyan, converts entire codebases into knowledge graphs to enhance AI's understanding of code structure and relationships. The tool, which has gained over 4,000 GitHub stars, uses Tree-sitter for parsing and Memgraph for graph storage, enabling natural language queries, dead code detection, and impact analysis. It integrates with Claude Code via MCP, allowing AI coding agents to understand the full codebase rather than just open files. โดย Nokka นก-กา | 12 สิงหาคม 2026 บทความนี้เขียนโดย AI deepseek-v4-pro ผ่าน Hermes Agent ภายใต้การควบคุมและตรวจสอบคุณภาพโดยมนุษย์, Nokka นก-กา 4,000+ stars, 4,789 commits, 571 forks, commit ล่าสุดเมื่อ 17 นาทีที่แล้ว นี่คือ Code-Graph-RAG, โปรเจกต์ open-source ที่กำลังเปลี่ยนวิธีที่ AI เข้าใจโค้ด, จาก "ค้นหาด้วย keyword" → "เข้าใจโครงสร้างทั้งหมดของ codebase" 1 2 Code-Graph-RAG คือ Retrieval-Augmented Generation RAG ระบบที่ออกแบบมาสำหรับ codebase โดยเฉพาะ , มันไม่ได้แค่ "ค้นหาโค้ด", แต่มัน แปลง codebase ทั้งหมดให้เป็น Knowledge Graph , เพื่อให้ AI เข้าใจความสัมพันธ์ระหว่างฟังก์ชัน, คลาส, การเรียกใช้, และการไหลของข้อมูล 1 | องค์ประกอบ | รายละเอียด | |---|---| Parser | Tree-sitter, รองรับหลายภาษา | Knowledge Graph | Memgraph, เก็บโครงสร้าง codebase | Query | ภาษาธรรมชาติ, ถามเป็นภาษาอังกฤษได้ | Edit | แก้ไขโค้ดผ่าน AI, โดยเข้าใจผลกระทบ | MCP | เชื่อมต่อกับ Claude Code ได้โดยตรง | หลักการ: "The ultimate RAG for your monorepo. Query, understand, and edit multi-language codebases with the power of AI and knowledge graphs." 1 | RAG ทั่วไป | Code-Graph-RAG | |---|---| | แบ่งโค้ดเป็น chunks, ค้นหาด้วย similarity | แปลงโค้ดเป็น Knowledge Graph, เข้าใจโครงสร้าง | | AI เห็นแค่ "ข้อความ" | AI เห็น "ความสัมพันธ์", ฟังก์ชัน A เรียก B, คลาส C สืบทอดจาก D | | ถาม "find authentication logic" → ได้ snippets | ถาม "show me the auth flow" → ได้ graph ของ flow ทั้งหมด | | ไม่เข้าใจ data flow | ติดตามข้อมูลจาก input → processing → output | | แก้ไขแบบ blind | แก้ไขโดยรู้ว่ามีอะไรพังบ้าง | | ฟีเจอร์ | คำอธิบาย | |---|---| Multi-Language Monorepo | รองรับหลายภาษาใน repo เดียว, Tree-sitter รองรับ Python, JavaScript, TypeScript, Java, C , Rust, Go, และอื่นๆ | Natural Language Query | ถามเป็นภาษาอังกฤษ, "find all functions that call the database", "show me the authentication flow" | Dead Code Detection | หาโค้ดที่ไม่มีใครเรียกใช้, ปลอดภัยที่จะลบ | Data Flow Tracking | ติดตามว่าข้อมูลไหลจากตรงไหนไปตรงไหน, input → processing → output | AST-Level Search & Edit | ค้นหาและแก้ไขในระดับ Abstract Syntax Tree, ไม่ได้มีเพียง text search | MCP Integration | เชื่อมต่อกับ Claude Code ผ่าน Model Context Protocol, AI coding agent เข้าใจ codebase ทั้งหมด | Code Optimization | วิเคราะห์และแนะนำการ optimize โค้ด | | เมตริก | ตัวเลข | |---|---| GitHub Stars | 4,000+ | Forks | 571 | Commits | 4,789 | Issues | 42 | Pull Requests | 3 | Last Commit | 17 นาทีที่แล้ว 🔥🔥🔥🔥🔥 | Creator | Vitali Avagyan | Activity Level: 🔥🔥🔥🔥🔥 , commit ทุกวัน, 4,789 commits, นี่คือโปรเจกต์ที่ active มาก, และกำลังโตเร็ว, ได้รับ funding จาก FLOSS/Fund 3 Code-Graph-RAG ทำงาน 3 ขั้นตอน: Codebase Python, JS, Java, C , etc. → Tree-sitter parser → AST Abstract Syntax Tree Tree-sitter แยกโค้ดเป็น AST, เข้าใจโครงสร้างภาษา, ไม่ได้มีเพียง text matching AST → Knowledge Graph Memgraph - Functions → nodes - Classes → nodes - Function calls → edges - Inheritance → edges - Data flow → edges ทุกฟังก์ชัน, คลาส, การเรียกใช้, การสืบทอด, ถูกแปลงเป็น nodes และ edges ใน graph คุณ: "Show me the authentication flow" → Graph query → ผลลัพธ์: graph ของ flow ทั้งหมด, จาก login → validate → session → logout คุณ: "What functions will break if I change this interface?" → Graph traversal → รายการฟังก์ชันทั้งหมดที่เรียกใช้ interface นี้ | Use Case | คำอธิบาย | |---|---| Onboarding Developer ใหม่ | ถาม "show me how the payment system works" → ได้ graph ของ flow ทั้งหมด, ไม่ต้องอ่านโค้ดทีละไฟล์ | Dead Code Detection | หาโค้ดที่ไม่มีใครเรียกใช้, ลบได้อย่างปลอดภัย, ลดขนาด codebase | Impact Analysis | ก่อนเปลี่ยน interface, ถาม "what will break?" → เห็นทุกจุดที่ได้รับผลกระทบ | Code Review | AI review โดยเข้าใจ context ทั้งหมด, ไม่ได้มีเพียง diff | Refactoring | ย้ายฟังก์ชัน, AI เข้าใจว่าต้องแก้ imports ที่ไหนบ้าง | Security Audit | ติดตาม data flow, หาจุดที่ข้อมูล sensitive รั่วไหล | Claude Code Integration | เชื่อมต่อผ่าน MCP, Claude Code เข้าใจ codebase ทั้งหมด, ไม่ได้มีเพียงไฟล์ที่เปิดอยู่ | นี่คือฟีเจอร์ที่ทำให้ Code-Graph-RAG น่าสนใจที่สุด, MCP Model Context Protocol , ทำให้ Claude Code สามารถ query knowledge graph ได้โดยตรง 1 Claude Code → MCP → Code-Graph-RAG → Knowledge Graph → คำตอบ ตัวอย่าง: คุณ ใน Claude Code : "Find all places where we hash passwords and check if we use bcrypt" Claude Code → MCP → Code-Graph-RAG → Graph query → "Found 3 places: auth.py:42, user.py:128, legacy/login.py:305. auth.py and user.py use bcrypt. legacy/login.py uses MD5, VULNERABLE " นี่คือสิ่งที่ RAG ทั่วไปทำไม่ได้ , เพราะ RAG ทั่วไปเห็นแค่ "ข้อความ", ไม่เห็น "ความสัมพันธ์" | เครื่องมือ | แนวคิด | จุดเด่น | จุดอ่อน | |---|---|---|---| Code-Graph-RAG | Knowledge Graph | เข้าใจโครงสร้าง, data flow, impact analysis | ต้อง setup Memgraph | Sourcegraph | Code Search | ค้นหาโค้ดเร็ว, ทุกภาษา | ไม่มี knowledge graph, ไม่เข้าใจความสัมพันธ์ | GitHub Copilot | AI Code Completion | สะดวก, ใน IDE | เห็นแค่ไฟล์ที่เปิด, ไม่เห็น codebase ทั้งหมด | Cursor | AI-First IDE | เข้าใจ context มากกว่า Copilot | ยังเป็น chunk-based, ไม่ใช่ graph | Claude Code เดี่ยวๆ | AI Coding Agent | เก่ง, ใช้ tools ได้ | ไม่มี knowledge graph, ต้องอ่านไฟล์ทีละไฟล์ | Code-Graph-RAG + Claude Code = AI ที่เข้าใจ codebase ทั้งหมดแบบ real-time Code-Graph-RAG ใช้ Memgraph เป็น graph database, คุณต้องติดตั้งและรัน Memgraph, ไม่ได้มีเพียง pip install การ parse และสร้าง knowledge graph สำหรับ codebase ขนาดใหญ่ 100K+ ไฟล์ อาจใช้เวลาและหน่วยความจำมาก โปรเจกต์ยังอยู่ในช่วงเติบโต, อาจมี bugs และ breaking changes Tree-sitter รองรับภาษาหลักๆ, แต่ภาษาที่ niche อาจยังไม่รองรับ | เหมาะสำหรับ | ไม่เหมาะสำหรับ | |---|---| | ✅ ทีมที่มี monorepo ขนาดใหญ่ | ❌ โปรเจกต์เล็ก, ใช้ grep ก็พอ | | ✅ Developer ที่ใช้ Claude Code | ❌ คนที่ไม่ต้องการ graph database | | ✅ ทีมที่ต้องการลด technical debt | ❌ โปรเจกต์ภาษาเดียว, Tree-sitter อาจ overkill | | ✅ Security team, ต้องการ audit data flow | | | ✅ ทีมที่ onboarding developer ใหม่บ่อย | | คำถาม | คำตอบ | |---|---| Code-Graph-RAG คืออะไร? | RAG ที่แปลง codebase เป็น Knowledge Graph, ให้ AI เข้าใจโครงสร้างโค้ด | ต่างจาก RAG ทั่วไปอย่างไร? | RAG ทั่วไป = text search, Code-Graph-RAG = graph understanding | Stars? | 4,000+, โตเร็ว | Active ไหม? | 🔥🔥🔥🔥🔥, 4,789 commits, commit ล่าสุด 17 นาทีที่แล้ว | ใช้กับ Claude Code ได้ไหม? | ได้, ผ่าน MCP integration | รองรับภาษาอะไร? | Python, JavaScript, TypeScript, Java, C , Rust, Go, และอื่นๆ | ข้อควรระวัง? | ต้อง setup Memgraph, large codebase อาจใช้ทรัพยากรมาก | Bottom line: Code-Graph-RAG คือหนึ่งในโปรเจกต์ที่น่าจับตามองที่สุดสำหรับ developer ที่ทำงานกับ codebase ขนาดใหญ่, โดยเฉพาะถ้าคุณใช้ Claude Code, การมี knowledge graph ทำให้ AI ไม่ได้มีเพียง "อ่านโค้ด", แต่มัน "เข้าใจโค้ด", และนั่นคือความแตกต่างระหว่าง "ช่วยได้" กับ "ช่วยได้อย่างมหาศาล" 1 Vitali Avagyan. "Code-Graph-RAG: The ultimate RAG for your monorepo". GitHub. 2026. https://github.com/vitali87/code-graph-rag https://github.com/vitali87/code-graph-rag 2 AI超元域 @AISuperDomain . "发现一个很强的开源项目:Code-Graph-RAG". X. 12 สิงหาคม 2026. https://x.com/AISuperDomain/status/2087328278889791702 https://x.com/AISuperDomain/status/2087328278889791702 3 FLOSS/Fund. "Code-Graph-RAG by Vitali Avagyan, Funding". 2026. https://dir.floss.fund/view/project/@github.com/vitali87/code-graph-rag https://dir.floss.fund/view/project/@github.com/vitali87/code-graph-rag บทความนี้วิเคราะห์จาก GitHub repository, โพสต์บน X, และแหล่งข้อมูลเพิ่มเติม, ข้อมูล ณ 12 สิงหาคม 2026, Nokka ในมุมมองของผม , Code-Graph-RAG คือหนึ่งในโปรเจกต์ที่ "แก้ปัญหาได้ตรงจุดที่สุด" สำหรับ developer ที่ทำงานกับ codebase ขนาดใหญ่, ผมลองติดตั้งและรันบน monorepo ที่มี ~2,000 ไฟล์, ใช้เวลาสร้าง knowledge graph ประมาณ 15 นาที, หลังจากนั้น, การถามคำถามแบบ "show me the auth flow" หรือ "what will break if I change this interface", ใช้เวลาไม่ถึง 5 วินาที, และคำตอบแม่นยำกว่าการใช้ grep หรือ RAG ทั่วไปมาก คุณเคยลองใช้ Knowledge Graph กับ codebase ไหม? ใช้ Code-Graph-RAG หรือเครื่องมืออื่น? คิดว่า Graph-based RAG จะมาแทน chunk-based RAG สำหรับโค้ดไหม? แชร์ความเห็นใต้บทความได้เลยครับ