Give Your AI Agents Long-Term Memory: The LLM Wiki Pattern Implemented in Symfony
Every developer who uses coding assistants like Claude Code, Codex, or Antigravity on the daily knows this frustration: you spin up a prompt for a project and, once again, you have to explain everything from scratch. The agent has no clue about your Symfony architecture preferences, your PHP standards, how you structure your DTOs, your Doctrine naming conventions, or the technical decisions you nailed down on another repo last week. You end up spending more time writing preambles in your prompts than actually coding high-value features.
To cure this chronic amnesia without setting up heavy RAG (Retrieval-Augmented Generation) pipelines, complex MCP servers, or relying on proprietary cloud chat histories, there’s a simple, universal, and incredibly effective approach: pairing a global AGENTS.md setup with the LLM Wiki pattern. This concept was popularized by Andrej Karpathy, former Director of AI at Tesla and co-founder of OpenAI.
The Trap of Disposable Context in PHP Development
When you ask an AI agent to implement a component—say, a caching system on an external HTTP client—your first instinct is to write a massive, detailed prompt. Without any existing context, you have to specify the PHP version, the dependency injection rules, the chosen Symfony cache component (cache.app, Redis, a custom Adapter), and how your PHPUnit tests should be structured.
Multiply that by dozens of daily interactions, and your productivity takes a massive hit. The goal is to give the agent persistent, portable memory that's completely decoupled from the underlying LLM model.
Step 1: Structuring Instructions with a Dual-Layer AGENTS.md
The AGENTS.md file format has quickly become the go-to standard for guiding coding assistants right from your repo's root. It defines your stack, your test commands, and your team's guidelines. However, keeping this file strictly at the project level doesn't solve the issue of your own personal developer context.
The first step is to leverage two distinct instruction layers:
The project level (./AGENTS.md): Specific to the Symfony app you're currently working on. It contains project conventions, language preferences, team CI/CD rules, etc.
Example:
## Stack
- Symfony 7, PHP 8.3, Doctrine, Twig, PostgreSQL.
## Conventions
- Skinny controllers, logic kept in autowired services.
- Doctrine migrations; never use schema:update.
## Quality
- Run everything through the Makefile: make test, make stan.
- PHPStan level 8, php-cs-fixer. Zero warnings.The user level (your agents global instruction files): Shared across all your projects. Every agent has its own entry point: ~/.codex/AGENTS.md, ~/.claude/CLAUDE.md, or ~/.gemini/GEMINI.md.
This is where you define your personal preferences. For example: using PHP 8 attributes, forcing strict types (declare(strict_types=1)), Git conventions, or requiring the agent to ask for confirmation before running destructive database commands like doctrine:schema:drop.
## About me
- Clément, Tech Lead. Reply to me in French.
## Defaults (Everywhere)
- Write code and documentation in English.
- PHP/Symfony, simple monolith. PHPStan level 4 minimum.
- Never push to git without my green light.The best part? These files can all be symlinks pointing to a single source file that you only have to maintain once:
➜ ls -l ~/.codex/AGENTS.md ~/.claude/CLAUDE.md ~/.gemini/GEMINI.md
/Users/cb/.claude/CLAUDE.md -> /Users/cb/.config/AGENTS.md
/Users/cb/.codex/AGENTS.md -> /Users/cb/.config/AGENTS.md
/Users/cb/.gemini/GEMINI.md -> /Users/cb/.config/AGENTS.mdHowever, you’ll quickly hit a technical ceiling: the context window. This is the limited amount of data an AI can hold in its active memory to process and respond to queries. Anthropic and OpenAI recommend keeping these AGENTS.md files under 200 to 300 lines to prevent model saturation or the risk of hallucination from instruction overload.
Step 2: Scaling Up with the LLM Wiki Pattern
To store a larger volume of knowledge without cluttering your main instruction file, Karpathy formalized the LLM Wiki pattern.
The core idea is simple: build a Markdown-based knowledge base structured like a Wiki, stored locally, and maintained/referenced by the agent itself. No new tools to install—just a clean folder structure of text files that you can track with Git.
This pattern works beautifully for a Symfony project, and it's just as powerful for a developer's personal knowledge base. It can be organized like this:
~/knowledge/
├── projects/ # App contexts (ProjetA, API-Core, Legacy-App)
├── tech/ # PHP 8 conventions, Symfony best practices, test patterns
├── people/ # Contacts, team members, stakeholder roles
├── index.md # Global map and entry point
└── log.md # Date-stamped changelog managed by the AIExample index.md
# Personal Knowledge Index
Durable personal base, maintained as a lightweight LLM Wiki-style knowledge layer. **Do not load the whole directory** -- read this index, then open only the files relevant to the question.
## Profile
- `profile/about-me.md` -- who I am, background, side projects.
- `profile/roles-and-context.md` -- SensioLabs roles, client missions, mandates, durable context.
## Projects
- `projects/index.md` -- map of local projects and repositories, mostly under `~/Sites/`.
## People
- `people/contacts.md` -- durable professional relationship context, contact importance signals, and domain heuristics for calendar/mail prioritization.
## Tech
- `tech/php-symfony-style.md` -- durable PHP/Symfony preferences, patterns I like/refuse, architectural posture.
- `tech/code-review-preferences.md` -- recurring review criteria.
- `tech/makefile-task-runner.md` -- preference for self-documented Makefiles as project task runners and operational maps.
- `tech/docs-methodology.md` -- index of documentation surfaces (ADR, plans, audits, wiki, handoffs, articles) and where each goes; read this first, it points to the richer plan doc below.
- `tech/agent-executable-plans.md` -- global convention for where to store agent execution plans, how to number them, and how to track them with lightweight indexes.
- `tech/agentic-tools.md` -- cross-project inventory of agent-accessible tools, integrations, MCP endpoints, and usage conventions.
…Orchestration: On-Demand Injection
To get your assistants to leverage this local Wiki, you only need a single line in your ~/.config/AGENTS.md file:
- Durable personal context: `~/knowledge/` (read the index before opening anything else).When starting a new session, the agent reads the Wiki index (~/knowledge/index.md) first. Think of this index as a routing table. Depending on your current task, the agent only loads the two or three files it actually needs, rather than clogging its workspace memory with the entire folder.
Another massive benefit is maintenance. After a deep refactoring session or when nailing down a complex architectural fix, the agent can update the relevant tech doc in ~/knowledge/tech/ itself and log the change in log.md. You retain full control via simple Git commits.
In Practice: The Power of Minimalist Prompts
Once this setup is live, how you write prompts changes completely. A super concise prompt is now fully understood by your assistant:
The agent uses automatic navigation within your local Wiki to resolve each context. For each element in the prompt, the agent locates the relevant context in the specified file:
🔵 Project1/Project2 -> knowledge/projects/index.md
🟢 Symfony preferences -> knowledge/tech/php-symfony-style.md
🟡 todo -> knowledge/todo/index.md
🟣 my CTO -> knowledge/people/contacts.md
🔴 Jira -> shared configuration, skills and MCP
Tailored Memory for Cleaner Code
By pairing the clarity of a global AGENTS.md file with the flexibility of the LLM Wiki pattern, you give your coding assistants genuine long-term memory without compromising data sovereignty.
This approach perfectly aligns with the clean, maintainable philosophy of the Symfony ecosystem: no black boxes, no hidden dependencies—just plain, version-controlled text that’s human-readable and ready for any current or future LLM.