<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aravind Raghu</title>
    <description>The latest articles on DEV Community by Aravind Raghu (@aravind_raghu_cbd9af04543).</description>
    <link>https://dev.to/aravind_raghu_cbd9af04543</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4020386%2F0ab20bf4-f9de-47b0-82f7-aaedbe5a2aa1.png</url>
      <title>DEV Community: Aravind Raghu</title>
      <link>https://dev.to/aravind_raghu_cbd9af04543</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aravind_raghu_cbd9af04543"/>
    <language>en</language>
    <item>
      <title>I built a persistent memory layer for AI coding agents (and it fits in a markdown file)</title>
      <dc:creator>Aravind Raghu</dc:creator>
      <pubDate>Wed, 08 Jul 2026 02:47:39 +0000</pubDate>
      <link>https://dev.to/aravind_raghu_cbd9af04543/i-built-a-persistent-memory-layer-for-ai-coding-agents-and-it-fits-in-a-markdown-file-3gol</link>
      <guid>https://dev.to/aravind_raghu_cbd9af04543/i-built-a-persistent-memory-layer-for-ai-coding-agents-and-it-fits-in-a-markdown-file-3gol</guid>
      <description>&lt;p&gt;Every AI coding session starts blank.&lt;/p&gt;

&lt;p&gt;You open Cursor. You open Claude. You paste your architecture doc. &lt;br&gt;
You re-explain your folder structure. You describe your patterns again.&lt;br&gt;
Then the context window fills up and you start over.&lt;/p&gt;

&lt;p&gt;For small projects, annoying. For large codebases, it's a real productivity &lt;br&gt;
killer.&lt;/p&gt;

&lt;h2&gt;
  
  
  The insight
&lt;/h2&gt;

&lt;p&gt;The problem isn't the AI. It's that there's no persistent, structured &lt;br&gt;
summary of your codebase that travels with the repo.&lt;/p&gt;

&lt;p&gt;So I built one.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Cortex does
&lt;/h2&gt;

&lt;p&gt;Cortex maintains a single file — &lt;code&gt;CORTEX_MEMORY.md&lt;/code&gt; — committed directly &lt;br&gt;
to your repo. It summarizes every source file: what it does, its key &lt;br&gt;
functions, dependencies, and gotchas.&lt;/p&gt;

&lt;p&gt;On each session, it only re-summarizes &lt;strong&gt;changed files&lt;/strong&gt; using SHA-256 &lt;br&gt;
hash diffing. Everything else is cached. So after the first run, it's &lt;br&gt;
fast and cheap.&lt;/p&gt;

&lt;p&gt;You paste the file into any AI assistant. It understands your whole &lt;br&gt;
codebase instantly.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;cortex-agent
cortex init
cortex run
&lt;span class="c"&gt;# CORTEX_MEMORY.md is generated&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each file gets a structured summary:&lt;br&gt;
src/auth/jwt.py&lt;br&gt;
Purpose: Handles JWT token generation, validation, and refresh.&lt;/p&gt;

&lt;p&gt;Key functions: generate_token, validate_token, refresh_token&lt;/p&gt;

&lt;p&gt;Dependencies: python-jose, datetime, os&lt;/p&gt;

&lt;p&gt;Notes: Tokens expire in 24h. Refresh tokens use a separate secret key.&lt;br&gt;
On the next run, if &lt;code&gt;jwt.py&lt;/code&gt; hasn't changed — no API call. Free.&lt;br&gt;
If it changed — one targeted API call to re-summarize just that file.&lt;/p&gt;

&lt;h2&gt;
  
  
  The staleness problem (and how I solved it)
&lt;/h2&gt;

&lt;p&gt;The hardest part wasn't summarization. It was keeping the memory fresh.&lt;/p&gt;

&lt;p&gt;Options I considered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;File watcher&lt;/strong&gt; — too noisy, expensive (LLM call on every save)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Git hooks&lt;/strong&gt; — only fires on commit, misses mid-session changes
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manual&lt;/strong&gt; — nobody does it consistently&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Solution: &lt;strong&gt;hash check on session start.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On every &lt;code&gt;cortex run&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;SHA-256 hash all source files&lt;/li&gt;
&lt;li&gt;Compare against stored hashes from last run&lt;/li&gt;
&lt;li&gt;Re-summarize only mismatches&lt;/li&gt;
&lt;li&gt;Prune entries for deleted/renamed files&lt;/li&gt;
&lt;li&gt;Write updated memory + hashes&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Simple, reliable, cheap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Token limits (alpha is conservative)
&lt;/h2&gt;

&lt;p&gt;I deliberately set tight defaults to prevent surprise bills:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Limit&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Per-file budget&lt;/td&gt;
&lt;td&gt;2,000 tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Per-session budget&lt;/td&gt;
&lt;td&gt;10,000 tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Max file size&lt;/td&gt;
&lt;td&gt;100 KB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Max files per run&lt;/td&gt;
&lt;td&gt;50&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;At these limits, a session costs ~$0.003 on GPT-4o mini.&lt;br&gt;
1,000 users × 10 sessions/day = ~$15/day total.&lt;/p&gt;

&lt;h2&gt;
  
  
  Works with any AI tool
&lt;/h2&gt;

&lt;p&gt;No lock-in. Cortex generates plain markdown. Paste it into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cursor&lt;/li&gt;
&lt;li&gt;Claude&lt;/li&gt;
&lt;li&gt;ChatGPT&lt;/li&gt;
&lt;li&gt;Copilot Chat&lt;/li&gt;
&lt;li&gt;Anything&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;MCP server integration (auto-inject into Cursor/Claude Code)&lt;/li&gt;
&lt;li&gt;Multi-model support (Claude, local models via Ollama)&lt;/li&gt;
&lt;li&gt;Failure memory — storing what &lt;em&gt;didn't&lt;/em&gt; work and why&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/aravindr-res01/cortex" rel="noopener noreferrer"&gt;https://github.com/aravindr-res01/cortex&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Would love feedback — especially from anyone working on large codebases &lt;br&gt;
where context limits are a real pain. What would make this actually fit &lt;br&gt;
into your workflow?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devtools</category>
      <category>openai</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
