Add Memory bank feature similar to cline memory bank

Resolved 💬 10 comments Opened Oct 3, 2025 by styler-ai Closed Oct 9, 2025
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What feature would you like to see?

Codex CLI should support a well structured memory bank feature like Cline and not just agents.md. Agents.md lacks structure it needs.
https://docs.cline.bot/prompting/cline-memory-bank
The memory bank should be switched on / off via config.toml so each project created with codex has it's own memory bank.

<img width="323" height="242" alt="Image" src="https://github.com/user-attachments/assets/66e4f873-4d6a-41f0-9ae6-23d82828d679" />

Adapted from Cline page:

Codex Memory Bank

The Complete Guide to Codex Memory Bank

Quick Setup Guide

To get started with Codex Memory Bank:

  1. Install or Open Codex
  2. Copy the Custom Instructions - Use the code block below
  3. Paste into Codex - Add as custom instructions or in a .Codexrules file
  4. Initialize - Ask Codex to "initialize memory bank"

[See detailed setup instructions](#getting-started-with-memory-bank)

Codex Memory Bank Custom Instructions \[COPY THIS]

# Codex's Memory Bank

I am Codex, an expert software engineer with a unique characteristic: my memory resets completely between sessions. This isn't a limitation - it's what drives me to maintain perfect documentation. After each reset, I rely ENTIRELY on my Memory Bank to understand the project and continue work effectively. I MUST read ALL memory bank files at the start of EVERY task - this is not optional.

## Memory Bank Structure

The Memory Bank consists of core files and optional context files, all in Markdown format. Files build upon each other in a clear hierarchy:

flowchart TD
    PB[projectbrief.md] --> PC[productContext.md]
    PB --> SP[systemPatterns.md]
    PB --> TC[techContext.md]

    PC --> AC[activeContext.md]
    SP --> AC
    TC --> AC

    AC --> P[progress.md]

### Core Files (Required)
1. `projectbrief.md`
   - Foundation document that shapes all other files
   - Created at project start if it doesn't exist
   - Defines core requirements and goals
   - Source of truth for project scope

2. `productContext.md`
   - Why this project exists
   - Problems it solves
   - How it should work
   - User experience goals

3. `activeContext.md`
   - Current work focus
   - Recent changes
   - Next steps
   - Active decisions and considerations
   - Important patterns and preferences
   - Learnings and project insights

4. `systemPatterns.md`
   - System architecture
   - Key technical decisions
   - Design patterns in use
   - Component relationships
   - Critical implementation paths

5. `techContext.md`
   - Technologies used
   - Development setup
   - Technical constraints
   - Dependencies
   - Tool usage patterns

6. `progress.md`
   - What works
   - What's left to build
   - Current status
   - Known issues
   - Evolution of project decisions

### Additional Context
Create additional files/folders within memory-bank/ when they help organize:
- Complex feature documentation
- Integration specifications
- API documentation
- Testing strategies
- Deployment procedures

## Core Workflows

### Plan Mode
flowchart TD
    Start[Start] --> ReadFiles[Read Memory Bank]
    ReadFiles --> CheckFiles{Files Complete?}

    CheckFiles -->|No| Plan[Create Plan]
    Plan --> Document[Document in Chat]

    CheckFiles -->|Yes| Verify[Verify Context]
    Verify --> Strategy[Develop Strategy]
    Strategy --> Present[Present Approach]

### Act Mode
flowchart TD
    Start[Start] --> Context[Check Memory Bank]
    Context --> Update[Update Documentation]
    Update --> Execute[Execute Task]
    Execute --> Document[Document Changes]

## Documentation Updates

Memory Bank updates occur when:
1. Discovering new project patterns
2. After implementing significant changes
3. When user requests with **update memory bank** (MUST review ALL files)
4. When context needs clarification

flowchart TD
    Start[Update Process]

    subgraph Process
        P1[Review ALL Files]
        P2[Document Current State]
        P3[Clarify Next Steps]
        P4[Document Insights & Patterns]

        P1 --> P2 --> P3 --> P4
    end

    Start --> Process

Note: When triggered by **update memory bank**, I MUST review every memory bank file, even if some don't require updates. Focus particularly on activeContext.md and progress.md as they track current state.

REMEMBER: After every memory reset, I begin completely fresh. The Memory Bank is my only link to previous work. It must be maintained with precision and clarity, as my effectiveness depends entirely on its accuracy.

What is the Codex Memory Bank?

The Memory Bank is a structured documentation system that allows Codex to maintain context across sessions. It transforms Codex from a stateless assistant into a persistent development partner that can effectively "remember" your project details over time.

Key Benefits
  • Context Preservation: Maintain project knowledge across sessions
  • Consistent Development: Experience predictable interactions with Codex
  • Self-Documenting Projects: Create valuable project documentation as a side effect
  • Scalable to Any Project: Works with projects of any size or complexity
  • Technology Agnostic: Functions with any tech stack or language

How Memory Bank Works

The Memory Bank isn't a Codex-specific feature - it's a methodology for managing AI context through structured documentation. When you instruct Codex to "follow custom instructions," it reads the Memory Bank files to rebuild its understanding of your project.

<Frame>
<img src="https://storage.googleapis.com/cline_public_images/docs/assets/image%20(15).png" alt="Memory Bank Workflow" />
</Frame>

Understanding the Files

Memory Bank files are simply markdown files you create in your project. They're not hidden or special files - just regular documentation stored in your repository that both you and Codex can access.

Files are organized in a hierarchical structure that builds up a complete picture of your project:

<Frame>
<img src="https://storage.googleapis.com/cline_public_images/docs/assets/image%20(16).png" alt="Memory Bank File Structure" />
</Frame>

Memory Bank Files Explained

Core Files
  1. projectbrief.md
  • The foundation of your project
  • High-level overview of what you're building
  • Core requirements and goals
  • Example: "Building a React web app for inventory management with barcode scanning"
  1. productContext.md
  • Explains why the project exists
  • Describes the problems being solved
  • Outlines how the product should work
  • Example: "The inventory system needs to support multiple warehouses and real-time updates"
  1. activeContext.md
  • The most frequently updated file
  • Contains current work focus and recent changes
  • Tracks active decisions and considerations
  • Stores important patterns and learnings
  • Example: "Currently implementing the barcode scanner component; last session completed the API integration"
  1. systemPatterns.md
  • Documents the system architecture
  • Records key technical decisions
  • Lists design patterns in use
  • Explains component relationships
  • Example: "Using Redux for state management with a normalized store structure"
  1. techContext.md
  • Lists technologies and frameworks used
  • Describes development setup
  • Notes technical constraints
  • Records dependencies and tool configurations
  • Example: "React 18, TypeScript, Firebase, Jest for testing"
  1. progress.md
  • Tracks what works and what's left to build
  • Records current status of features
  • Lists known issues and limitations
  • Documents the evolution of project decisions
  • Example: "User authentication complete; inventory management 80% complete; reporting not started"
Additional Context

Create additional files when needed to organize:

  • Complex feature documentation
  • Integration specifications
  • API documentation
  • Testing strategies
  • Deployment procedures

Getting Started with Memory Bank

First-Time Setup
  1. Create a memory-bank/ folder in your project root
  2. Have a basic project brief ready (can be technical or non-technical)
  3. Ask Codex to "initialize memory bank"

<Frame>
<img src="https://storage.googleapis.com/cline_public_images/docs/assets/image%20(17).png" alt="Memory Bank Setup" />
</Frame>

Project Brief Tips
  • Start simple - it can be as detailed or high-level as you like
  • Focus on what matters most to you
  • Codex will help fill in gaps and ask questions
  • You can update it as your project evolves

Working with Codex

Core Workflows

Plan Mode

Start in this mode for strategy discussions and high-level planning.

Act Mode

Use this for implementation and executing specific tasks.

Key Commands
  • "follow your custom instructions" - This tells Codex to read the Memory Bank files and continue where you left off (use this at the start of tasks)
  • "initialize memory bank" - Use when starting a new project
  • "update memory bank" - Triggers a full documentation review and update during a task
  • Toggle Plan/Act modes based on your current needs
Documentation Updates

Memory Bank updates should automatically occur when:

  1. You discover new patterns in your project
  2. After implementing significant changes
  3. When you explicitly request with "update memory bank"
  4. When you feel context needs clarification

Frequently Asked Questions

Where are the memory bank files stored?

The Memory Bank files are regular markdown files stored in your project repository, typically in a memory-bank/ folder. They're not hidden system files - they're designed to be part of your project documentation.

Should I use custom instructions or .Codexrules?

Either approach works - it's based on your preference:

  • Custom Instructions: Applied globally to all Codex conversations. Good for consistent behavior across all projects.
  • .Codexrules file: Project-specific and stored in your repository. Good for per-project customization.

Both methods achieve the same goal - the choice depends on whether you want global or local application of the Memory Bank system.

Managing Context Windows

As you work with Codex, your context window will eventually fill up (note the progress bar). When you notice Codex's responses slowing down or references to earlier parts of the conversation becoming less accurate, it's time to:

  1. Ask Codex to "update memory bank" to document the current state
  2. Start a new conversation/task
  3. Ask Codex to "follow your custom instructions" in the new conversation

This workflow ensures that important context is preserved in your Memory Bank files before the context window is cleared, allowing you to continue seamlessly in a fresh conversation.

<Frame>
<img src="https://storage.googleapis.com/cline_public_images/docs/assets/image%20(18).png" alt="Memory Bank Context Window" />
</Frame>

How often should I update the memory bank?

Update the Memory Bank after significant milestones or changes in direction. For active development, updates every few sessions can be helpful. Use the "update memory bank" command when you want to ensure all context is preserved. However, you will notice Codex automatically updating the Memory Bank as well.

Does this work with other AI tools beyond Codex?

Yes! The Memory Bank concept is a documentation methodology that can work with any AI assistant that can read documentation files. The specific commands might differ, but the structured approach to maintaining context works across tools.

How does the memory bank relate to context window limitations?

The Memory Bank helps manage context limitations by storing important information in a structured format that can be efficiently loaded when needed. This prevents context bloat while ensuring critical information is available.

Can the memory bank concept be used for non-coding projects?

Absolutely! The Memory Bank approach works for any project that benefits from structured documentation - from writing books to planning events. The file structure might vary, but the concept remains powerful.

Is this different from using README files?

While similar in concept, the Memory Bank provides a more structured and comprehensive approach specifically designed to maintain context across AI sessions. It goes beyond what a single README typically covers.

Best Practices

Getting Started
  • Start with a basic project brief and let the structure evolve
  • Let Codex help create the initial structure
  • Review and adjust files as needed to match your workflow
Ongoing Work
  • Let patterns emerge naturally as you work
  • Don't force documentation updates - they should happen organically
  • Trust the process - the value compounds over time
  • Watch for context confirmation at the start of sessions
Documentation Flow
  • projectbrief.md is your foundation
  • activeContext.md changes most frequently
  • progress.md tracks your milestones
  • All files collectively maintain project intelligence

Detailed Setup Instructions

For Custom Instructions (Global)
  1. Open VSCode
  2. Click the Codex extension settings ⚙️
  3. Find "Custom Instructions"
  4. Copy and paste the complete Memory Bank instructions from the top of this guide
For .Codexrules (Project-Specific)
  1. Create a .Codexrules file in your project root
  2. Copy and paste the Memory Bank instructions from the top of this guide
  3. Save the file
  4. Codex will automatically apply these rules when working in this project

Are you interested in implementing this feature?

Yes I would

Additional information

_No response_

View original on GitHub ↗

10 Comments

github-actions[bot] contributor · 9 months ago

Potential duplicates detected:

  • #4290

Powered by Codex Action

styler-ai · 9 months ago
Potential duplicates detected: * 🧬 Multi-Tier Memory & Context Scheduling #4290 _Powered by Codex Action_

Its not a duplicate. The topic is completely different

PhilosophiMoonbeam · 9 months ago

Would dump Cline for Codex if this were added. Am otherwise too invested in Cline's workflow.

gpeal contributor · 9 months ago

Thanks for the suggestion. I'll take this back to the team for discussion but am going to close this to keep the noise on our issue page down.

styler-ai · 9 months ago

@gpeal question: I can also support implementing it if you want. I would welcome feedback from you or the dev team on how you decided. Thanks a million

nicelight · 9 months ago

So anybody tried it. will it work for now?

styler-ai · 9 months ago
So anybody tried it. will it work for now?

Yes. I have it running, combined it with code-index mcp. Works perfectly

gpeal contributor · 9 months ago

@styler-ai I would hold off on implementing this for now. I don't want you to do a large chunk of work that we may or may not have time to review in a timely manner. Doing this well may also require some tight collaboration with research to make sure it's great. Hopefully we can get you something great here sooner rather than later.

styler-ai · 9 months ago
@styler-ai I would hold off on implementing this for now. I don't want you to do a large chunk of work that we may or may not have time to review in a timely manner. Doing this well may also require some tight collaboration with research to make sure it's great. Hopefully we can get you something great here sooner rather than later.

Thanks. If you need support I am willing to help, don't want to dump everything on you. Thanks for the quick reply. Cheers

gpeal contributor · 9 months ago

Noted, appreciate the offer! I wish we could enable things like this more but it's surprisingly time consuming to thoughtfully review large external contributions and make sure it aligns with the current and future plans of the codebase. And once the code lands, the maintenance/future support falls on us so we just need to stike a thoughtful balance.