Agent Memory Files
Last reviewed November 12, 2026 (checked against the app).
Give hand-launched CLI sessions full CPLai context so they can recall knowledge, submit plans, and follow your team's handoff conventions - without pasting anything.
Availability: handoff recall and CPLai's larger Codex instruction-file allowance are available from 26.11.21. Web rule updates, company-folder updates and deliverable discovery are available from 26.11.22. If a control described here is missing, check your installed version under Settings -> About & updates.
What are Agent Memory Files?
When you open a terminal and run claude, codex, or agy (Antigravity) by hand, those CLI tools read instruction files from your project directory:
| CLI | File it reads |
|---|---|
| Claude Code | CLAUDE.md |
| Codex / opencode / OpenRouter CLIs | AGENTS.md |
| Antigravity | GEMINI.md |
CPLai can generate and maintain a managed block inside each of these files. The block tells the CLI how to reach the CPL API, how to search your company's knowledge vault, how to submit plans to the plan board, and where to save session handoffs and finished deliverables. Everything the CLI needs to behave like a first-class CPLai citizen.
The managed block is wrapped in HTML comment markers (<!-- CPL:MANAGED:START --> and <!-- CPL:MANAGED:END -->). CPLai replaces the generated content between those markers. Your own text is preserved; CPLai can also copy it into enabled files that have no rules of their own. See Your own rules are kept the same in every file.
You can change the Agent Memory settings and update the files from the desktop app or from the web dashboard. From the web, the always-on CPLai service writes the files, so the desktop app can be closed. See Can I change the rules from the web dashboard?.
How do I generate memory files for one project?
Open the project's Project Workspace, from Projects or from a company's Projects tab, and click the Memory Files button in the workspace header bar. This button only appears if the project has a repository directory set.
The button opens the Memory Files Wizard. The wizard also opens on its own right after you create a project.
The Wizard
The wizard shows:
-
Files to manage - three toggles, one per CLI target:
CLAUDE.md(Claude Code CLI)AGENTS.md(Codex / opencode / OpenRouter)GEMINI.md(Antigravity CLI)
Each enabled row shows a status badge:
- Will create - the file does not exist yet.
- Add CPL block at top - the file exists but has no managed block. CPLai prepends the block so the CLI reads CPLai context first.
- Update CPL block - the file already has a managed block. CPLai replaces only the content between the markers.
-
Session handoff folder - the base folder where CLI sessions should save handoff notes (for example
D:\Team Workspace\handoffs). CPLai appends the current project name. -
Artifacts folder - the base folder for finished reports, decks, generated HTML, exports, and other review deliverables (for example
D:\Team Workspace\artifacts). CPLai appends the current project name. -
Extra instructions - free-form markdown that is injected verbatim into every project's managed block. Use this for workflow rules, naming conventions, or anything else every CLI session should follow.
-
Generate / Update Files button - writes the selected files into your project directory and its attached Git worktrees (see How do memory files reach new worktrees?).
After writing, the wizard shows a status line confirming which files were written.
Tip: The wizard lets you review the settings before it writes. CPLai also refreshes the managed block on its own when agents and CLI terminal tabs launch; see When does CPLai generate memory files?.
How do I update all projects at once?
Open Settings -> Agent memory -> Agent Memory. At the bottom of the card, click Update all projects.
This opens the wizard in all-projects mode. Instead of per-file status badges, it shows an aggregate preview:
Applies to N projects - X new, Y to update, Z skipped (no folder).
Projects without a repository directory are skipped automatically.
Click Update All Projects to write memory files across every project in one pass.
The same pass also updates each company's own folder. See Do company folders get memory files?.
Can I change the rules from the web dashboard?
Availability: from 26.11.22.
Yes. Open Settings -> Agent memory -> Agent Memory in the web dashboard. The card has the same settings as the desktop card: the three file toggles, the handoff and artifacts folders, the bearer token env file and the extra instructions. A field is saved when you leave it.
Saving a setting does not change any project yet. When you are ready, click Update all projects at the bottom of the card. The always-on CPLai service writes your rules into every project's CLAUDE.md, AGENTS.md and GEMINI.md and their attached worktrees, then reports how many projects it updated, how many it skipped because they have no folder, and any file it could not write. Click Check first to see how many files would change without writing anything. The check also names the projects and company folders that would change. After the update, the report names the ones that did change, so you know where to commit the files if a project keeps them in git.
To update a single project, open the project in the web dashboard and go to its Git tab. The Memory files panel checks the project on open, lists the files that would change, and updates them with Update this project.
On Windows the service writes the files as you, the signed-in user, not as a system account. The files keep the same owner as when the desktop app writes them, the token goes into your own ~/.env, and the file contents are byte for byte what the desktop app would write.
Only you, the owner, can change these settings or run the update. Agents cannot change them through the API, because the rules become instructions for every agent and the token file setting decides where your API token is written. A development copy of CPLai never writes these files.
What goes into the managed block?
Every file (CLAUDE.md, AGENTS.md, GEMINI.md) receives the same content:
| Section | What it provides |
|---|---|
| Project Identity | Your company ID and project ID, with instructions to use them for all CPL API calls. |
| Recall Before You Ask | Endpoints for unified knowledge search (/api/knowledge/search), structured records (tickets, plans), and agent memory search. Tells the CLI to check CPLai before asking you to re-explain context. |
| Plans on the CPL Board | How to read, create and revise plans, and check off completed items. Sessions save a finished implementation plan to the project's board without asking first, then tell you its name and location. An existing plan is updated instead of duplicated. |
| API Base URL + Auth | The CPL_API_URL environment variable, the api.json port pointer file, fallback ports, and the bearer token location in your configured env file. |
| Session Handoffs & Scratch Files | Per-project folders for handoffs and review artifacts, plus the rule that agent scratch files go under CPL_AGENT_WORKSPACE. |
| Handoff Folder Structure | How sessions keep the handoff folder: an index, a common rules file, one program document per open piece of work, an archive and a scripts folder. See "How do sessions keep the handoff folder?" below. |
| Skills, Credentials & Agents | Dynamic content from your project's CPLai context - available skills, keychain entries, and the agent roster. |
| Extra Instructions | Your verbatim markdown from the wizard settings. |
How do I configure the settings?
Open Settings -> Agent memory -> Agent Memory. The card contains:
| Setting | Description |
|---|---|
| Generate CLAUDE.md | Toggle - controls whether CLAUDE.md is included when writing memory files. Default: on. |
| Generate AGENTS.md | Toggle - controls whether AGENTS.md is included. Default: on. |
| Generate GEMINI.md | Toggle - controls whether GEMINI.md is included. Default: on. |
| Session handoff folder | Text field - the base directory for handoff notes. The project name is appended when files are generated. Blank uses handoffs under your CPLai data root when one is set. |
| Artifacts folder | Text field - the base directory for finished review deliverables. The project name is appended when files are generated. Blank uses artifacts under your CPLai data root when one is set. |
| Bearer token env file | Text field - the file where CPL_Bear_Token is stored. Blank defaults to ~/.env. A Save token here button writes the token into this file if it is missing. |
| Extra instructions | Textarea - verbatim markdown added to every project's managed block. |
| Update all projects | Button - opens the all-projects wizard to create or refresh memory files across your entire portfolio. On the web dashboard the service writes the files; see Can I change the rules from the web dashboard?. |
When does CPLai generate memory files?
You can write memory files through the wizard, and CPLai also refreshes the managed block on its own:
- Project creation - when you create or import a project, CPLai opens the wizard so you can generate files for the new project.
- Manual trigger - click the Memory Files button in a project's workspace header.
- Bulk update - use the Settings card, on the desktop app or the web dashboard, to update all projects at once.
- Agent launches - each time the desktop app itself runs a project-scoped agent, CPLai re-stamps the managed block in the run's working folder before the CLI starts. Runs that go to the background service do not re-stamp.
- CLI terminal tabs - opening a Claude Code, Codex, Antigravity, or opencode terminal tab in a project folder re-stamps the managed block in that folder, at most about once a minute per folder.
The automatic refreshes use your saved Agent Memory settings. They replace the managed block and apply the own-rules synchronization only in the registered project folder. Like the wizard, they also create the per-project handoff and artifacts folders and add the API token to your token env file when it is missing.
How are handoff and artifacts folders organized?
The two folder settings are base paths. CPLai appends a filesystem-safe version of the project name when it renders that project's managed block.
For a project named CPLai:
| Base setting | Managed project folder |
|---|---|
D:\Team Workspace\handoffs |
D:\Team Workspace\handoffs\CPLai |
D:\Team Workspace\artifacts |
D:\Team Workspace\artifacts\CPLai |
Spaces and hyphens in the project name are preserved. Characters that are invalid in a folder name are removed. If a base path is blank, CPLai uses the handoffs or artifacts folder under your CPLai data root instead. Only when no data root is set does CPLai omit that instruction from the managed block.
Deliverable discovery (from 26.11.22): CPLai recall can find a deliverable in a project's artifacts folder by its file name, folder, modified date and opening text. It stores a pointer and an excerpt, not a full copy of the document, and returns the file path. Markdown, HTML, plain text and CSV files up to 2 MB contribute up to 1,200 characters of readable text. Larger files and PDF, Word (.docx), PowerPoint (.pptx) and Excel (.xlsx) files are discoverable by name, folder and date only. The scan covers the project folder and two levels of subfolders, up to 800 files per project. Images, logs and code are left out. Changes are normally picked up within about ten minutes while the service is running; removed files leave the results after the next scan. See How do I find handoffs and finished deliverables?.
When you generate memory files, CPLai also creates the per-project handoff and artifacts folders recursively. If Windows permissions prevent creation, create the displayed folder manually or choose a writable base path.
How do sessions keep the handoff folder?
The managed block teaches every CLI session one way to keep a project's handoff folder, so work on a long-running project stays easy to pick up. The folder is a small set of living documents, one per open piece of work. It is not a pile of dated session notes.
| In the handoff folder | What it holds |
|---|---|
_INDEX - START HERE.md |
One table of every open program in priority order (number, name, one-line status, hard date) and the current state of the project in a few lines. |
_COMMON - Rules and Environment.md |
Project rules, environment, merge and deploy recipes, testing and gotchas. |
PROGRAM NN - <name>.md |
One document per open or planned piece of work, numbered by priority. |
_archive/ |
Retired documents, in dated subfolders. Old handoffs are archived, never deleted. |
_scripts/ |
Every script a program still uses. Scripts are saved here, not loose in the folder or in a temp folder. |
Each program document has the same five parts in the same order: the goal, where it stands (with the date it was checked), the open work with the next step first, the rules specific to that work, and pointers to files, scripts, tickets, pull requests, plans and memory notes.
What a session does with the folder:
- At the start it reads the index and the common rules, then offers you a short list of what to work on in priority order. It reads a program document in full only once you pick that program.
- If the folder holds notes but no index it tells you, then converts the folder: it reads every note, checks each against live state, writes one program document per piece of open work, and moves the originals into
_archive/. - Before it ends it updates the program documents it touched in place, keeps the index true, and records decisions and gotchas as tickets, comments, plans or memory entries. CPLai recall searches the index, the common rules and the program documents within about ten minutes of a change. A document moved to the archive leaves the search, so a decision that matters later must also be recorded in one of those places.
- Past 15 program documents it rebuilds the folder: finished work is dropped, related programs are merged, and replaced documents go to
_archive/.
These instructions are written only when a handoff folder is configured or a CPLai data root is set.
Do company folders get memory files?
Availability: from 26.11.22.
Yes. Agents that do not work in a code folder (leadership, marketing, content and similar teams) run from their company's folder, so CPLai keeps CLAUDE.md, AGENTS.md and GEMINI.md there too.
Update all projects writes them, on the desktop app and from the web dashboard. Each company folder appears in the result as its own line, named <Company> (company folder).
| Project folder | Company folder | |
|---|---|---|
| Identity section | Company ID and project ID | Company ID only |
| Plans | Saved to this project's board | The agent lists the company's projects and picks the one the plan belongs to. If more than one fits, it asks you |
| Handoff and artifacts folders | Named after the project | Named <Company> - company |
| Skills, credentials and agents list | Included | Not included |
| Git worktrees | Also updated | Not applicable |
| Your settings, your extra instructions, recall and API details | Included | Included |
Your own text is treated the same way as in a project. See Your own rules are kept the same in every file: a file with no rules of its own is filled from the one that has them. When files disagree, CPLai updates the managed block but leaves your own text untouched and reports that it needs review.
A company folder is skipped when:
- the company is archived, or has no folder;
- the folder does not exist on disk;
- a project is registered at that same folder. The project's files win.
CPLai only reads and writes those three files. Any other file in the company folder is never touched.
Tip: If you already keep your own rules in a company folder's files and also set them as Extra instructions, they will appear twice after an update: once in the managed block and once as your own text. Remove your own copy from all three files to keep them short.
How do memory files reach new worktrees?
When you generate or update memory files for a Git project, CPLai runs the equivalent of git worktree list and writes the selected CLAUDE.md, AGENTS.md, and GEMINI.md managed blocks into the main checkout and every attached worktree that still exists on disk.
CPLai does this only when the project folder is itself the top folder of its Git repository and no other CPLai project uses the same folder. A worktree registered as another project's folder is skipped. A project folder nested inside another repository gets only its own files.
This keeps active feature branches aligned even when their instruction files have drifted. A worktree created after the last wizard run inherits whatever memory files are committed on its starting branch. Re-run the wizard after adding a new worktree if you want to guarantee that every checkout has the newest managed block.
Tip: Updating all attached worktrees can create intentional changes in more than one checkout. Review each worktree's Git status before committing.
How do I add my own content alongside the managed block?
Write anything you want in the same file, outside the marker comments. For example, in CLAUDE.md:
<!-- CPL:MANAGED:START -->
... (CPLai-generated content) ...
<!-- CPL:MANAGED:END -->
## My Custom Rules
- Always run tests before committing.
- Use conventional commit messages.
CPLai only replaces content between the markers. Your custom content is preserved across updates.
Your own rules are kept the same in every file
Each CLI reads only its own file. If your rules lived only in CLAUDE.md, an agent running on Codex or Antigravity would never see them, and an agent would lose them the day you changed its model. So when CPLai updates a project folder, it also keeps your own content in step across the files you have switched on:
- One file has your rules and the others have none. CPLai copies your rules into the files that have none. Nothing is overwritten, because those files held nothing of their own.
- All files already have the same rules. Nothing changes.
- Two files hold different rules. CPLai still updates its own block in every file, so your Agent Memory rules are current. It leaves your own text as it is, because it cannot know which version you want, and lists the project after the update with a Review button. See How do I resolve files that disagree?.
CPLai never picks a winner between files that disagree, and it never creates a file you switched off.
This copying happens only in the project folder itself. Other checkouts of the same repository receive your rules the usual way, through git, once you commit the change. CPLai does not commit anything for you.
Codex and long files. When CPLai starts Codex, Codex reads the first 64 KB of AGENTS.md. When an AGENTS.md is close to that (over 60 KB) or past it, the summary after an update names the project, because the end of the file may be cut off. Shorten your own rules in that project. A Codex you start yourself, outside CPLai, reads only the first 32 KB unless you raise project_doc_max_bytes in your Codex configuration.
How do I resolve files that disagree?
After an update, each project whose CLAUDE.md, AGENTS.md and GEMINI.md hold different text of your own is listed with a Review button. This is the same on the desktop app (in the Agent Memory wizard) and on the web dashboard (in the Update all projects panel and on a project's page).
Click Review. A side bar slides out. It compares the files by section (each heading in your text), not line by line, and one sentence at the top says what it found, for example "16 sections are only in CLAUDE.md, 12 are only in AGENTS.md". When the files differ only in spacing or blank lines, it says so, and one save makes them identical.
The sections are listed in groups:
| Group | What it holds | Color |
|---|---|---|
| In more than one file, but the text is different | Sections with the same heading whose text differs. The two versions are shown side by side with matching lines on the same row. | Matching lines green, changed lines red |
| Only in CLAUDE.md (or another file) | Sections that exist in that file and not in the others. | Red |
| Same in every file | Sections that already match. Folded away, because there is nothing to decide. | Green |
Click the arrow beside a section to read it. A file with no text of its own does not count as a disagreement; it gets the final text.
If it is not clear what the files are, click Explain the difference. CPLai sends your own text from these files to your Utility Model and shows a short answer: what each file covers, what you would lose by keeping only one, and a recommendation. Nothing is sent until you click, and the answer names the model that wrote it. Pick a local Utility Model if the text must stay on your network. When the project's company is in Local Only mode, the button works only with a local Utility Model, unless "Any model" is on for that company in Trust Center; otherwise it says so and sends nothing. Check the answer against the sections before you rely on it.
To settle it:
- Leave Keep everything selected to lose nothing: sections that match are kept once, and every section that exists in only one file is kept. This is the starting choice, and the right one when the files are different documents.
- Untick any section you do not want. For a section whose text differs, both versions are kept until you untick one; the editor tells you how many sections are still in the final text twice.
- Or click Keep only CLAUDE.md (or another file) to use that file exactly as it is.
- The Final text box shows the result. You can edit it by hand.
- Click Save to all files.
CPLai then copies the files as they were into a backup folder, writes your final text into every file, and puts its own block back on top. The result line names the backup folder.
| Detail | What happens |
|---|---|
| Backup location | <Artifacts folder>\<project>\agent-memory-backups\<date-time>\. If no artifacts folder is set, .cloudpeaklabs\agent-memory-backups\ inside the project. |
| Backup fails | Nothing is changed, and the editor says why. |
| Files switched off in Agent Memory | Left alone. Only the files you generate are compared and written. |
| Who can do this | Only you, signed in. Agents cannot read, change or ask for an explanation of these files through this editor. |
| Where it writes | Only the folder the project is registered at, never a worktree. |
Tip: Company folders are not offered for review yet. If a company folder's files disagree, the update names it and leaves your text as it is.
Troubleshooting
The Memory Files button does not appear
On the desktop app the button is in the project workspace; on the web dashboard the Memory files panel is on the project's Git tab. Both need the project to have a repository directory set. Open the project, check its settings, and make sure a valid local folder is configured.
The bearer token is not found by the CLI
Make sure the token env file setting points to a file that exists and contains CPL_Bear_Token=<your-token>. Use the Save token here button in Settings to write it automatically.
A CLI session cannot reach the CPL API
The managed block references CPL_API_URL and falls back to api.json for port discovery. If the CPLai desktop app or headless service is not running, the CLI cannot reach the API. Start the app or service first.
Related pages: Projects, Settings, Agents, Scheduling
