Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
TypeScript antigravity-skillsbusiness-knowledgeclaude-codeclaude-skillscodebase-analysiscodexcodex-skillsdeveloper-tools-ai-agentgemini-cli-skillskarpathy-llm-wikiknowledge-baseknowledge-graphmemoryopencode-skillspi-agentunderstandcodevibe-coding
import type { KnowledgeGraph } from "@understand-anything/core";
import { buildChatContext, formatContextForPrompt } from "./context-builder.js";
/**
* Build a complete chat prompt by combining knowledge graph context
* with a system instruction for answering codebase questions.
*/
export function buildChatPrompt(
graph: KnowledgeGraph,
query: string,
): string {
const context = buildChatContext(graph, query);
const formattedContext = formatContextForPrompt(context);
return [
"You are a knowledgeable assistant that answers questions about a software codebase.",
"Use the following knowledge graph context to inform your answer.",
"Reference specific files, functions, classes, and relationships from the graph.",
"If layers are present, explain which architectural layer(s) are relevant.",
"Be concise but thorough — link concepts to actual code locations.",
"",
"---",
"",
formattedContext,
"---",
"",
`**User question:** ${query}`,
].join("\n");
}