Content
<div align="center">
<h1>🧠 GitMem</h1>
<p><b>Repository-Native Engineering Memory for AI</b></p>
<p>
<a href="https://golang.org/"><img src="https://img.shields.io/badge/Made%20with-Go-00ADD8.svg?style=flat-square&logo=go" alt="Made with Go"></a>
<a href="https://github.com/Ashishkumar14077/gitmem/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square" alt="License"></a>
</p>
</div>
---
## 🌟 What is GitMem?
**GitMem** is a CLI tool that transforms your repository into an intelligent, AI-ready engineering memory bank. It stores architecture notes, Architecture Decision Records (ADRs), and commit rationale locally in your repository and exposes them to LLMs through semantic search and the Model Context Protocol (MCP).
By keeping the knowledge **in the repository** (inside a `.repo-memory` directory), your engineering context travels with the code, preventing knowledge loss and drastically improving AI coding assistant performance.
## 🚀 Key Features
- **Repository-Native Storage**: Context, architecture, and ADRs live right next to your code.
- **AI-Powered Q&A**: Ask questions about your architecture and get answers powered by Gemini, Ollama, or OpenRouter.
- **Local RAG & Embeddings**: Uses Nomic Embeddings (local) or Gemini and LanceDB for blazing-fast semantic search.
- **Automated ADRs**: Interactively generate standardized Architecture Decision Records.
- **Smart Git Hooks**: Keep memory up to date with pre-commit checks and AI-generated commit messages.
- **MCP Integration**: Run GitMem as an MCP server to give tools like Claude Desktop or other AI agents direct access to your repository's memory.
## 🛠️ Installation
Make sure you have Go installed, then run:
```bash
# Clone the repository
git clone https://github.com/Ashishkumar14077/gitmem.git
cd gitmem
# Build the CLI
go build -o gitmem .
# (Optional) Move to your bin path
sudo mv gitmem /usr/local/bin/
```
> Note: You will need to copy `.env.example` to `.env` and fill in your API keys (e.g., `GEMINI_API_KEY`) for AI features to work.
## 🎮 Usage
### 1. Initialize
Initialize GitMem in your current repository. This creates the `.repo-memory` folder and prepares the structure.
```bash
gitmem init
```
### 2. Document & Decide
Scaffold your initial architecture documentation and make architectural decisions interactively.
```bash
gitmem architecture
gitmem decision
```
### 3. Index the Memory
Run the embedding pipeline to index all documents into the local vector database.
```bash
gitmem index
```
### 4. Ask Questions
Query your engineering memory using natural language.
```bash
gitmem ask "Why did we choose LanceDB over Pinecone?"
```
## 🧩 Advanced Commands
### Smart Commits & Hooks
Prevent knowledge staleness by generating commit messages that include deep engineering rationale based on your memory.
```bash
# Generate a commit message based on staged changes
gitmem commit
# Install pre-commit hooks to check for memory staleness
gitmem hook install
```
### Universal Context Generation
Generate a unified `context.md` file summarizing your entire project's state.
```bash
gitmem context
```
### Model Context Protocol (MCP) Server
Expose your repository memory to modern AI agents (like Claude Desktop) via stdio.
```bash
gitmem mcp
```
## 🏗️ Architecture
GitMem is built for speed and privacy using a modern stack:
- **CLI Framework**: Cobra
- **Git Operations**: go-git
- **LLM Support**: Gemini, Ollama (Local), OpenRouter
- **Embeddings**: Nomic (Local) or Gemini
- **Vector Database**: LanceDB (embedded)
- **Integration**: Official MCP SDK
See the [Architecture Document](ARCHITECTURE.md) for more details.
## 🤝 Contributing
Contributions are welcome! Feel free to open issues or submit Pull Requests.
## 📄 License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.