Everything under an AI coding agent, from first principles.
A first-principles map of everything under an AI coding agent: how source code is parsed into a syntax tree, how a code knowledge graph is built from it, how large language models read, how agents retrieve context over MCP, and how Koragraph ties it together. Forty concepts, each explained on its own, drawn as one graph you can walk.
Code, parsed
What a codebase actually is, and how a machine turns flat text back into structure it can reason about.
What a codebase actually is
A codebase is a large pile of interdependent text files that together describe a running system, most of whose meaning lives in the links between them rather than in any one file.
Source code as structured text
Source code is plain text that follows a strict grammar, which is what lets a machine recover structure from it that a search box never sees.
Parsing and grammars
Parsing is the act of reading text against a grammar to rebuild the tree of intent the author wrote, turning a flat string into nested structure.
The abstract syntax tree
An abstract syntax tree is the nested, typed representation of a program that a parser produces, where every construct is a node and containment is the shape.
Tree-sitter
Tree-sitter is a parser generator fast and forgiving enough to parse every file in a repository, including ones that do not currently compile.
Declaration extraction
Declaration extraction is finding every function, class, method and type a codebase defines, which is the floor every later query stands on.
Symbols, scope and binding
A symbol is a name the program gives to something, and scope is the set of rules that decides which definition a given use of that name actually refers to.
Static analysis
Static analysis is learning what a program does by reading its structure rather than by running it, which is the only way to reason about code that is never executed.
Structure, mapped
Once you have the structure, you can draw the relationships. Nodes, edges, and the questions only a graph can answer.
What a graph is
A graph is nothing more than a set of things and the connections between them, and it is the natural shape for anything whose meaning is relational.
The code knowledge graph
A code knowledge graph is a structured map of a codebase where every declaration is a node and every real relationship, calls, imports, inheritance, cross-service links, is an edge.
The call graph
A call graph records which functions call which, so that following the edges forward gives everything a function depends on and backward gives everything that depends on it.
The dependency graph
A dependency graph records which units of code rely on which others through imports and packages, at the coarser grain of files and modules rather than individual calls.
Type hierarchies and inheritance
Inheritance edges record which types are built from which others, which is what lets a graph answer a question asked of a base type about all the code that specialises it.
Cross-service edges
A cross-service edge is a dependency that leaves one repository or service and lands in another, which is exactly where single-repository tooling goes silent.
Blast radius
Blast radius is everything that could break if you change one piece of code, including the paths that cross a repository boundary and the ones no test covers.
Git history and co-change
Git co-change is the fact that two pieces of code keep being edited in the same commits, which reveals coupling no parser can see because it lives in convention, not syntax.
Machines that read language
What a large language model is from the ground up: tokens, embeddings, attention, the context window, and where it goes wrong.
What a large language model is
A large language model is a function that, given some text, predicts the next token, trained on so much text that doing this well requires it to model a great deal about the world.
Tokens and tokenization
A token is the unit a model actually reads, a fragment of text between a character and a word, and tokenization is the reversible way text is chopped into them.
Embeddings and vector space
An embedding is a list of numbers that places a piece of text at a point in space, positioned so that things close in meaning sit close together.
The transformer and attention
The transformer is the architecture behind modern language models, and attention is its central trick: letting every token look at every other token to decide what matters.
The context window
The context window is the fixed amount of text a model can consider at once, and it is a budget to be spent well rather than a container to be filled.
Training and inference
Training is the slow, expensive process of fitting a model to data once, and inference is the fast, repeated process of using it, and confusing the two explains most misunderstandings about what a model can know.
Hallucination and grounding
A model hallucinates when it produces fluent text that is not true, and grounding is the practice of feeding it real facts so its answer is anchored to something checkable.
Prompt and context engineering
Prompt engineering is wording the request well, and context engineering is the larger discipline of deciding what information the model gets to see at all.
Retrieval and agents
How a model is turned into something that acts: retrieval, tools, planning, and memory that survives the conversation.
Retrieval-augmented generation
Retrieval-augmented generation is the pattern of looking up relevant information and putting it in the context window before the model answers, so the answer rests on fetched facts.
Vector search and similarity
Vector search finds text by nearness in embedding space rather than by matching words, which is powerful for prose and quietly wrong for code, where the caller and the callee rarely share vocabulary.
GraphRAG for code
GraphRAG for code is retrieval that walks a graph of the codebase to assemble context, following real edges out from a node instead of returning the chunks that scored highest for similarity.
What an AI agent is
An AI agent is a language model placed in a loop where it can take actions, see the results, and decide what to do next, which is what turns a text generator into something that gets work done.
Tool use and function calling
Tool use is the mechanism by which a model asks for an action to be performed, a search to be run or a function to be called, and receives the result back as text it can reason over.
Reasoning and planning
Reasoning is a model working through a problem in steps before answering, and planning is it deciding a sequence of actions, both of which improve sharply when the model is given the right facts to reason over.
Agentic coding
Agentic coding is letting an agent read, write and run code in a loop, which shifts the bottleneck from typing to giving the agent an accurate picture of the system it is editing.
Memory for agents
Memory is what lets an agent keep a fact past the end of a conversation, so a lesson learned once, a fix that worked, a hazard, does not have to be rediscovered on every session.
Koragraph's stack
The protocol, the local store, the ingest pipeline, and the reasons a resolved graph beats text search for code.
The Model Context Protocol
The Model Context Protocol is an open standard that lets any AI model reach any external tool or data source through one common interface, so a data source is built once and every client can use it.
MCP servers and clients
In MCP the agent is the client and the thing it reaches is the server, and a local server is the right shape whenever the data, such as your source code, should never leave the machine.
Tools, resources and prompts
An MCP server offers three things: tools the agent can call, resources it can read, and prompts it can reuse, and most of the useful surface of a code server is its tools.
Local-first, offline by design
A local-first tool does its work on your own machine with no cloud round trip, which for source code is not a feature but a requirement, and it also happens to be faster and to work on a plane.
SQLite as the store
SQLite is a full relational database that lives in a single file with no server, which makes it the natural home for a code graph that has to persist on your machine across sessions and follow renames.
The ingest pipeline
Ingest is the pass that turns a pile of repositories into one graph: parse with tree-sitter, extract declarations, resolve every edge, mine the git history, and write it all to the local store.
Graph vs grep vs embeddings
Text search finds strings that look alike and vector search finds text that means something similar, but only a resolved graph can answer what is actually connected to what, which is the question code work turns on.
The context layer
A context layer sits between your codebase and your agent and decides what the agent sees for a given question, which is the job Koragraph exists to do and the point every other concept here builds toward.
