Give Your AI Agents Long-Term Memory: The LLM Wiki Pattern Implemented in Symfony

· Clément Bertillon · Expertise · 4 minutes to read
Black green and golden computer RAM on a dark ground

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.md

However, 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 AI

Example 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:

On a dark screen, I am on Project 1 (in blue). Add a cache, like on Project 2 (in blue). Keep my Symfony preferences (in green). Write an ADR, a counter-audit todo (in yellow). Update the Jira (in red) ticket, email my CTO (in purple)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.

Ready to boost your Symfony projects with AI?

Let's start a conversation about incorporating AI into your development project. Our SensioLabs experts would love to start a conversation with you about scaling your Symfony projects.

This might also interest you

Abstract editorial illustration of PHP 8.6 JSON parsing with a highlighted error position and subtle purple accents
Oskar Stark

PHP 8.6: JSON Decode Error Position

PHP 8.6 adds a small but useful improvement to JSON decoding: you can now get the exact error position when parsing fails. That makes debugging malformed payloads much faster.

Read more : PHP 8.6: JSON Decode Error Position
Large tree under the sunlight
Mathieu Santostefano

Multiply your AI development speed using Git Worktrees

Say goodbye to context switching and the "stash-and-switch" headache. By leveraging Git Worktrees alongside modern AI agents, you can now isolate environments and handle bug fixes in parallel while your AI builds features in the background. It’s a total DX game-changer that turns your Git workflow into a multi-threaded powerhouse.

Read more : Multiply your AI development speed using Git Worktrees
A man sculpting a rock with PDF written on it
Steven Renaux

Create a Custom Builder - A GotenbergBundle Story

In a previous article, we explored how to generate your first PDF in a few lines of code using Gotenberg and GotenbergBundle, a Symfony bundle that wraps Gotenberg's HTTP API to convert HTML or Office files into PDFs. That was a great start. But what happens when your application needs to generate multiple different PDFs, each with its own layout, styles, data?

Read more : Create a Custom Builder - A GotenbergBundle Story
Nicolas Grekas standing on stage at SymfonyLive Paris 2026
Jules Daunay

SymfonyLive Paris 2026: AI Revolution and a Peak Reunion for Team SensioLabs

The final curtain has fallen on SymfonyLive Paris 2026, and we're still buzzing ✨ (and seeing lines of code). As Symfony's creator and a long-time core sponsor, SensioLabs couldn't have picked a better moment to celebrate open source, innovation, and, most importantly, the amazing community that supports us.

Read more : SymfonyLive Paris 2026: AI Revolution and a Peak Reunion for Team SensioLabs
Paper notes on a wall
Imen Ezzine

Behind the Scenes: 3 Collaborative Ceremonies for Better Development

Following a recent LinkedIn post, I wanted to write this article to describe 3 ceremonies that truly made an impact on me during one of my latest missions: Event Storming, Example Mapping, and Domain Storytelling.

Read more : Behind the Scenes: 3 Collaborative Ceremonies for Better Development
Why PHP?
Silas Joisten

Why PHP Powers the Enterprise Web: The Strategic Advantage Companies Cannot Ignore

PHP remains one of the most reliable and cost effective backend technologies for enterprise systems.

Read more : Why PHP Powers the Enterprise Web: The Strategic Advantage Companies Cannot Ignore
Symfony UX training
Elise Hamimi

Boost Your Interfaces: Learn Symfony UX with the New Official Training by SensioLabs

In just a few years, Symfony UX has become a favorite among Symfony users. Perfectly aligned with modern  developers’ priorities, it allows you to easily build interactive, high-performance interfaces without leaving the comfort of the framework. It was time to bring this to our training catalog. That’s why we are proud to officially launch our new Symfony UX training program.

Read more : Boost Your Interfaces: Learn Symfony UX with the New Official Training by SensioLabs
Fabien Potencier
Elise Hamimi

SymfonyCon Amsterdam 2025: Our Recap and the Highlights

After an iconic first edition in 2019, SymfonyCon made its big comeback to Amsterdam. From the start, you could feel the energy of a highly anticipated conference: more than 1,200 attendees, 39 nationalities, the biggest Symfony community reunion of the year, great discoveries... and a fun atmosphere. This year was extra special because it was the 20th anniversary of Symfony. SensioLabs was there: we'll tell you all about our experience there!

Read more : SymfonyCon Amsterdam 2025: Our Recap and the Highlights