DEV Community

Cover image for I got tired of explaining the same architecture to AI every single day. So I built something different: AI Dimag.
Anup Khanal
Anup Khanal

Posted on

I got tired of explaining the same architecture to AI every single day. So I built something different: AI Dimag.

AI agents are powerful, but they forget everything. Here's how I solved it with falsifiable evidence.

The Problem I Couldn't Ignore

It was 2am, and I was staring at my screen in frustration.

For the third time that week, I was re-explaining the same architectural decisions to Claude. "All database access goes through src/db/store.ts." "We tried microservices approach X and it failed." "Auth flows through this single module."

The AI would understand, help me code for a few hours, then... forget everything by the next session or next chat.

That's when I realized: AI coding agents have amnesia.

Everyone's Building Memory Wrong

I looked at existing solutions. Tools like Mem0, MemGPT, and various context providers were storing information. But they all had the same fatal flaw:

They never verified if their memories were still true.

Think about it: Your codebase changes constantly. That architectural decision from last month? Someone might have violated it yesterday. That "never use library X" rule? A junior dev might have added it in a PR this morning.

Static memory files like .cursorrules or CLAUDE.md go stale the moment you write them. And stale information is worse than no informationโ€”it actively misleads your AI.

The Insight: Memory Needs Evidence

While building AI platforms at REI (AI Nexus with self-hosted Ollama models, and the GSA Virtual Helpdesk Chatbot with OpenAI), I learned something critical:

AI models are only as trustworthy as the information you give them.

GPT-5, Claude 5, even the upcoming GPTsโ€”they're all incredibly powerful. But feed them outdated context, and they'll confidently generate wrong code.

I needed a system where every memory could prove it was still true.

Building AI Dimag

I spent the last few months building AI Dimag. The core idea is simple but powerful:

Every memory carries falsifiable evidence that gets re-verified.

Here's how it works:

dim remember "All DB access goes through src/db/store.ts" \
  -k INVARIANT \
  -e "STATIC_CHECK:grep -rL 'store.ts' src --include=*.ts"
Enter fullscreen mode Exit fullscreen mode

This memory includes a shell command as evidence. When you run dim verify, it re-executes that command. If someone added direct database access elsewhere, the evidence fails, and the memory goes STALE.

Five Types of Evidence

I designed five evidence types based on what actually matters in software development:

  1. STATIC_CHECK - Shell commands that verify code patterns
  2. TEST_RESULT - Unit/integration tests that must pass
  3. COMMIT_REF - Anchored to specific commits (detects drift)
  4. EXEC_TRACE - Runtime behavior validation
  5. HUMAN_ATTESTED - Manual confirmation with confidence decay

Each type serves a different purpose, but they all answer the same question: "Is this still true?"

Human-Gated Capture

Here's another critical insight: Not everything should become memory.

AI Dimag mines your commits, PRs, and AI chat transcripts into proposals. But nothing enters memory until you review and approve it.

dim review  # Interactive approval workflow
Enter fullscreen mode Exit fullscreen mode

The system auto-triages proposals by confidence score. You can batch-approve high-confidence items:

dim review approve all --min-score 0.7
Enter fullscreen mode Exit fullscreen mode

This prevents garbage accumulation and ensures your memory stays high-quality.

AiDimag dashboard and list of memories in IDE

Works With Every AI Tool

I didn't want to bet on one AI tool winning. So AI Dimag works two ways:

For MCP-compatible tools (Claude, Cursor):

  • Real-time memory via Model Context Protocol
  • Tools like memory_search, memory_propose, memory_critique
  • Session-start briefings and session-end extraction

For non-MCP tools (Copilot, Windsurf):

  • Generates static context files (.cursorrules, CLAUDE.md, AGENTS.md)
  • Auto-refresh with --auto flag
  • Always up-to-date with verified memory

Team Sync: Shared Knowledge Graphs

Individual memory is powerful. Team memory is transformative.

AI Dimag includes local-first team sync:

dim serve    # Start sync server
dim sync     # Sync with team
Enter fullscreen mode Exit fullscreen mode

Features:

  • Device-code login (no password storage)
  • Brain-scoped API keys
  • Cross-machine verification consensus
  • Evidence trust gates (never auto-execute untrusted shell commands)

When your team uses AI Dimag, you build a shared knowledge graph. Every agent gets smarter together.

Memory -

The coding agent successfully adhered to the constraints we set.

The Tech Stack

For the technically curious:

TypeScript/Node.js - Fast, cross-platform CLI
SQLite with sqlite-vec - Hybrid FTS5 + vector KNN search
MCP SDK - Integration with Claude, Cursor, etc.
OpenAI/Ollama embeddings - Optional (works keyword-only without them)
Better-sqlite3 - Synchronous, embeddable database

I chose SQLite over dedicated vector databases because:

  1. Zero configuration
  2. Works offline
  3. Embeddable in CLI tools

Hybrid search (keyword + semantic) performs better for code

What's Next

AI Dimag is early stage, but the roadmap is clear:

Short-term:

More AI tool integrations (JetBrains, Zed, Neovim)

Enhanced team features (SSO, audit logs, RBAC)

VS Code/IntelliJ extension improvements

Medium-term:

Skills library (reusable procedures, not just facts)

Guardrails enforcement (behavioral rules via pre-commit hooks)

Knowledge inbox (auto-summarize design docs, ADRs, PDFs)

Long-term:

Standard protocol for verified AI memory across all domains

Platform for team knowledge graphs and AI workflows

Enterprise features for regulated industries

Try It Yourself
AI Dimag is open source (Elastic License 2.0, free for teams โ‰ค10 users).

Install:

npm install -g aidimag
Enter fullscreen mode Exit fullscreen mode

Quick start:

cd your-repo
dim init
dim bootstrap  # LLM surveys your repo
dim review     # Approve memories
dim recall "database access"
dim verify     # Re-verify all evidence
Enter fullscreen mode Exit fullscreen mode

Links:

๐Ÿ“š Docs: https://aidimag.com

๐Ÿ’ป GitHub: https://github.com/anup-khanal/aidimag

๐Ÿ’ฌ Discord: https://discord.gg/86tQFcXQY

๐Ÿ“ฆ npm: npm install -g aidimag

The Bigger Picture

We're at an inflection point. AI coding agents are becoming essential development tools. But without verified memory, they're like developers with amnesiaโ€”powerful in the moment, useless across sessions.

I built AI Dimag to be the memory layer for the AI-native development era. Not just for one tool, but for the entire ecosystem.

If you're building with AI agents, I'd love your feedback. What does your AI forget? What would make this more useful?

Drop a comment or reach out. Let's build the future of AI-assisted development together.

Top comments (0)