Skip to content

Instantly share code, notes, and snippets.

@es-repo
es-repo / llm-wiki.md
Created April 4, 2026 17:36 — forked from karpathy/llm-wiki.md
llm-wiki

LLM Wiki

A pattern for building personal knowledge bases using LLMs.

This is an idea file, it is designed to be copy pasted to your own LLM Agent (e.g. OpenAI Codex, Claude Code, OpenCode / Pi, or etc.). Its goal is to communicate the high level idea, but your agent will build out the specifics in collaboration with you.

The core idea

Most people's experience with LLMs and documents looks like RAG: you upload a collection of files, the LLM retrieves relevant chunks at query time, and generates an answer. This works, but the LLM is rediscovering knowledge from scratch on every question. There's no accumulation. Ask a subtle question that requires synthesizing five documents, and the LLM has to find and piece together the relevant fragments every time. Nothing is built up. NotebookLM, ChatGPT file uploads, and most RAG systems work this way.

@es-repo
es-repo / better-unit-test-in-c#-article-FillBoxTest.cs
Created July 28, 2022 22:11
better-unit-test-in-c#-article-FillBoxTest.cs
public static class FillBoxTest
{
public sealed record Args
{
public IBox Box { get; init; } = null!;
public Dictionary<string, Thing> LabelsAndThings { get; init; } = new();
public WriteLog WriteLog { get; init; } = null!;
}
sealed class TestCases : IEnumerable<object[]>
static object[] BoxAndLabelsAndThings_OpenBoxThenPutThingInsideThenCloseBoxAndWriteLogs_ThingsWithLabelEndedWithIgnoreExpected_1()
{
var writeLogMock = new Mock<WriteLog>(MockBehavior.Strict);
var boxMock = new Mock<IBox>(MockBehavior.Strict);
var mockSequence = new MockSequence();
boxMock.InSequence(mockSequence).Setup(box => box.Open());
writeLogMock.InSequence(mockSequence).Setup(writeLog => writeLog("The box is opened."));
boxMock.InSequence(mockSequence).Setup(box => box.PutInside(new Thing { Size = 1 }, "Label 1")).Returns(true);
@es-repo
es-repo / better-unit-test-in-c#-article-mock-sequences.cs
Last active July 28, 2022 22:23
better-unit-test-in-c#-article-mock-sequences.cs
var mockSequence = new MockSequence();
boxMock.InSequence(mockSequence).Setup(box => box.Open());
writeLogMock.InSequence(mockSequence).Setup(writeLog => writeLog("The box is opened."));
boxMock.InSequence(mockSequence).Setup(box => box.PutInside(new Thing { Size = 1 }, "Label 1")).Returns(true);
boxMock.InSequence(mockSequence).Setup(box => box.PutInside(new Thing { Size = 2 }, "Label 2 Ignore")).Returns(false);
boxMock.InSequence(mockSequence).Setup(box => box.PutInside(new Thing { Size = 3 }, "Label 3")).Returns(true);
boxMock.InSequence(mockSequence).Setup(box => box.Close());
writeLogMock.InSequence(mockSequence).Setup(writeLog => writeLog("The box is closed."));
@es-repo
es-repo / better-unit-test-in-c#-article-mock-sequence.cs
Last active July 28, 2022 22:04
better-unit-test-in-c#-article-mock-sequence.cs
var writeLogMock = new Mock<WriteLog>(MockBehavior.Strict);
var boxMock = new Mock<IBox>(MockBehavior.Strict);
boxMock.InSequence(mockSequence).Setup(box => box.Open());
writeLogMock.InSequence(mockSequence).Setup(writeLog => writeLog("The box is opened."));
boxMock.InSequence(mockSequence).Setup(box => box.PutInside(new Thing { Size = 1 }, "Label 1")).Returns(true);
boxMock.InSequence(mockSequence).Setup(box => box.PutInside(new Thing { Size = 2 }, "Label 2 Ignore")).Returns(false);
boxMock.InSequence(mockSequence).Setup(box => box.PutInside(new Thing { Size = 3 }, "Label 3")).Returns(true);
boxMock.InSequence(mockSequence).Setup(box => box.Close());
writeLogMock.InSequence(mockSequence).Setup(writeLog => writeLog("The box is closed."));
@es-repo
es-repo / better-unit-test-in-c#-article-mocks.cs
Created July 28, 2022 21:59
better-unit-test-in-c#-article-mocks.cs
var writeLogMock = new Mock<WriteLog>(MockBehavior.Strict);
var boxMock = new Mock<IBox>(MockBehavior.Strict);
@es-repo
es-repo / better-unit-test-in-c#-article-FillBoxTest-TestCases-layout.cs
Last active July 26, 2022 22:59
better-unit-test-in-c#-article-FillBoxTest-TestCases-layout.cs
sealed class TestCases : IEnumerable<object[]>
{
public IEnumerator<object[]> GetEnumerator()
{
yield return BoxAndLabelsAndThings_OpenBoxThenPutThingInsideThenCloseBoxAndWriteLogs_ThingsWithLabelEndedWithIgnoreExpected_1();
}
static object[] BoxAndLabelsAndThings_OpenBoxThenPutThingInsideThenCloseBoxAndWriteLogs_ThingsWithLabelEndedWithIgnoreExpected_1()
{
...
@es-repo
es-repo / better-unit-test-in-c#-article-FillBoxTest-layout.cs
Last active July 28, 2022 21:54
better-unit-test-in-c#-article-FillBoxTest-layout.cs
public static class FillBoxTest
{
public sealed record Args
{
public IBox Box { get; init; } = null!;
public Dictionary<string, Thing> LabelsAndThings { get; init; } = new();
public WriteLog WriteLog { get; init; } = null!;
}
sealed class TestCases : IEnumerable<object[]>
@es-repo
es-repo / better-unit-test-in-c#-article-Operations-FillBox.cs
Last active July 28, 2022 21:49
better-unit-test-in-c#-article-Operations-FillBox.cs
public static class Operations
{
public static Dictionary<string, Thing> FillBox(
IBox box,
IDictionary<string, Thing> labelsAndThings,
WriteLog writeLog)
{
var rest = new Dictionary<string, Thing>();
box.Open();
writeLog("The box is opened.");
@es-repo
es-repo / better-unit-test-in-c#-article-IBox-and-WriteLog.cs
Last active July 28, 2022 21:48
better-unit-test-in-c#-article-IBox-and-WriteLog.cs
public interface IBox
{
int Size { get; }
void Open();
void Close();
bool PutInside(Thing thing, string label);
}
public delegate void WriteLog(string message);