Cog: Add Persistent Memory and Self-Reflection to Claude Code with Just Markdown

Cog: Add Persistent Memory and Self-Reflection to Claude Code with Just Markdown

Cog is a plain-text cognitive architecture for Claude Code that adds persistent memory, self-reflection, and foresight using only CLAUDE.md files—no servers or dependencies.

12h ago·4 min read·22 views·via hn_claude_code
Share:

Cog: Add Persistent Memory and Self-Reflection to Claude Code with Just Markdown

What It Does — A Text-Based Cognitive Architecture

Cog is an open-source framework that transforms Claude Code from a session-based assistant into a continuously aware agent with memory, self-reflection, and foresight. Unlike complex agent frameworks requiring servers or runtimes, Cog implements everything through plain Markdown files in your project's .claude/ directory.

The system organizes knowledge into three memory tiers:

  • Hot Memory (memory/hot-memory.md): Always loaded (under 50 lines). Contains current priorities, active situations, and system notes.
  • Warm Memory (memory/personal/, memory/work/): Domain-specific files loaded when relevant skills activate.
  • Glacier Memory (memory/glacier/): Archived, indexed content retrieved on demand via YAML frontmatter.

Setup — One Command to Get Started

Getting Cog running takes less than a minute:

git clone https://github.com/marciopuga/cog
cd cog

Open the project in Claude Code, then type:

/setup

Cog will initiate a conversation about your life and work—company, side projects, what you want to track. From that conversation, it generates:

  • Domain manifests
  • Memory directory structure
  • Skill files
  • Routing tables

Cog ships with .claude/settings.json pre-configured to approve the tools it needs (file reads, writes, edits, search, and git operations). When you first open the project, Claude Code will ask you to accept these project-level permissions. Accept once and you won't be interrupted again.

How It Works in Practice — Memory That Builds Over Time

Here's what emerges from your conversations with Claude Code after installing Cog:

Hot Memory Example (memory/hot-memory.md):

# Hot Memory
<!-- L0: Current priorities, active situations, system notes -->

## Identity
- Software engineer at Acme Corp, 2 kids, based in Melbourne
- Side project: open-source CLI tools

## Watch
- Performance review cycle opens next week — prep doc started [[work/acme/action-items]]
- Kid's speech therapy showing progress — 3 new words this month [[personal/health]]

## System
- /reflect found 3 observation clusters ready to promote to patterns

Observations Log (memory/personal/observations.md):

- 2026-03-10 [family]: School called — Gabe had a great day, shared toys unprompted for the first time
- 2026-03-11 [health]: Ran 5k in 28min. Knee felt fine. Third run this week without pain.
- 2026-03-12 [insight]: Realized I've been avoiding the budget conversation. Not about money — about control

Action Items (memory/personal/action-items.md):

- [ ] Review Q3 OKRs with team — due 2026-03-15
- [ ] Call dentist for cleaning appointment — due 2026-03-20
- [x] Submit conference talk proposal — completed 2026-03-08

Why Text-Only Architecture Matters

Cog's plain-text design has several advantages for Claude Code users:

  1. Full Observability: You can see exactly how Claude organizes knowledge and where self-improvement succeeds or fails.
  2. Zero Lock-in: Your memories remain accessible even if you stop using Cog.
  3. Git-Compatible: All changes are tracked through your existing version control workflow.
  4. No Performance Overhead: Unlike vector databases or external services, text files add minimal latency.

When To Use It — Specific Workflows That Benefit

Cog shines in these Claude Code scenarios:

  • Long-running projects: Maintain context across weeks or months of development
  • Personal knowledge management: Track insights, decisions, and progress alongside code
  • Team onboarding: Share domain knowledge and project history with new team members
  • Reflective development: Analyze patterns in your coding habits and decision-making

The Self-Improvement Experiment

Beyond memory, Cog attempts something more ambitious: giving Claude the ability to self-evolve. The system includes mechanisms for:

  • Reflecting on its own behavior
  • Auditing its own rules
  • Improving how it operates over time

This happens through periodic /reflect commands that analyze observation clusters and promote them to patterns, creating a feedback loop where Claude Code gets better at helping you.

Getting Started Today

If you use Claude Code daily and want continuity between sessions, Cog provides the simplest possible implementation. The entire system lives in your project directory, works with your existing workflow, and gives you complete transparency into how Claude remembers and reasons about your work.

Clone the repository, run /setup, and start building a memory system that grows with your projects.

AI Analysis

Claude Code users should install Cog today if they work on projects spanning multiple sessions or want to maintain personal context alongside code. The key workflow change is treating Claude Code not as a fresh start each time but as a continuous assistant with memory. Start by running `/setup` and answering the initial questions thoroughly—this creates your foundational memory structure. Then, make it a habit to reference your memory files in prompts. Instead of explaining your project from scratch each session, you can say "Check memory/hot-memory.md for current priorities" or "Update memory/work/observations.md with today's deployment results." The most powerful pattern is using Cog's append-only observation logs for decision tracking. Before making significant architectural decisions with Claude Code, log your reasoning in the observations file. Later, you can ask Claude to analyze these logs for patterns in your decision-making process, creating a self-improvement loop. For team projects, consider committing the memory directory (excluding personal files) to version control. This creates a shared knowledge base that evolves with the codebase, making onboarding new developers dramatically faster as Claude can reference the entire project history.
Original sourcegithub.com

Trending Now

More in Products & Launches

View all