Rein is an agent-native memory layer on top of git.
Git stores code history. Rein stores semantic memory about commits so future agents can search prior intent, reasoning, and notes before starting work.
The CLI command is:
reinCore primitive:
rein commitThis creates a real git commit and stores an AgentCommit record in Supabase.
rein commitDistills staged changes with an LLM, creates a git commit, embeds the memory text, and stores it in Supabase.
rein search "auth middleware"Hybrid semantic + keyword search over stored AgentCommit memories.
rein show <sha>Show the stored memory for a git commit SHA.
MVP fields:
type AgentCommit = {
id: string
sha: string
intent: string
reasoning_trace: string
notes_for_future_agents: string
embedding_text: string
}The database also stores:
embedding: vector
created_at: timestampnpm installRequired:
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
OPENAI_API_KEY=your-openai-keyOptional:
REIN_MODEL=gpt-4o-mini
REIN_EMBEDDING_MODEL=text-embedding-3-small
DATABASE_URL=postgresql://...DATABASE_URL is only needed if you want to run the DB setup script from the CLI.
Option A: use the script. This requires DATABASE_URL in .env:
npm run db:setupThe setup script connects directly with pg and applies supabase/migrations/001_agent_commits.sql. We do not use supabase db query here because it can fail on multi-statement migration files with cannot insert multiple commands into a prepared statement.
Option B: paste this file into the Supabase SQL editor:
supabase/migrations/001_agent_commits.sqlThis creates:
agent_commitstablevectorextension- full-text search column
- vector index
match_agent_commitsRPC for hybrid search
npm run buildThe Workspace page can run against the seeded local database in
data/local-repository-db.json. This lets the app exercise repository summaries,
commit tables, filters, memory coverage, and data-derived insights without
depending on a populated Supabase project.
REIN_REPOSITORY_DATA_SOURCE=local npm run devRegenerate the deterministic compact seed database:
npm run seed:local
LOCAL_SEED_MAX_COMMITS=75 npm run seed:localLOCAL_SEED_MAX_COMMITS is clamped between 75 and 100 commits per repository.
The default is 90, which keeps the fixture lightweight while preserving branches,
PR/issue references, releases, affected files, semantic embeddings, risk scores,
and agent memory metadata for every commit.
Useful options:
REIN_REPOSITORY_DATA_SOURCE=auto
REIN_REPOSITORY_DATA_SOURCE=remote
REIN_LOCAL_REPOSITORY_DB=data/local-repository-db.json
NEXT_PUBLIC_REIN_SEED_LOCAL_WORKSPACE=1auto uses the local database for seeded repositories and falls back to the
GitHub/Supabase provider for other repositories. remote uses GitHub for commit
metadata and Supabase for AgentCommit memory.
npm linkThen verify:
rein --helpExpected:
Usage: rein [options] [command]
Commands:
commit [options]
search [options] <query...>
show <sha>You can run without linking:
npm run rein -- --help
npm run rein -- search "auth middleware"
npm run rein -- commitAfter linking, use:
rein --help
rein search "auth middleware"
rein commitSearch prior project memory:
rein search "auth middleware"Stage changes:
git add <files>Create git commit + semantic memory:
rein commitFlow:
staged diff
-> LLM distillation
-> git commit
-> get SHA
-> generate embedding
-> store AgentCommit in SupabaseDry run:
rein commit --dry-runThis prints the generated commit message and memory without committing.
Build:
npm run buildRun search through npm:
npm run rein -- search "auth middleware"Link CLI:
npm linkUse linked CLI:
rein --help
rein search "auth middleware"Apply DB setup:
npm run db:setupThis was caused by using supabase db query on a multi-statement SQL migration. The setup script now uses the pg package directly, so rerun:
npm install
npm run db:setupThis usually means Supabase returned an error object. Common causes:
- The migration has not been applied.
match_agent_commitsRPC does not exist yet.vectorextension is not enabled..envhas the wrong Supabase key.OPENAI_API_KEYis missing or invalid.
Run:
npm run db:setupOr paste supabase/migrations/001_agent_commits.sql into Supabase SQL editor.
Then rebuild:
npm run buildrein commit only commits staged changes. Run:
git add <files>
rein commitThe git commit is not rolled back. Rein writes a recovery file to:
.rein/pending/<sha>.jsonA future rein sync command can upload these pending memories.
rein/
├── src/
│ ├── cli.ts # rein commands
│ ├── db.ts # Supabase client/store
│ ├── git.ts # git helpers
│ ├── llm.ts # OpenAI distillation + embeddings
│ ├── types.ts # AgentCommit types
│ └── server.ts # older HTTP API compatibility layer
├── supabase/
│ └── migrations/
│ └── 001_agent_commits.sql
├── plan.md
├── package.json
└── tsconfig.json- Use
rein commit, notgit commit, when an agent finishes a task. - Git remains the source of truth for code.
- Supabase stores semantic memory.
- Search is hybrid: OpenAI embeddings + Postgres full-text search.