How do you fit an entire codebase into a prompt?
Every model has a token limit. A mid-sized repo can run to tens of millions of tokens.
Our answerGraph queries select only the relevant part of the codebase for each task.
Built for engineering leaders facing a legacy re-platform, or an AI rollout on a large, multi-language codebase. Anyone can point an LLM at a repository and generate code. What’s hard is knowing what that code should do — and whether it’s correct. We map your system into a knowledge graph, so AI works with your architecture, not against it.
Multiple languages, integrations and poor documentation. If you don’t know how the pieces connect, browsing the repo becomes guesswork — for your engineers and for your AI tools.
C++, Java, Python, JavaScript and shell — each with its own conventions.
Maven, npm, Make and friends, quietly deciding what actually ships.
The wiring that makes components talk, rarely written down.
Fixtures and mocks that encode assumptions about behaviour.
Environment-specific switches that change how code runs.
Code nobody wrote by hand — and nobody wants to read.
Every model has a token limit. A mid-sized repo can run to tens of millions of tokens.
Our answerGraph queries select only the relevant part of the codebase for each task.
Left unchecked, it drifts — inventing functions and starting doom loops.
Our answerPrompts are grounded in deterministic structure extracted from your code.
Standards and patterns live in people’s heads, not in the model.
Our answerResponses are parsed and checked against the patterns stored in the graph.

George Jayaratnam
Founder · Sydney, Australia
MCMC Graph Co is led by George Jayaratnam: 25+ years building risk models and the data systems behind them in financial markets, now applying the same discipline to codebases.
GraphRAG combines a knowledge graph grounded in your own code and data with a large language model. We use it the way we use compilers and databases — as a tool grounded in structure, not guesswork.
Where we focus first
Large, complex codebases with multiple languages, integrations, and poor documentation.
We build two knowledge graphs of your codebase without any LLMs. Only then do we bring in a model — and check everything it says against the graphs.
Deterministic · no LLMs
Database schema metadata ingested straight into a graph model.
Language-specific parsers map functions, parameters and services across files and repos.
Probabilistic
Explain or refactor code with exactly the context it needs — nothing more.
Validation loop. Every LLM response is parsed and compared against the patterns and standards in the knowledge graphs — before anyone has to review it.
A deterministic, modular build system that maps an entire codebase into a graph. Graph queries then prompt LLMs to refactor code, which is checked against a new, pre-specified schema.
graphrag-code-kg/
├── pyproject.toml
├── README.md
├── .env
├── notebooks/ # Experiments + presentations
├── src/
│ └── codebase_kg/
│ ├── services/ # Backend integration APIs
│ │ ├── neo4j_services.py # Neo4j connection
│ │ ├── neo4j_cypher.py # Cypher query runner
│ │ └── github_repo_service.py # Repo metadata via GitHub API
│ ├── cli/ # Thin interface layer
│ │ ├── cli.py # Auto-scans ./commands
│ │ └── commands/
│ │ ├── neo4j.py # CLI → Neo4j service
│ │ └── repo.py # CLI → GitHub service
│ ├── schemas/ # Software architecture schemas
│ ├── data_kg/ # Database metadata ingestion
│ │ ├── extract/ # Connectors + foreign-key logic
│ │ ├── transform/ # Raw metadata → graph model
│ │ ├── load/ # Bulk CSV → Neo4j
│ │ └── pipeline.py # Builds the Data KG
│ ├── app_kg/ # Business-logic metadata ingestion
│ │ ├── repo_metadata/ # Directory structure + file types
│ │ ├── parsers/ # Language-specific AST extraction
│ │ ├── codesearch/ # Cross-file usage + invocations
│ │ ├── transform/ # Raw metadata → graph model
│ │ ├── load/ # Bulk CSV → Neo4j
│ │ └── pipeline.py # Builds the Application KG
│ ├── neo4jImports/ # CSV files for Neo4j
│ └── graph_queries/ # Deterministic graph intelligence
│ ├── shortest_join_paths.cypher
│ ├── application_logic.cypher
│ └── dependency_paths.cypher
├── tests/ # Test-driven development
├── graphrag/ # Graph ↔ LLM interaction
│ ├── embeddings/
│ ├── retrievers/
│ ├── prompt_builders/
│ └── response_synthesis/
└── docs/ # Code documentation site
Practical write-ups on codebase knowledge graphs, GraphRAG and AI-assisted refactoring.
In my previous post, I suggested that reverse engineering legacy software into a Codebase KG could give an LLM the right context to perform a task. However a Codebase KG only gives you application code artifacts and the relationships between them. There is still an analytical task that needs to be undertaken to analyse the codebase. So what's the best way to examine a codebase and describe its' system context?
The biggest mistake you can make when using an LLM on a large codebase is giving it too much code. An LLM doesn't need the entire codebase in its context window. It needs the right parts of the codebase, the right system context, and a clear task objective.
Refactoring code with LLMs isn’t new. But standard prompting quickly runs into some fundamental problems when you move beyond small, self-contained codebases:
Request a discovery call. We’ll talk through your system, where it hurts, and whether a Codebase Knowledge Graph is the right fit.