Transcript
here is the truth nobody tells ai builders.
you do not need to build your own model.
all you need to build is
TLDR; if you don't wanna read it , then give this link to your agent and ask it questions to understand ➡️github.com/codejunkie99/agentic-stack
the infrastructure around the model.
The memory that persists across sessions.
The skills that encode how tasks should be done.
The protocols that govern what the agent can and cannot do.
Garry Tan posted on April 13 that nailed this point perfectly.
I spent the last three months building exactly this.
Four-layer memory.
Fat skills with self-rewrite hooks.
Protocol enforcement.
A nightly dream cycle that compresses everything the agent learned that day.
This article is 4,000 words of how I built it and why every piece exists.
If you do not want to read all that, you can just install the whole thing here:⬇️
If you just want to install it: github.com/codejunkie99/agentic-stack
Works with Claude Code, Cursor, OpenClaw, or any agent that reads markdown.
If you want to understand what you are installing and why each piece exists, keep reading.⬇️
The shape of the full stack
Here is the folder structure. I will explain each part in detail, but I want you to see the whole thing first because the shape matters more than any individual piece.
This mirrors patterns from Gstack and Claude Code's own memory hooks. I did not design it from scratch.
I arrived at it by trying other layouts that did not work and gradually converging on this one.
The key insight, and the thing Garry's post crystallized for me, is the separation.
The harness does not think. It reads files, calls tools, writes logs, runs hooks. All the intelligence lives in the skill files and the memory files. The protocols enforce boundaries.
This means:
You can swap the harness for a different one tomorrow and lose nothing
You can swap the model and lose nothing
The only things that accumulate value are the skills, the memory, and the protocols
Those are plain markdown and JSON in a git repo
The files nobody shows you (and the prompts to generate them)
Every guide shows you the folder structure. Nobody shows you what actually goes inside the four files that make or break the system. Here they are.
AGENTS.md
This is the first file the harness reads. It is the table of contents for your agent's brain. Without it, the agent does not know where anything lives.
Prompt to generate yours:
Read the folder structure at .agent/ and write an AGENTS.md that serves as the root config file. It should tell the agent where memory, skills, and protocols live, what to read first, and what rules to always follow. Keep it under 30 lines. It is a map, not an encyclopedia.
DECISIONS.md
This is the file that saves you from re-debating the same architectural choice three months later. Without it, the agent (and you) will revisit settled questions endlessly.
Prompt to generate yours:
Read memory/semantic/LESSONS.md and memory/episodic/AGENT_LEARNINGS.jsonl. Identify the 3-5 most significant architectural or workflow decisions that have been made. For each one, write an entry in DECISIONS.md with: the decision, the rationale, alternatives that were considered, and whether it is still active. Format as markdown. Only include decisions that would be costly to revisit or re-debate.
on_failure.py
This is the hook that turns failures into learning instead of just errors. Without it, failures get logged with generic pain scores and no reflection.
What it does that post_execution.py does not:
Automatically assigns high pain scores (8) so failures surface during retrieval
Counts recent failures per skill
Flags skills for rewrite after 3+ failures in 14 days
Includes error type and context so the reflection is actionable
The cron line
That is it. The dream cycle runs at 3am, compresses memory, promotes lessons, archives stale entries, and git commits the result.
Check the log:
Check the history:
That is the agent's autobiography. Every line is a night of learning.
The harness: thin conductor
I spent about 30 minutes on the first version of this. You can skip it entirely if you use Claude Code or Cursor as your harness, because they already have the loop, the tool calling, and the file watching built in. Point them at your .agent/folder and you are done.
I wanted full ownership, so I wrote the conductor myself. The entire thing is under 200 lines.
The critical function is build_context, and it deserves a mental model before you look at the priority list.
The context window is a computation box. The model only reasons over what is inside it. Everything outside it, your memory files, your skill library, your tool schemas, your entire git history, does not exist to the model unless the harness retrieves it, shapes it, and injects it.
Each piece that enters the context window is a context fragment. Each fragment is an explicit decision about what the model needs to do its work right now.
The