Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@shahmilsaari/memory-core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
memory-core
Every AI coding agent in your project, following your rules. Automatically.
You decide the architecture. memory-core remembers it. Every AI tool — Copilot, Cursor, Claude Code, Windsurf, and 10 more — reads those rules before writing a single line of code.
npx @shahmilsaari/memory-core initNo OpenAI key. No cloud. Fully local.
What does it actually do?
Without memory-core, every AI agent starts fresh. It doesn't know you're using Clean Architecture. It doesn't know controllers shouldn't call the database. It doesn't know why you made that decision six months ago.
With memory-core:
- You run
initonce and answer a few questions about your project - memory-core generates config files for every AI agent you use
- Those agents read the files and follow your rules — automatically
- When you commit code, a hook catches violations before they land in the repo
- Watch mode catches violations as you type, not just at commit time
Before you start
You need three things installed:
| What | Why | Install |
|---|---|---|
| PostgreSQL 14+ | Stores your rules and decisions | See below |
| pgvector | Makes search smart (finds similar rules, not just exact matches) | See below |
| Ollama | Runs AI locally — no API key needed | See below |
Install
PostgreSQL
macOS
brew install postgresql@16
brew services start postgresql@16Linux
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresqlWindows — download from postgresql.org
pgvector
pgvector adds AI-powered search to PostgreSQL.
macOS + PostgreSQL 17+ (easiest)
brew install pgvectormacOS + PostgreSQL 16 (brew's pgvector targets 17+, so build from source)
xcode-select --install
git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git /tmp/pgvector
cd /tmp/pgvector
make PG_CONFIG=/opt/homebrew/opt/postgresql@16/bin/pg_config
make install PG_CONFIG=/opt/homebrew/opt/postgresql@16/bin/pg_configLinux
sudo apt install postgresql-16-pgvector # replace 16 with your versionCheck it worked:
psql -U $(whoami) -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';"Ollama
Ollama runs AI models on your machine. Two models are needed — one for search, one for code checking.
macOS
brew install ollama
brew services start ollamaLinux
curl -fsSL https://ollama.com/install.sh | sh
ollama serve &Windows — download from ollama.com
Then pull the two models:
ollama pull nomic-embed-text # used for search
ollama pull llama3.2 # used to check your codeCreate the database
createdb memory_core
psql -U $(whoami) -d memory_core -f setup.sqlsetup.sql:
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE IF NOT EXISTS memories (
id BIGSERIAL PRIMARY KEY,
type TEXT NOT NULL,
scope TEXT NOT NULL DEFAULT 'project',
architecture TEXT,
project_name TEXT,
title TEXT,
content TEXT NOT NULL,
reason TEXT,
tags TEXT[] DEFAULT '{}',
embedding vector(768),
created_at TIMESTAMP DEFAULT now()
);
CREATE INDEX IF NOT EXISTS memories_embedding_idx
ON memories USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100);
CREATE INDEX IF NOT EXISTS memories_architecture_idx ON memories (architecture);
CREATE INDEX IF NOT EXISTS memories_scope_idx ON memories (scope);Quick start
# 1. Go to your project
cd my-api
# 2. Initialize — answers a few questions, generates all config files
npx @shahmilsaari/memory-core init
# 3. Load 192 predefined best-practice rules
npx @shahmilsaari/memory-core seed
# 4. Install the pre-commit hook (optional but recommended)
npx @shahmilsaari/memory-core hook installThat's it. Every AI agent in your project now has your rules.
Commands
init — Set up a project
npx @shahmilsaari/memory-core initAsks you:
- Project name
- Project type (Backend / Frontend / Fullstack)
- Architecture (Clean Architecture, MVC, React, Vue, etc.)
- Language
- Whether to enable caveman mode (optional token saver)
Generates config files for every supported AI agent and saves your choices to .memory-core.json.
remember — Save a decision
Made a decision your team should never forget? Save it.
npx @shahmilsaari/memory-core remember "Controllers must never call the database directly"It will ask you why — that reason gets stored alongside the rule and shown to AI agents and developers when a violation is caught.
With flags (skip the prompts):
npx @shahmilsaari/memory-core remember "Use DTOs for all API responses" \
--type rule \
--scope global \
--reason "Raw DB entities expose internal schema and sensitive fields" \
--tags "api,dto"| Flag | Options | Default |
|---|---|---|
--type |
decision rule pattern note |
decision |
--scope |
global project |
project |
--reason |
any text | asked interactively |
--tags |
comma-separated | none |
sync — Refresh all agent files
After saving new memories, regenerate every agent file to include them.
npx @shahmilsaari/memory-core syncsearch — Find a rule or decision
npx @shahmilsaari/memory-core search "error handling"
npx @shahmilsaari/memory-core search "auth strategy" --limit 10Uses AI search — finds related rules even if you don't use the exact words.
seed — Load predefined rules
192 best-practice rules across all supported architectures, each with a plain-English reason explaining why the rule exists.
npx @shahmilsaari/memory-core seed # all architectures
npx @shahmilsaari/memory-core seed --arch clean-architecture # one only
npx @shahmilsaari/memory-core seed --force # re-seed existinghook install — Block bad commits
npx @shahmilsaari/memory-core hook installInstalls a git pre-commit hook. Every time you run git commit, your staged files are checked against your architecture rules before the commit goes through.
When a violation is found, the commit is blocked and you see exactly what's wrong and how to fix it:
✗ 2 rule violations found — commit blocked
[1] src/controllers/user.ts:32
Rule: Thin controllers — business logic belongs in services
Why: Logic in controllers cannot be reused from other entry points
— it gets siloed and duplicated across handlers
Issue: Password validation logic inside route handler
Fix: Move to UserService.validateCredentials()
[2] src/domain/user.entity.ts:5
Rule: Domain has zero external imports
Why: Framework imports tie business logic to infrastructure
Issue: Imports 'typeorm' directly
Fix: Define IUserRepository interface in domain/
To bypass: git commit --no-verify
To save as memory: memory-core remember "<lesson>"npx @shahmilsaari/memory-core hook uninstall # remove the hookwatch — Catch violations as you type
npx @shahmilsaari/memory-core watchRuns in the background and checks each file the moment you save it. You see violations immediately — before you even think about committing.
archmind watch — real-time rule enforcement
watching: /your/project
model: llama3.2
rules: 24
ctrl+c to stop
[10:42:11] saved: src/controllers/user.ts
✗ 1 violation in src/controllers/user.ts
[1] src/controllers/user.ts:34
Rule: Thin controllers — business logic belongs in services
Why: Logic in controllers cannot be reused from other entry points
Issue: Password hashing inside the route handler
Fix: Move to UserService.hashPassword()Options:
npx @shahmilsaari/memory-core watch --path src/ # watch a specific folder only
npx @shahmilsaari/memory-core watch --verbose # show extra detailsOnly checks source files — ignores node_modules, dist, config files, JSON, etc.
check — Manual check (for CI)
npx @shahmilsaari/memory-core check --staged # check staged files
npx @shahmilsaari/memory-core check --staged --verbose # with extra detailSame as the pre-commit hook. Use this in CI/CD pipelines.
global — Apply rules to every project
npx @shahmilsaari/memory-core globalWrites your rules to the global config of each AI agent — so they follow your rules in every project on your machine, not just the current one.
| Agent | Where it writes |
|---|---|
| Claude Code | ~/.claude/CLAUDE.md |
| GitHub Copilot | VS Code settings.json |
| Cursor | ~/.cursor/rules/memory-core.mdc |
| Cline | VS Code settings.json |
| Continue.dev | ~/.continue/config.json |
| Aider | ~/.aider.conf.yml |
| Zed AI | ~/.config/zed/settings.json |
| Windsurf | ~/.windsurf/rules/memory-core.md |
Supported agents
| Agent | File generated |
|---|---|
| Claude Code | CLAUDE.md |
| GitHub Copilot | .github/copilot-instructions.md |
| Cursor | .cursorrules + .cursor/rules/memory-core.mdc |
| Windsurf | .windsurfrules |
| Cline | .clinerules |
| Roo Code | .roo/rules/memory-core.md |
| Aider | .aider.conf.yml |
| Continue.dev | .continue/config.json |
| Devin | DEVIN.md |
| Amazon Q | .amazonq/dev/guidelines.md |
| Gemini Code Assist | .gemini/styleguide.md |
| Zed AI | .zed/settings.json |
| JetBrains AI | .idea/ai-instructions.md |
| OpenHands | AGENTS.md |
Plus shared files: AI_RULES.md, ARCHITECTURE.md, PROJECT_MEMORY.md
Architecture profiles
Pick the one that matches how your project is structured.
Backend
| Profile | Use when… |
|---|---|
| Clean Architecture | You want strict separation between domain, application, and infrastructure |
| Modular Monolith | You're building feature modules that might become microservices later |
| MVC | Standard web app with controllers and services |
| Hexagonal | You want ports and adapters for maximum testability |
| Next.js | Next.js 13+ with server components and server actions |
| Laravel | Laravel with service-repository pattern |
Frontend
| Profile | Use when… |
|---|---|
| React | Functional components, hooks, React Query, Zustand |
| Vue 3 | Composition API, Pinia, composables |
| Angular | Standalone components, signals, OnPush strategy |
| Svelte | Svelte 5 runes, SvelteKit load functions |
| Nuxt 3 | Fullstack Vue with SSR |
| React Native | Mobile apps |
Fullstack projects get both sections in every generated file.
Caveman mode (optional)
Cuts AI response length by 65–75% by removing filler words. Opt in during init.
| Level | What it does |
|---|---|
lite |
Professional and concise |
full |
Caveman-style short answers |
ultra |
Absolute minimum words |
Day-to-day workflow
# Starting a new project
cd my-api
npx @shahmilsaari/memory-core init
npx @shahmilsaari/memory-core seed
npx @shahmilsaari/memory-core hook install
# Made an architectural decision? Save it.
npx @shahmilsaari/memory-core remember "All auth goes through middleware, never in controllers" \
--type decision --scope global
# Refresh agent files after saving new memories
npx @shahmilsaari/memory-core sync
# Not sure how something was decided? Search.
npx @shahmilsaari/memory-core search "caching strategy"
# Commit code → hook checks it automatically
git commit -m "add user endpoint"Environment variables
memory-core creates .memory-core.env automatically during init. You can also set these manually:
| Variable | Required | Default | What it does |
|---|---|---|---|
DATABASE_URL |
Yes | — | PostgreSQL connection string |
OLLAMA_URL |
No | http://localhost:11434 |
Where Ollama is running |
OLLAMA_MODEL |
No | nomic-embed-text |
Model used for search |
OLLAMA_CHAT_MODEL |
No | llama3.2 |
Model used for code checking |
Troubleshooting
extension "vector" is not available
pgvector isn't installed for your PostgreSQL version. Follow the pgvector install steps above.
Ollama not running — skipping rule check
Start Ollama: brew services start ollama (macOS) or ollama serve (Linux).
Chat model "llama3.2" not found
Run ollama pull llama3.2. Or switch to another model: add OLLAMA_CHAT_MODEL=mistral to .memory-core.env.
DATABASE_URL is not set
Run npx @shahmilsaari/memory-core init — it will create the .memory-core.env file for you.
createdb: role does not exist
createuser -s $(whoami)Hook is flagging JSON or config files
It won't — the hook only checks source code files: .ts .tsx .js .jsx .py .php .rb .go .java .cs .swift .kt .rs .vue .svelte. Everything else is skipped automatically.
Roadmap
| Feature | |
|---|---|
| ✓ | Watch mode — real-time violation alerts on save |
| CI/CD — fail PRs that violate your rules | |
| Violation memory — auto-save what went wrong as a new rule | |
| Rule analytics — see which rules get broken most | |
| Team sync — share memory across your whole team | |
| Memory review — approve rules before they propagate |
License
MIT