Show HN: A plain-text cognitive architecture for Claude Code
TL;DR Highlight
A project that designs a hierarchical memory structure (Cognitive Architecture) based on plain-text files to address Claude Code's inability to retain memory across sessions. A practical reference for developers who want to use AI coding assistants consistently over the long term.
Who Should Read
Developers who use AI coding assistants like Claude Code or Aider daily in their work, but are frustrated by having to re-explain context every time a new session starts.
Core Mechanics
- Claude Code has no memory between sessions by default — once a conversation ends, it retains no prior context. Cog is a project that addresses this by building an external memory system composed of plain-text files.
- Instead of dumping everything into a single file, memory is divided into tiers such as 'hot (load immediately) → warm (load on demand) → cold (archive)'. This allows efficient use of the context window and enables fast access to frequently needed information.
- A dedicated 'onboarding flow' at session start and a 'shutdown flow' at session end are built in, so the AI can organize and update its own memory autonomously — similar to how a person checks their TODO list at the start of the day and writes a journal at the end.
- One of the core design philosophies of this project is that storing context-rich lessons (e.g., 'Do not mock the DB in integration tests — there was a case where tests passed but the migration failed') is far more effective than storing bare facts (e.g., 'The database is PostgreSQL 16').
- The project is similar to CLAUDE.md (the per-project instruction file officially supported by Claude Code), but adds a more sophisticated structure. Architectural decisions, file paths, and rules like 'do X / don't do Y' are systematically organized to guide Claude toward consistent behavior.
- This approach is not limited to Claude Code — it is a general-purpose pattern that applies equally to other AI coding tools such as Aider and OpenCode. Being plain-text based makes it compatible with any tool.
- Alternatives like Anthropic's official Auto Dream feature or episodic-memory exist, but Cog's differentiator is that developers can directly customize the structure and version-control the files with git.
Evidence
- "A comment pointed out reliability issues with long-term memory — if observations from 30 sessions ago and inferences drawn from a single offhand remark are stored at the same level, the memory becomes increasingly useless. A real implementation experience was shared where tagging entries with confidence scores and timestamps, decaying memories that hadn't been reinforced over time, and managing conflicting observations in a separate 'contradictions log' proved to be useful. There was also a pragmatic counterargument that a well-written CLAUDE.md alone is sufficient. A developer who heavily uses Claude Code for infrastructure work argued that 'storing lessons was far more effective than storing facts,' and that a single well-crafted CLAUDE.md can be more powerful than a complex memory architecture. A case was shared of someone implementing a far more sophisticated workflow on their own — managing separate onboarding.md, journal.md, and musings.md files, and having the AI review consistency across all documents and code before submitting a PR at the end of each session. The view was that 'treating AI as a collaborator rather than a tool yields much better results,' though the author honestly noted the significant downside of massive token consumption ('token fire'). Some expressed that Codex handles context management better than Claude, sharing a comparison experience that 'Claude drops information from its context, whereas Codex doesn't forget content even in long sessions' — which ironically validates the very reason this project exists to work around Claude Code's fundamental limitations. There was also a critical perspective that this entire approach is a superficial fix that patches LLM architectural limitations with text files. The argument was that if local open models were more competitive, this would have been solved with overnight fine-tuning — a philosophical critique pointing to the inherent limitations of the current LLM paradigm."
How to Apply
- "If you find yourself repeating the same explanations at the start of every Claude Code session, write lessons in your CLAUDE.md in the format 'don't do X + the reason why (including failure cases)' instead of plain facts. For example, including context like 'No DB mocking in integration tests — there was a past case where tests passed but the actual migration failed' will make Claude behave far more consistently. Managing all memory in a single file wastes your context window. Split files into three tiers — 'always-load (core project principles)', 'load-when-needed (per-module rules)', and 'archive (history of past decisions)' — and instruct Claude to read only the relevant files at session start to improve token efficiency. If you're concerned about the reliability of AI memory in long-running projects, get into the habit of annotating stored information with 'when it was recorded' and 'how certain it is (speculation vs. verified fact)'. When conflicting information arises, don't delete either entry — keep both in a 'conflict' section, which will help with context reconstruction later. The Cog architecture is not exclusive to Claude Code, so it applies equally if you use Aider or other AI coding tools. Check out the structure on the official Cog site (https://lab.puga.com.br/cog/) and try adopting it by simply adjusting the file conventions to fit your own tool."
Terminology
Related Papers
Show HN: OpenKnowledge – open source AI-first alternative to Obsidian/Notion
Git 기반 동기화와 Claude/Codex/Cursor 연동을 내장한 로컬 우선 마크다운 에디터로, AI 에이전트의 두 번째 뇌(LLM Wiki)로 활용할 수 있는 오픈소스 도구다.
The Unfireable Safety Kernel: Execution-Time AI Alignment for AI Agents and Other Escapable AI Systems
AI 에이전트가 자신의 안전장치를 우회할 수 없도록, 에이전트 프로세스 바깥에 수학적으로 증명된 강제 통제 게이트를 배치하는 아키텍처
RubyLLM: A Ruby framework for all major AI providers
OpenAI, Claude, Gemini 등 주요 AI 프로바이더를 단일 인터페이스로 통합한 Ruby 프레임워크로, Rails 통합과 에이전트 기능까지 지원해 Ruby 개발자가 AI 기능을 빠르게 붙일 수 있다.
Qwen-AgentWorld: Language World Models for General Agents
Alibaba Qwen 팀이 AI 에이전트가 행동 결과를 미리 시뮬레이션할 수 있는 'Language World Model'을 공개했다. 에이전트 훈련과 실행 경로 검증에 새로운 패러다임을 제시하는 연구다.
SHERLOC: Structured Diagnostic Localization for Code Repair Agents
버그 위치만 알려주는 게 아니라 '왜, 어떻게 고쳐야 하는지'까지 진단 리포트를 생성해서 코드 수정 에이전트의 성능을 높이는 training-free 프레임워크
Show HN: peerd – AI agent harness that runs entirely in your browser
백엔드 서버 없이 Chrome/Firefox 확장 프로그램으로만 동작하는 AI 에이전트 실행 환경으로, 브라우저 탭을 직접 조작하고 WASM Linux VM까지 구동할 수 있어 프라이버시와 보안을 동시에 챙길 수 있다.