diff --git a/README.md b/README.md index b2c4cc8..9421444 100644 --- a/README.md +++ b/README.md @@ -1,86 +1,117 @@ # Claude OS -```text -╔═══════════════════════════════════════════════════════════════╗ -║ ║ -║ ██████╗██╗ █████╗ ██╗ ██╗██████╗ ███████╗ ██████╗ ███████╗ -║ ██╔════╝██║ ██╔══██╗██║ ██║██╔══██╗██╔════╝ ██╔═══██╗██╔════╝ -║ ██║ ██║ ███████║██║ ██║██║ ██║█████╗ ██║ ██║███████╗ -║ ██║ ██║ ██╔══██║██║ ██║██║ ██║██╔══╝ ██║ ██║╚════██║ -║ ╚██████╗███████╗██║ ██║╚██████╔╝██████╔╝███████╗ ╚██████╔╝███████║ -║ ╚═════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚══════╝ -║ ║ -║ Localized Multi-Knowledge-Base RAG System ║ -║ with MCP Integration ║ -║ ║ -╚═══════════════════════════════════════════════════════════════╝ -``` +

+ Claude OS Hero +

-> **Production-grade RAG system** with SQLite vector search, Ollama LLMs, and Model Context Protocol. Runs 100% locally on your machine. +

+ AI Memory & Knowledge Base System for Claude Code
+ Share with your team • Initialize projects in seconds • Never lose context again +

-[![License: MIT](https://img.shields.io/badge/License-MIT-purple.svg)](LICENSE) -[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/) -[![SQLite](https://img.shields.io/badge/SQLite-3.0+-green.svg)](https://www.sqlite.org/) -[![Ollama](https://img.shields.io/badge/Ollama-Latest-pink.svg)](https://ollama.ai/) +

+ License: MIT + Python 3.11+ + SQLite + Ollama +

--- ## 🚀 What is Claude OS? -**Claude OS** is a **localized RAG (Retrieval-Augmented Generation) system** designed to make AI assistants deeply knowledgeable about your codebase and documentation. It combines: +**Claude OS** is **Claude Code's personal memory system** - making AI the best coding assistant in the universe by remembering everything across sessions. -- **🗄️ SQLite + sqlite-vec** - Lightweight vector database for semantic search -- **🤖 Ollama** - Local LLMs (llama3.1) with no API keys needed -- **🔌 MCP Integration** - Claude CLI integration via Model Context Protocol -- **⚡ React UI** - Modern dashboard for managing knowledge bases -- **📚 Multi-KB Support** - Separate knowledge bases for different projects -- **🧠 Advanced RAG** - Hybrid search, reranking, and agentic modes +### The Problem -### Perfect For +You work with Claude Code on a feature, close the terminal, come back tomorrow... and Claude forgot everything. You explain the same architecture. You reference the same files. You repeat yourself constantly. -✅ Making Claude deeply familiar with your codebase -✅ Private, secure knowledge base (never leaves your machine) -✅ Team collaboration (share with coworkers easily) -✅ Integration with Claude CLI via MCP -✅ Building AI-assisted development workflows +### The Solution + +**Claude OS gives Claude persistent memory:** + +- 📝 **Remembers decisions** across all sessions +- 🔍 **Searches past work** automatically at session start +- 📚 **Indexes your docs** and makes them searchable +- 🧠 **Learns patterns** that improve over time +- 🤝 **Shares with your team** - one install, unlimited projects + +### Key Features + +✅ **One-Command Project Init** - `/claude-os-init` and you're done +✅ **Automatic Context Loading** - Starts every session with relevant memories +✅ **Session Management** - Track work, save progress, resume later +✅ **Documentation Ingestion** - Auto-indexes your docs during setup +✅ **Team Sharing** - `./install.sh` for coworkers, works instantly +✅ **100% Local** - Never leaves your machine, fully private +✅ **Template System** - Commands and skills shared via symlinks --- -## ⚡ Quick Start (5-10 minutes) +## ⚡ Quick Start for Coworkers + +**Your coworker shared Claude OS with you? Here's the 3-minute setup:** + +### Step 1: Clone and Install + +```bash +# Clone the repository +git clone https://github.com/your-team/claude-os.git +cd claude-os + +# Run the installer (handles everything) +./install.sh +``` + +The installer will: +- ✅ Set up Python environment +- ✅ Install all dependencies +- ✅ Configure MCP server +- ✅ Symlink commands and skills to `~/.claude/` +- ✅ Create start script + +### Step 2: Start Claude OS + +```bash +./start.sh +``` + +This starts the MCP server at `http://localhost:8051` + +### Step 3: Initialize Your First Project + +```bash +cd /path/to/your/project +``` + +In Claude Code, run: +``` +/claude-os-init +``` + +Answer the questions (project name, tech stack, docs path, etc.) and **you're done!** + +**What you get:** +- ✅ 4 knowledge bases created (memories, profile, index, docs) +- ✅ Documentation auto-indexed +- ✅ Codebase analyzed +- ✅ CLAUDE.md file with all context +- ✅ Ready to code with AI memory! + +--- + +## 🎯 For First-Time Setup (Original Creator) ### Prerequisites -**You MUST have these installed first:** +**Required:** +- Python 3.11+ (`python3 --version`) +- Git (`git --version`) -1. **Python 3.11+** (required) - ```bash - python3 --version - ``` - - macOS: `brew install python@3.11` - - Linux: `sudo apt-get install python3.11` - - Windows: Download from https://www.python.org/downloads/ +**Optional:** +- Node.js 16+ (for React UI) -2. **Git** (required) - ```bash - git --version - ``` - - macOS: `brew install git` - - Linux: `sudo apt-get install git` - - Windows: Download from https://git-scm.com/ - -3. **Node.js 16+** (optional, for React frontend) - ```bash - node --version - ``` - - macOS: `brew install node` - - Linux: `sudo apt-get install nodejs` - - Windows: Download from https://nodejs.org/ - ---- - -### Quick Install (3 Steps) - -**Once you have Python 3.11+ and Git, run these commands:** +### Installation ```bash # 1. Clone the repository @@ -94,213 +125,143 @@ cd claude-os ./start_all_services.sh ``` -**The setup script will automatically:** -- ✅ Install Ollama (if needed) + download LLM models -- ✅ Install Redis (if needed) for caching/queues -- ✅ Set up Python virtual environment -- ✅ Install all Python dependencies -- ✅ Create SQLite database -- ✅ Install frontend dependencies (if Node.js present) +**The setup script automatically installs:** +- ✅ Ollama (if not present) + LLM models +- ✅ Redis (if not present) for caching/queues +- ✅ Python virtual environment +- ✅ All Python dependencies +- ✅ SQLite database +- ✅ Frontend dependencies (if Node.js present) -**Done!** Visit http://localhost:5173 to start using Claude OS. +**Visit** http://localhost:5173 to use the web UI. -### Installation (Step by Step) +### Consolidate Your Files (First Time Only) -**Step 1: Install Prerequisites** (one-time only) - -Choose your OS: - -**macOS:** -```bash -# Install Python 3.11 -brew install python@3.11 - -# Install Git -brew install git - -# Optional: Install Node.js for frontend -brew install node -``` - -**Linux (Ubuntu/Debian):** -```bash -# Install Python 3.11 -sudo apt-get update -sudo apt-get install python3.11 python3.11-venv - -# Install Git -sudo apt-get install git - -# Optional: Install Node.js for frontend -sudo apt-get install nodejs npm -``` - -**Verify installation:** -```bash -python3 --version # Should be 3.11+ -git --version # Should exist -``` - ---- - -**Step 2: Clone the Repository** +If you've been using Claude OS and have scattered commands/skills, run the consolidation script: ```bash -git clone https://github.com/brobertsaz/claude-os.git -cd claude-os +./cli/claude-os-consolidate.sh ``` +This moves all commands from `~/.claude/commands/` to `templates/commands/` and creates symlinks. + +**Then commit to git:** +```bash +git add templates/ cli/ install.sh SHARING_GUIDE.md +git commit -m "Add packaging system for sharing" +git push +``` + +Now your team can clone and use `./install.sh`! + --- -**Step 3: Run the Installer** +## 🎨 The `/claude-os-init` Command + +**Initialize any project with Claude OS in under 2 minutes:** + +### What It Does ```bash -./setup.sh +cd /your/project ``` -This automatically installs: -- ✅ **Ollama** - LLM engine (auto-installed if missing) -- ✅ **Redis** - Cache & queues (auto-installed if missing) -- ✅ **Python dependencies** - All required packages -- ✅ **SQLite database** - Local vector store -- ✅ **Frontend** - React UI (if Node.js present) - -The script will download ~5-10 GB of LLM models (llama3.1, embeddings). - ---- - -**Step 4: Start Services** - -```bash -./start_all_services.sh +In Claude Code: +``` +/claude-os-init ``` -This starts: -- 🔌 **MCP Server** (port 8051) - Backend RAG engine -- 🎨 **React UI** (port 5173) - Web dashboard -- 🤖 **Ollama** (port 11434) - LLM service -- 💾 **Redis** (port 6379) - Cache & queues -- 🧠 **RQ Workers** - Real-time learning system +The command will: + +1. **Ask Questions Interactively:** + - Project name (auto-detects from folder) + - Tech stack (Ruby on Rails, Python, Node.js, etc.) + - Database (PostgreSQL, MySQL, etc.) + - Development environment (Docker, Local, etc.) + - Brief description + - Documentation directory to ingest (optional) + +2. **Create Project in Claude OS:** + - Calls API to create project + - Creates 4 knowledge bases automatically: + - `{project}-project_memories` - Claude's memory + - `{project}-project_profile` - Architecture & standards + - `{project}-project_index` - Codebase index + - `{project}-knowledge_docs` - Your documentation + +3. **Set Up Project Structure:** + ``` + your-project/ + ├── CLAUDE.md # Auto-loaded every session! + ├── .claude/ # Commands, skills, agents + │ ├── ARCHITECTURE.md + │ ├── CODING_STANDARDS.md + │ └── DEVELOPMENT_PRACTICES.md + └── .claude-os/ # Config and state (git-ignored) + ├── config.json + └── hooks.json + ``` + +4. **Ingest Documentation:** + - Scans your docs directory + - Uploads all files to `{project}-knowledge_docs` + - Creates vector embeddings for search + +5. **Analyze Codebase:** + - Runs `initialize-project` skill + - Generates coding standards + - Documents architecture + - Indexes key files + +6. **Ready to Code:** + - Claude now knows your project + - Memory persists across sessions + - Context auto-loads on session start --- -**Step 5: Access the Application** +## 🧠 How Claude OS Works -Open your browser and visit: -- **Frontend:** http://localhost:5173 -- **API Docs:** http://localhost:8051/docs +### Session Workflow -Start uploading documents to create knowledge bases! +**Every Claude Code session automatically:** ---- +1. **Checks for Active Session** + - Reads `claude-os-state.json` + - Prompts: Continue working? Start something new? -## 🎯 Initialize Your Project (The Magic Sauce ✨) +2. **Loads Context** + - Searches `{project}-project_memories` for recent work + - Loads relevant patterns and decisions + - Shows what it remembers -Once Claude OS is running, follow these 3 simple steps to make Claude an expert on your codebase: +3. **Works With Memory** + - Saves insights with `/claude-os-remember` + - Searches memories with `/claude-os-search` + - References past decisions automatically -### Step 1: Create a Project in Claude OS UI +4. **Ends Session** + - Saves session summary + - Updates memories + - Tracks what was accomplished -1. **Open the UI** - Visit http://localhost:5173 in your browser -2. **Click "Create Project"** button -3. **Fill in the form:** - - **Project Name** - e.g., "my-awesome-app" - - **Project Path** - Select your project directory (e.g., `/Users/you/Projects/my-awesome-app`) - - **Description** - (optional) Brief description of your project +### Available Commands -4. **Click "Create Project"** +All these work in any initialized project: -Your project is now registered in Claude OS! +- **`/claude-os-init`** - Initialize new project +- **`/claude-os-search [query]`** - Search memories & docs +- **`/claude-os-remember [content]`** - Quick save to memories +- **`/claude-os-save [title]`** - Full-featured save with KB selection +- **`/claude-os-list`** - List all knowledge bases +- **`/claude-os-session [action]`** - Manage development sessions +- **`/claude-os-triggers`** - Manage trigger phrases -### Step 2: Get Your Project ID +### Available Skills -After creating your project, you'll see it listed in the Projects view. The **Project ID** is displayed right on the project card (e.g., `#1`, `#2`, etc.). - -Simply note the number - that's your project ID! - -**Example:** -- If you see `#1` on your project card, your project ID is `1` -- If you see `#3` on your project card, your project ID is `3` - -### Step 3: Initialize Project with Claude Code - -This is where the magic happens! The initialization will: -- ✅ Analyze your entire codebase (~5 minutes) -- ✅ Generate coding standards & architecture docs -- ✅ Index 50 key files (~800 code chunks) -- ✅ Set up Git hooks for auto-indexing -- ✅ Create 4 Knowledge Bases automatically - -**Open Claude Code and copy-paste this command** (replace `1` with your project ID): - -``` -/initialize-project 1 -``` - -**⚠️ Important:** Replace `1` with your actual project ID from Step 2 - -**Examples:** -- If your project ID is `1`: `/initialize-project 1` -- If your project ID is `2`: `/initialize-project 2` -- If your project ID is `3`: `/initialize-project 3` - -**What happens after you run it:** -1. Claude analyzes your project structure, patterns, and conventions (takes ~5 minutes) -2. Generates 3 documentation files: - - `CODING_STANDARDS.md` - Your code style - - `ARCHITECTURE.md` - Your system design - - `DEVELOPMENT_PRACTICES.md` - How you build software -3. Creates semantic indexes for 50 key files (~800+ code chunks) -4. Installs Git hooks to auto-update knowledge on commits -5. Creates 4 Knowledge Bases for use with Claude CLI - -**When it's done:** -✅ Claude is now an expert on your project! -✅ Ask Claude about your codebase and it will know the answers -✅ Every git commit automatically updates Claude's knowledge - ---- - -## 🔌 Auto-Generated MCPs for Claude CLI - -After running `/initialize-project`, Claude OS automatically creates **4 MCPs (Model Context Protocol endpoints)** for your project: - -1. **📚 knowledge_docs** - Your project documentation -2. **📋 project_profile** - Project analysis and overview -3. **🗂️ project_index** - Code structure and file index -4. **💾 project_memories** - Persistent memory and insights - -The `/initialize-project` command will show you the MCP URLs to add them to Claude CLI. Your project knowledge is immediately available! 🚀 - ---- - -## 📚 Managing Knowledge Bases - -### Create a Knowledge Base - -1. Visit http://localhost:5173 -2. Click "Create Knowledge Base" -3. Choose type: - - **GENERIC** - General documentation - - **CODE** - Source code repositories - - **DOCUMENTATION** - Technical docs - - **AGENT_OS** - Spec-driven development - -### Upload Documents - -1. Select a knowledge base -2. Click "Upload Documents" -3. Choose files (supports .md, .txt, .pdf, .py, .js, .ts, .json, .yaml) -4. Watch as documents are indexed - -### Query the Knowledge Base - -**Via Web UI:** -1. Select a KB from the dropdown -2. Type your question -3. View answer with source citations - -**Via Claude CLI:** -Once added as MCP server, Claude CLI can query your knowledge bases automatically when working on your project. +- **`initialize-project`** - Analyze codebase and generate standards +- **`remember-this`** - Auto-save when you say "remember this:" +- **`memory`** - Simple memory management --- @@ -308,8 +269,8 @@ Once added as MCP server, Claude CLI can query your knowledge bases automaticall ``` ┌─────────────────────────────────────────────────┐ -│ Claude CLI │ -│ (or any MCP client) │ +│ Claude Code CLI │ +│ (with Claude OS integration) │ └───────────────────┬─────────────────────────────┘ │ MCP HTTP ┌───────────────────▼─────────────────────────────┐ @@ -322,13 +283,14 @@ Once added as MCP server, Claude CLI can query your knowledge bases automaticall ┌───────▼────────────┐ ┌────────▼──────────┐ │ RAG Engine │ │ React UI │ │ (llama-index) │ │ (Port 5173) │ -│ • Vector Search │ │ │ -│ • Hybrid Search │ └────────────────────┘ -│ • Reranking │ -└───────┬────────────┘ +│ • Vector Search │ │ • Project Mgmt │ +│ • Hybrid Search │ │ • KB Browser │ +│ • Reranking │ │ • Doc Upload │ +└───────┬────────────┘ └───────────────────┘ │ ┌───────▼────────────────────────────────────────┐ │ SQLite + sqlite-vec (Local Database) │ +│ • projects │ │ • knowledge_bases │ │ • documents (with embeddings) │ │ • Single-file database │ @@ -344,14 +306,138 @@ Once added as MCP server, Claude CLI can query your knowledge bases automaticall └────────────────┘ ``` +### Template System + +``` +claude-os/ +├── templates/ # Shared with all projects +│ ├── commands/ # Slash commands (symlinked to ~/.claude/) +│ │ ├── claude-os-init.md +│ │ ├── claude-os-search.md +│ │ └── ... +│ ├── skills/ # Skills (symlinked to ~/.claude/) +│ │ ├── initialize-project/ +│ │ ├── remember-this/ +│ │ └── memory/ +│ └── project-files/ # Files created during /claude-os-init +│ ├── CLAUDE.md.template +│ └── .claude-os/ +│ ├── config.json.template +│ └── hooks.json.template +├── cli/ # CLI tools +│ └── claude-os-consolidate.sh +├── install.sh # One-command setup for coworkers +└── start.sh # Start services +``` + +**Benefits:** +- ✅ Update once, all projects benefit +- ✅ Symlinks mean instant updates +- ✅ Easy to share with team +- ✅ Consistent across projects + +--- + +## 📚 Managing Knowledge Bases + +### Via Web UI + +1. **Visit** http://localhost:5173 +2. **Create Knowledge Base:** + - Click "Create Knowledge Base" + - Choose type (Generic, Code, Documentation, Agent_OS) +3. **Upload Documents:** + - Select KB from dropdown + - Drag & drop files or click upload + - Supports .md, .txt, .pdf, .py, .js, .ts, .json, .yaml +4. **Query:** + - Type question in search box + - View answer with source citations + +### Via CLI + +```bash +# Search your project memories +/claude-os-search "how did we implement authentication?" + +# Save a quick insight +/claude-os-remember "Fixed bug in user controller by adding validation" + +# Full-featured save +/claude-os-save "Authentication Pattern" my-app-project_profile Architecture +``` + +### Auto-Created KBs + +When you run `/claude-os-init`, you get 4 knowledge bases: + +1. **`{project}-project_memories`** + - Claude's memory for decisions, patterns, solutions + - Automatically saved during sessions + - Searched at session start + +2. **`{project}-project_profile`** + - Architecture, coding standards, practices + - Generated by `initialize-project` skill + - Updated as project evolves + +3. **`{project}-project_index`** + - Automated codebase index + - Tracks file structure + - Updates on git commits (with hooks) + +4. **`{project}-knowledge_docs`** + - Your documentation + - Auto-ingested during init + - Add more via UI or CLI + +--- + +## 🤝 Team Collaboration + +### Sharing Claude OS + +**Step 1: Package for sharing** +```bash +cd /path/to/claude-os +./cli/claude-os-consolidate.sh # Move files to templates/ +git add templates/ cli/ install.sh +git commit -m "Ready for team sharing" +git push +``` + +**Step 2: Share repo URL with team** + +Send teammates: +- Repo URL +- Link to `SHARING_GUIDE.md` in the repo + +**Step 3: They install (3 minutes)** +```bash +git clone +cd claude-os +./install.sh +./start.sh +``` + +Done! They can now use `/claude-os-init` on any project. + +### Per-Project Setup + +Each team member: +1. Runs `/claude-os-init` in their project +2. Gets their own knowledge bases +3. CLAUDE.md is committed to git (shared) +4. .claude-os/ state is git-ignored (personal) + +**Result:** Team shares context via CLAUDE.md, but each person has their own AI memory. + --- ## ⚙️ Configuration ### Environment Variables -The system uses sensible defaults, but you can customize via environment variables: - ```bash # SQLite Database SQLITE_DB_PATH=data/claude-os.db # Default: data/claude-os.db @@ -365,15 +451,38 @@ MCP_SERVER_HOST=0.0.0.0 # Default: 0.0.0.0 MCP_SERVER_PORT=8051 # Default: 8051 ``` +### Project Configuration + +Each project has `.claude-os/config.json`: + +```json +{ + "project_name": "my-app", + "claude_os_url": "http://localhost:8051", + "knowledge_bases": { + "memories": "my-app-project_memories", + "profile": "my-app-project_profile", + "index": "my-app-project_index", + "docs": "my-app-knowledge_docs" + }, + "docs_settings": { + "watch_paths": ["./docs", "./knowledge_docs"], + "auto_ingest_patterns": ["*.md", "*.txt", "*.pdf"] + }, + "tech_stack": "Ruby on Rails", + "database": "MySQL" +} +``` + --- ## 📊 Performance -**Native Ollama Setup (Current)** +**Native Ollama Setup:** - Response time: ~40 seconds per query - GPU acceleration: Full Metal GPU on Apple Silicon - Memory usage: 8-10GB (models + context) -- CPU usage: 12 cores (M4 Pro, leaves 2 for system) +- CPU usage: 12 cores (M4 Pro) **Why it's fast:** - Direct GPU acceleration (no virtualization) @@ -385,186 +494,108 @@ MCP_SERVER_PORT=8051 # Default: 8051 ## 🛠️ Scripts Guide -Claude OS includes comprehensive shell scripts for setup, service management, and testing. Here's what each one does: - ### Installation & Setup -#### `./setup.sh` - Complete Setup ⭐ **USE THIS ONE** +#### `./install.sh` - Team Member Setup ⭐ +```bash +./install.sh +``` +**For coworkers joining the team:** +- ✅ Creates `~/.claude/` directories +- ✅ Symlinks all commands and skills +- ✅ Sets up Python environment +- ✅ Installs dependencies +- ✅ Configures MCP server + +#### `./setup.sh` - First-Time Setup ```bash ./setup.sh ``` -**This is the standard setup script that 99% of users need.** +**For the original creator:** +- ✅ Installs Ollama + Redis (if needed) +- ✅ Downloads LLM models (~5-10 GB) +- ✅ Sets up Python environment +- ✅ Creates database -**Prerequisites (must be installed first):** -- ✅ Python 3.11+ (required - script will fail if missing) -- ✅ Git (required - script will fail if missing) -- ⚠️ Node.js 16+ (optional - script skips frontend if missing) - -**What it automatically installs:** -- ✅ **Ollama** - Downloads and starts if not installed -- ✅ **Redis** - Installs and starts if not present -- ✅ **Python virtual environment** - Isolated environment -- ✅ **Python dependencies** - All packages from `requirements.txt` -- ✅ **LLM models** - llama3.1 and nomic-embed-text (~5-10 GB) -- ✅ **SQLite database** - Local vector store -- ✅ **Frontend dependencies** - npm packages (if Node.js present) - -**Supported platforms:** macOS & Linux - -**When to use:** -- ✅ **First-time setup (recommended for 99% of users)** -- ✅ You have Python 3.11+ and Git already installed -- ✅ You don't have Ollama or Redis yet -- ✅ You want a complete, automated setup -- ✅ You're on any Unix system (macOS/Linux) - ---- - -#### `./setup_native.sh` - Fast macOS Setup (Advanced Users Only) +#### `./cli/claude-os-consolidate.sh` - Organize Files ```bash -./setup_native.sh +./cli/claude-os-consolidate.sh ``` -**This is an optional lightweight setup for macOS users who already have Ollama installed via Homebrew.** - -**What it does:** -- ✅ Verifies Ollama is already installed via Homebrew (fails if not) -- ✅ Pulls required LLM models (llama3.1, nomic-embed-text) -- ✅ Sets up Python virtual environment -- ✅ Installs Python dependencies -- ✅ Creates data/ and logs/ directories -- ✅ Initializes SQLite database -- ⚠️ Does NOT install Redis - -**When to use (rare):** -- ⚠️ Only if you already have **Ollama installed via `brew install ollama`** -- ⚠️ You're on macOS only -- ⚠️ You already have Redis running separately - -**Note:** Most users should use `./setup.sh` instead. Only use this if you know what you're doing. - ---- +**One-time consolidation:** +- Moves commands to `templates/` +- Moves skills to `templates/` +- Creates symlinks +- Prepares for git commit ### Service Management -#### `./start_all_services.sh` - Start Everything +#### `./start.sh` or `./start_all_services.sh` - Start Everything ```bash -./start_all_services.sh +./start.sh ``` **Starts:** -- 🔌 **MCP Server** (port 8051) - Backend RAG engine -- 🎨 **React Frontend** (port 5173) - Web dashboard -- 🤖 **RQ Workers** - Real-time learning system -- 💾 **Redis** - Cache & message queue -- 🧠 **Ollama** - LLM service +- 🔌 MCP Server (port 8051) +- 🎨 React Frontend (port 5173) +- 🤖 RQ Workers +- 💾 Redis +- 🧠 Ollama -**Features:** -- Automatic health checks for all services -- Creates required directories if missing -- Checks that ports are free -- Logs all services to `logs/` directory -- Shows service URLs and PIDs - -**Output:** -``` -Service URLs: - 🎨 Frontend: http://localhost:5173 - 🔌 API Server: http://localhost:8051 - 📚 API Docs: http://localhost:8051/docs - -Log Files: - MCP Server: logs/mcp_server.log - Frontend: logs/frontend.log - RQ Workers: logs/rq_workers.log -``` - ---- - -#### `./stop_all_services.sh` - Stop All Services +#### `./stop_all_services.sh` - Stop All ```bash ./stop_all_services.sh ``` -**Stops:** -- 🔌 MCP Server (port 8051) -- 🎨 React Frontend (port 5173) -- 🤖 RQ Workers (real-time learning) -- 💾 Redis -**Note:** Ollama is preserved (may be used by other apps) - ---- - -#### `./restart_services.sh` - Restart Everything +#### `./restart_services.sh` - Restart ```bash ./restart_services.sh ``` -**Does:** -1. Stops all services gracefully -2. Waits for ports to be released (3 second delay) -3. Starts all services fresh - -**Use when:** Code changes aren't reflected or services need a clean restart --- -#### `./start_mcp_server.sh` - Start Only MCP Server +## 🐛 Troubleshooting + +### "Command not found: /claude-os-init" + +Symlinks weren't created. Re-run: ```bash -./start_mcp_server.sh -``` -**Starts:** -- 🔌 MCP Server (port 8051) - -**Checks:** -- ✅ Ollama is running -- ✅ SQLite database exists -- ✅ Python environment is ready - -**Use when:** You only need the backend API (e.g., for testing) - ---- - -#### `./start_redis_workers.sh` - Start RQ Workers -```bash -./start_redis_workers.sh -``` -**Starts:** -- 🤖 RQ Workers for real-time learning system -- Listening on queues: `claude-os:learning`, `claude-os:prompts`, `claude-os:ingest` -- Scheduler for periodic tasks - -**Checks:** -- ✅ Redis is running -- ✅ Python virtual environment exists -- ✅ RQ dependencies are installed - -**Use when:** Running the real-time learning system separately - ---- - -### Testing - -#### `./run_tests.sh` - Run Test Suite -```bash -./run_tests.sh [OPTIONS] +cd /path/to/claude-os +./install.sh ``` -**Options:** +### "Connection refused to localhost:8051" + +Claude OS server isn't running: ```bash -./run_tests.sh # Run all tests -./run_tests.sh --unit # Unit tests only -./run_tests.sh --integration # Integration tests only -./run_tests.sh --vector # Vector DB tests -./run_tests.sh --rag # RAG engine tests -./run_tests.sh --api # API endpoint tests -./run_tests.sh --coverage # Generate coverage report -./run_tests.sh --verbose # Detailed output -./run_tests.sh --unit --coverage # Combine options +cd /path/to/claude-os +./start.sh ``` -**Features:** -- Validates PostgreSQL connection -- Creates test database if needed -- Shows test configuration -- Generates HTML coverage report (with `--coverage`) +### "Project already exists" + +Project name is taken. Choose a different name or delete via UI at http://localhost:5173 + +### Port Already in Use + +```bash +# Find process on port 8051 +lsof -i :8051 + +# Kill if needed +kill -9 +``` + +### Ollama Issues + +```bash +# Check if running +ollama list + +# Start manually +ollama serve + +# Check for model +ollama list | grep llama3.1 +``` --- @@ -572,112 +603,60 @@ Log Files: ``` claude-os/ +├── templates/ # NEW: Shared templates system +│ ├── commands/ # Slash commands +│ ├── skills/ # Skills +│ └── project-files/ # Files created during init +├── cli/ # NEW: CLI tools +│ └── claude-os-consolidate.sh ├── app/ # Backend application │ ├── core/ # Core modules -│ │ ├── config.py # Configuration management -│ │ ├── sqlite_manager.py # SQLite interface -│ │ ├── rag_engine.py # RAG logic +│ │ ├── sqlite_manager.py +│ │ ├── rag_engine.py │ │ └── ... -│ ├── db/ # Database schemas -│ └── ... +│ └── db/ # Database schemas ├── frontend/ # React UI (Vite) │ ├── src/ -│ │ ├── pages/ -│ │ ├── components/ -│ │ └── ... -│ └── package.json +│ └── public/ +│ └── assets/ +│ └── claude-os-hero.png ├── mcp_server/ # MCP Server (HTTP) -│ ├── server.py # FastAPI + MCP endpoints -│ └── ... -├── migrations/ # Database migrations -├── data/ # SQLite database (auto-created) +│ └── server.py # FastAPI + MCP endpoints +├── data/ # SQLite database │ └── claude-os.db -├── logs/ # Service logs (auto-created) -├── .sh scripts # Utility scripts (see Scripts Guide above) -├── requirements.txt # Python dependencies +├── logs/ # Service logs +├── install.sh # NEW: Coworker setup +├── start.sh # NEW: Start services +├── SHARING_GUIDE.md # NEW: Team sharing docs └── README.md # This file ``` --- -## 🐛 Troubleshooting - -### Database Issues - -The SQLite database is automatically created at `data/claude-os.db`. If you encounter issues: - -```bash -# Check if database exists -ls -lh data/claude-os.db - -# Remove and recreate (WARNING: deletes all data) -rm data/claude-os.db -# Restart the server to recreate -``` - -### Ollama Issues - -```bash -# Check if Ollama is running -ollama list - -# Start Ollama manually -ollama serve - -# Check for specific model -ollama list | grep llama3.1 -``` - -### Port Already in Use - -```bash -# Find process on port 8051 (MCP Server) -lsof -i :8051 - -# Find process on port 5173 (React UI) -lsof -i :5173 - -# Kill if needed (replace PID with actual process ID) -kill -9 -``` - -### MCP Server Not Starting - -```bash -# Check logs -tail -f /tmp/mcp_server.log - -# Verify Python environment -source venv/bin/activate -python mcp_server/server.py - -# Check port 8051 is accessible -curl http://localhost:8051/health -``` - ---- - ## 📖 Additional Documentation +### Getting Started +- **[SHARING_GUIDE.md](SHARING_GUIDE.md)** - 🤝 How to share with your team +- **[templates/README.md](templates/README.md)** - 📂 Template system documentation + ### Core Features -- **[docs/SELF_LEARNING_SYSTEM.md](docs/SELF_LEARNING_SYSTEM.md)** - 🧠 How Claude learns from your conversations automatically -- **[docs/REAL_TIME_LEARNING_GUIDE.md](docs/REAL_TIME_LEARNING_GUIDE.md)** - Real-time learning system usage guide -- **[docs/MEMORY_MCP_GUIDE.md](docs/MEMORY_MCP_GUIDE.md)** - Persistent memory across sessions +- **[docs/SELF_LEARNING_SYSTEM.md](docs/SELF_LEARNING_SYSTEM.md)** - 🧠 How Claude learns automatically +- **[docs/REAL_TIME_LEARNING_GUIDE.md](docs/REAL_TIME_LEARNING_GUIDE.md)** - Real-time learning usage +- **[docs/MEMORY_MCP_GUIDE.md](docs/MEMORY_MCP_GUIDE.md)** - Persistent memory guide ### Technical Documentation -- **[README_NATIVE_SETUP.md](README_NATIVE_SETUP.md)** - Detailed native setup guide -- **[NATIVE_VS_DOCKER_DECISION.md](NATIVE_VS_DOCKER_DECISION.md)** - Why we chose native Ollama +- **[README_NATIVE_SETUP.md](README_NATIVE_SETUP.md)** - Detailed native setup +- **[NATIVE_VS_DOCKER_DECISION.md](NATIVE_VS_DOCKER_DECISION.md)** - Why native Ollama - **[PERFORMANCE_TEST_RESULTS.md](PERFORMANCE_TEST_RESULTS.md)** - Benchmark results -- **[SLUG_IMPLEMENTATION_SUMMARY.md](SLUG_IMPLEMENTATION_SUMMARY.md)** - URL slug system -- **[MCP_KB_ENDPOINTS.md](MCP_KB_ENDPOINTS.md)** - MCP endpoint documentation +- **[MCP_KB_ENDPOINTS.md](MCP_KB_ENDPOINTS.md)** - MCP endpoint docs --- ## 🤝 Contributing -This is a personal development tool. Feel free to: +This is a team development tool. Feel free to: - Modify for your specific needs -- Add new KB types +- Add new commands and skills - Optimize RAG strategies - Contribute improvements back @@ -691,12 +670,27 @@ MIT License - Use it freely! ## 🎯 Next Steps -1. **First-time setup:** Run `./setup_native.sh` -2. **Start services:** Run `./start_all_services.sh` -3. **Create knowledge base:** Visit http://localhost:5173 -4. **Upload documents:** Add your codebase/docs -5. **Integrate with Claude:** Run `claude mcp add ...` -6. **Start coding:** Ask Claude about your project! +### For Original Creator: +1. Run `./setup.sh` (first time) +2. Run `./cli/claude-os-consolidate.sh` (organize files) +3. Commit templates to git +4. Share repo with team -Happy coding! 🚀 +### For Team Members: +1. Clone the repo +2. Run `./install.sh` +3. Run `./start.sh` +4. Use `/claude-os-init` in your projects +### For Everyone: +- Use `/claude-os-search` to find past work +- Use `/claude-os-remember` to save insights +- Use `/claude-os-session` to track work +- Enjoy never losing context again! + +--- + +

+ Claude Code + Claude OS = Invincible! 🚀
+ Built by AI coders, for AI coders +

diff --git a/SHARING_GUIDE.md b/SHARING_GUIDE.md new file mode 100644 index 0000000..20fdbde --- /dev/null +++ b/SHARING_GUIDE.md @@ -0,0 +1,299 @@ +# Claude OS Sharing Guide + +## Overview + +This guide explains how to share Claude OS with coworkers and set up new projects. + +## Architecture + +``` +claude-os/ +├── templates/ # All reusable templates +│ ├── commands/ # Slash commands (symlinked to ~/.claude/) +│ ├── skills/ # Skills (symlinked to ~/.claude/) +│ ├── agents/ # Agent templates +│ └── project-files/ # Files created during project init +│ ├── CLAUDE.md.template +│ └── .claude-os/ # Config templates +├── cli/ # CLI tools +│ └── claude-os-consolidate.sh +├── install.sh # One-command install for coworkers +└── app/ # Flask API server +``` + +## For You (Initial Setup) + +### Step 1: Consolidate Your Files + +Move all scattered commands and skills into templates/: + +```bash +cd /Users/iamanmp/Projects/claude-os +./cli/claude-os-consolidate.sh +``` + +This will: +- Move commands from `~/.claude/commands/` → `templates/commands/` +- Move skills from `~/.claude/skills/` → `templates/skills/` +- Create symlinks so everything still works for you +- Update any hardcoded paths + +### Step 2: Commit to Git + +```bash +cd /Users/iamanmp/Projects/claude-os +git add templates/ cli/ install.sh SHARING_GUIDE.md +git commit -m "Add templates and installation system for sharing" +git push +``` + +### Step 3: Test Installation (Optional) + +Test on a different machine or user account: + +```bash +git clone your-repo/claude-os.git +cd claude-os +./install.sh +``` + +## For Coworkers (First Time Setup) + +### Step 1: Clone Claude OS + +```bash +git clone your-repo/claude-os.git +cd claude-os +``` + +### Step 2: Run Install Script + +```bash +./install.sh +``` + +This will: +- ✅ Create `~/.claude/` directories +- ✅ Symlink all commands and skills +- ✅ Set up Python virtual environment +- ✅ Install dependencies +- ✅ Configure MCP server +- ✅ Create start script + +### Step 3: Start Claude OS + +```bash +./start.sh +``` + +This starts the MCP server at `http://localhost:8051` + +### Step 4: Initialize Their First Project + +```bash +cd /path/to/their/project +``` + +In Claude Code, run: +``` +/claude-os-init +``` + +Follow the prompts to: +- Name the project +- Specify tech stack +- Ingest documentation +- Analyze codebase + +Done! Their project is now connected to Claude OS. + +## For New Projects (After Setup) + +Once Claude OS is installed, initializing new projects is simple: + +```bash +cd /path/to/new/project +``` + +In Claude Code: +``` +/claude-os-init +``` + +Answer the questions and you're done! + +## What Gets Created During Project Init + +``` +your-project/ +├── CLAUDE.md # Project context (auto-loaded every session) +├── .claude/ # Project-specific Claude Code files +│ ├── commands/ # (symlinks to Claude OS templates) +│ ├── skills/ # (symlinks to Claude OS templates) +│ ├── agents/ # Project-specific agents +│ ├── ARCHITECTURE.md # Generated by initialize-project +│ ├── CODING_STANDARDS.md +│ └── DEVELOPMENT_PRACTICES.md +└── .claude-os/ # Claude OS state/config + ├── config.json # Project configuration + ├── hooks.json # Project hooks + └── .gitignore # State files ignored +``` + +## Knowledge Bases Created + +Each project gets 4 knowledge bases: + +1. **`{project}-project_memories`** - Claude's memory for decisions, patterns, solutions +2. **`{project}-project_profile`** - Architecture, standards, practices +3. **`{project}-project_index`** - Automated codebase index +4. **`{project}-knowledge_docs`** - Your documentation (auto-ingested) + +## Commands Available After Setup + +All these work in any initialized project: + +- `/claude-os-init` - Initialize new project +- `/claude-os-search` - Search project memories +- `/claude-os-save` - Save insights +- `/claude-os-remember` - Quick save to memories +- `/claude-os-list` - List knowledge bases +- `/claude-os-session` - Manage dev sessions +- `/claude-os-triggers` - Manage trigger phrases + +## Skills Available + +- `initialize-project` - Analyze codebase and generate standards +- `remember-this` - Auto-save when you say "remember this:" +- `memory` - Simple memory management + +## Benefits for Your Team + +### One-Time Setup +- Clone repo → run install → done +- No configuration needed +- Works on Mac/Linux (Windows with WSL) + +### Project Isolation +- Each project has its own knowledge bases +- No cross-contamination +- Team members can work on multiple projects + +### AI Memory Across Sessions +- Claude remembers decisions across conversations +- Searchable history of all work +- Pattern recognition improves over time + +### Documentation Integration +- Automatically indexes your docs +- Searchable alongside code context +- Always up to date + +## Updating Claude OS + +When you add new commands/skills to templates: + +```bash +# On your machine: +cd /Users/iamanmp/Projects/claude-os +git pull origin main + +# Commands/skills auto-update via symlinks! +``` + +Coworkers do the same: +```bash +cd ~/Projects/claude-os +git pull origin main + +# Their symlinks automatically point to updated templates +``` + +## Troubleshooting + +### "Command not found: /claude-os-init" + +Symlinks weren't created. Re-run: +```bash +cd /path/to/claude-os +./install.sh +``` + +### "Connection refused to localhost:8051" + +Claude OS server isn't running: +```bash +cd /path/to/claude-os +./start.sh +``` + +### "Project already exists" + +Project name is taken. Choose a different name or delete the old project via the UI at `http://localhost:8051` + +### Commands work but changes don't persist + +Make sure you're committing changes to the Claude OS repo, not your project repo: +```bash +cd /path/to/claude-os # NOT your project dir +git status +git add templates/ +git commit -m "Updated templates" +git push +``` + +## Adding Custom Commands/Skills + +### Add a New Command + +1. Create file in `templates/commands/my-command.md` +2. Write command logic (see existing commands for examples) +3. Commit to git +4. Coworkers pull and get it automatically via symlinks + +### Add a New Skill + +1. Create directory in `templates/skills/my-skill/` +2. Add `SKILL.md` and any scripts +3. Commit to git +4. Coworkers pull and get it automatically + +## Security Notes + +- `.claude-os/` state files are git-ignored by default +- Never commit API keys or secrets to CLAUDE.md +- Each team member has their own Claude OS database +- Knowledge bases are local, not shared (unless you want to sync them) + +## FAQ + +**Q: Do I need to reinstall for each project?** +A: No! Install Claude OS once, then just run `/claude-os-init` in each project. + +**Q: Can multiple people work on the same project?** +A: Yes! Each person has their own Claude OS database. Shared project knowledge goes in CLAUDE.md (git-tracked). + +**Q: What if someone doesn't have Claude Code?** +A: They need Claude Code (the CLI tool) to use this. Free at https://claude.com/claude-code + +**Q: How much disk space does it use?** +A: ~500MB for Claude OS + dependencies. Each project's knowledge base is ~10-100MB depending on docs. + +**Q: Does this work on Windows?** +A: Yes, with WSL (Windows Subsystem for Linux). Native Windows support coming soon. + +## Support + +- 📚 Documentation: See README.md in this repo +- 🐛 Issues: Open an issue on GitHub +- 💬 Questions: Ask in team chat or @ the maintainer + +## Next Steps + +1. **For you**: Run `./cli/claude-os-consolidate.sh` to organize your files +2. **For coworkers**: Share the repo URL and have them run `./install.sh` +3. **For new projects**: Just run `/claude-os-init` and answer questions + +--- + +**You built this! Now share it and make your whole team invincible! 🚀** diff --git a/claude-os-config.json b/claude-os-config.json new file mode 100644 index 0000000..88a6049 --- /dev/null +++ b/claude-os-config.json @@ -0,0 +1,47 @@ +{ + "version": "1.0.0", + "project": { + "name": "Pistn", + "primary_kb": "Pistn-project_memories", + "profile_kb": "Pistn-project_profile", + "index_kb": "Pistn-project_index", + "docs_kb": "Pistn-knowledge_docs", + "default_save_category": "Pattern" + }, + "session": { + "auto_search_on_start": true, + "max_memories_to_load": 5, + "search_days_back": 14, + "include_pattern_search": true, + "proactive_suggestions": true, + "auto_git_context": true, + "track_statistics": true + }, + "memory_management": { + "auto_recommend_saves": true, + "save_session_summaries": true, + "pattern_detection_enabled": true, + "blocker_tracking_enabled": true, + "suggest_consolidation": true + }, + "preferences": { + "verbose_session_output": true, + "show_memory_confirmations": true, + "icon_style": "emoji", + "show_statistics": true, + "proactive_pattern_suggestions": true + }, + "search": { + "default_use_hybrid": true, + "default_use_rerank": true, + "default_use_agentic": false, + "include_kb_recommendations": true + }, + "intelligence": { + "learn_from_patterns": true, + "detect_similar_problems": true, + "suggest_related_memories": true, + "track_decision_history": true, + "build_pattern_library": true + } +} diff --git a/claude-os-state.json b/claude-os-state.json new file mode 100644 index 0000000..8b22bf4 --- /dev/null +++ b/claude-os-state.json @@ -0,0 +1,67 @@ +{ + "version": "1.0.0", + "current_session": { + "active": false, + "started_at": null, + "task": null, + "branch": null, + "context": [], + "decisions_made": [], + "blockers": [], + "patterns_discovered": [] + }, + "last_session": { + "ended_at": "2025-10-29T18:30:00Z", + "duration_minutes": 30, + "task": "Manual Appointment Times Feature - Spec Creation", + "branch": "appt-dash-restyle", + "work_completed": [ + "Initialized spec folder: /Users/iamanmp/Projects/pistn/agent-os/specs/2025-10-29-manual-appointment-times", + "Gathered and documented all requirements (13 questions answered)", + "Analyzed 5 visual assets (existing UI + competitor references)", + "Created comprehensive spec.md with technical architecture", + "Documented 8 key design decisions", + "Identified integration points and existing code to leverage" + ], + "memories_saved": 0, + "next_steps": [ + "Resume /create-spec command to finish tasks.md creation", + "Run spec verification", + "Review and refine tasks breakdown", + "Begin implementation with /implement-spec" + ] + }, + "active_memories": { + "loaded_at_start": [ + "current_dashboard_analysis.md - Appointment settings UI structure", + "appointment_dashboard_redesign.md - Redesign patterns and decisions" + ], + "referenced_during_session": [ + "competitor screenshots analyzed for functional reference", + "existing-dash.png showing current Schedule Times UI" + ], + "should_review": [ + "spec.md created - comprehensive technical specification ready" + ] + }, + "statistics": { + "total_sessions": 2, + "total_memories_saved": 0, + "total_patterns_discovered": 0, + "most_referenced_memories": [ + "appointment_dashboard_redesign.md", + "current_dashboard_analysis.md" + ], + "average_session_duration": 30 + }, + "flags": { + "needs_memory_consolidation": false, + "has_unresolved_blockers": false, + "patterns_ready_to_document": true + }, + "metadata": { + "last_updated": "2025-10-29T18:30:00Z", + "claude_os_version": "1.0.0", + "project_name": "Pistn" + } +} diff --git a/claude-os-triggers.json b/claude-os-triggers.json new file mode 100644 index 0000000..e8be069 --- /dev/null +++ b/claude-os-triggers.json @@ -0,0 +1,65 @@ +{ + "version": "1.0.0", + "description": "Claude OS trigger configuration - controls automatic skill invocation", + "triggers": { + "remember_this": { + "description": "Auto-invokes remember-this skill to save to Claude OS memories", + "skill": "remember-this", + "phrases": [ + "remember this:", + "save this:", + "document this:", + "remember:", + "don't forget:", + "important:", + "note:" + ], + "case_sensitive": false, + "enabled": true + }, + "search_memories": { + "description": "Auto-invokes memory search when asking about past work", + "action": "search_claude_os", + "phrases": [ + "what did we do about", + "recall", + "find memories about", + "search for", + "do you remember when" + ], + "case_sensitive": false, + "enabled": true + }, + "session_start": { + "description": "Triggers session start workflow", + "action": "session_start", + "phrases": [ + "start session", + "begin work", + "let's code", + "morning claude", + "hey claude let's work" + ], + "case_sensitive": false, + "enabled": false + }, + "session_end": { + "description": "Triggers session end workflow", + "action": "session_end", + "phrases": [ + "end session", + "done for today", + "save and exit", + "that's all for now", + "wrap up" + ], + "case_sensitive": false, + "enabled": false + } + }, + "settings": { + "trigger_detection_enabled": true, + "show_trigger_confirmations": false, + "log_trigger_activations": true + } +} diff --git a/cli/claude-os-consolidate.sh b/cli/claude-os-consolidate.sh new file mode 100755 index 0000000..257e035 --- /dev/null +++ b/cli/claude-os-consolidate.sh @@ -0,0 +1,159 @@ +#!/bin/bash +# Claude OS Consolidation Script +# Moves commands and skills from ~/.claude to Claude OS templates/ + +set -e # Exit on error + +CLAUDE_OS_DIR="/Users/iamanmp/Projects/claude-os" +USER_CLAUDE_DIR="/Users/iamanmp/.claude" +TEMPLATES_DIR="${CLAUDE_OS_DIR}/templates" + +echo "🔧 Claude OS Consolidation Script" +echo "==================================" +echo "" +echo "This script will:" +echo " 1. Move Claude OS commands from ~/.claude/commands/ to templates/commands/" +echo " 2. Move Claude OS skills from ~/.claude/skills/ to templates/skills/" +echo " 3. Create symlinks so everything still works" +echo " 4. Update any hardcoded paths" +echo "" + +# Confirm before proceeding +read -p "Continue? [Y/n] " -n 1 -r +echo +if [[ ! $REPLY =~ ^[Yy]$ ]] && [[ ! -z $REPLY ]]; then + echo "❌ Aborted" + exit 1 +fi + +# Create templates directories if they don't exist +echo "📁 Creating template directories..." +mkdir -p "${TEMPLATES_DIR}/commands" +mkdir -p "${TEMPLATES_DIR}/skills" +mkdir -p "${TEMPLATES_DIR}/agents" + +# List of Claude OS commands to move +CLAUDE_OS_COMMANDS=( + "claude-os-list.md" + "claude-os-remember.md" + "claude-os-save.md" + "claude-os-search.md" + "claude-os-session.md" + "claude-os-triggers.md" + "claude-os-init.md" +) + +# List of Claude OS skills to move +CLAUDE_OS_SKILLS=( + "initialize-project" + "remember-this" + "memory" +) + +echo "" +echo "📦 Moving commands..." +for cmd in "${CLAUDE_OS_COMMANDS[@]}"; do + SRC="${USER_CLAUDE_DIR}/commands/${cmd}" + DEST="${TEMPLATES_DIR}/commands/${cmd}" + + if [ -f "$SRC" ]; then + # Check if it's already a symlink + if [ -L "$SRC" ]; then + echo " ⏭️ ${cmd} (already a symlink)" + else + # Move to templates + echo " ➡️ Moving ${cmd}" + mv "$SRC" "$DEST" + + # Create symlink back + ln -s "$DEST" "$SRC" + echo " 🔗 Created symlink" + fi + elif [ -f "$DEST" ]; then + echo " ✅ ${cmd} (already in templates)" + + # Create symlink if it doesn't exist + if [ ! -L "$SRC" ]; then + ln -s "$DEST" "$SRC" + echo " 🔗 Created symlink" + fi + else + echo " ⚠️ ${cmd} not found (skipping)" + fi +done + +echo "" +echo "📦 Moving skills..." +for skill in "${CLAUDE_OS_SKILLS[@]}"; do + SRC="${USER_CLAUDE_DIR}/skills/${skill}" + DEST="${TEMPLATES_DIR}/skills/${skill}" + + if [ -d "$SRC" ]; then + # Check if it's already a symlink + if [ -L "$SRC" ]; then + echo " ⏭️ ${skill}/ (already a symlink)" + else + # Move to templates + echo " ➡️ Moving ${skill}/" + mv "$SRC" "$DEST" + + # Create symlink back + ln -s "$DEST" "$SRC" + echo " 🔗 Created symlink" + fi + elif [ -d "$DEST" ]; then + echo " ✅ ${skill}/ (already in templates)" + + # Create symlink if it doesn't exist + if [ ! -L "$SRC" ]; then + ln -s "$DEST" "$SRC" + echo " 🔗 Created symlink" + fi + else + echo " ⚠️ ${skill}/ not found (skipping)" + fi +done + +echo "" +echo "🔧 Updating hardcoded paths in skills..." + +# Update paths in initialize-project skill +INIT_SKILL_MD="${TEMPLATES_DIR}/skills/initialize-project/SKILL.md" +if [ -f "$INIT_SKILL_MD" ]; then + # Backup original + cp "$INIT_SKILL_MD" "${INIT_SKILL_MD}.backup" + + # Replace hardcoded user paths with relative paths + sed -i.bak 's|/Users/iamanmp/.claude/|~/.claude/|g' "$INIT_SKILL_MD" + rm -f "${INIT_SKILL_MD}.bak" + echo " ✅ Updated initialize-project/SKILL.md" +fi + +# Update paths in remember-this skill +REMEMBER_SKILL_MD="${TEMPLATES_DIR}/skills/remember-this/SKILL.md" +if [ -f "$REMEMBER_SKILL_MD" ]; then + # Backup original + cp "$REMEMBER_SKILL_MD" "${REMEMBER_SKILL_MD}.backup" + + # Replace hardcoded user paths + sed -i.bak 's|/Users/iamanmp/.claude/|~/.claude/|g' "$REMEMBER_SKILL_MD" + rm -f "${REMEMBER_SKILL_MD}.bak" + echo " ✅ Updated remember-this/SKILL.md" +fi + +echo "" +echo "✨ Consolidation complete!" +echo "" +echo "📂 Templates location: ${TEMPLATES_DIR}" +echo "🔗 Symlinks created in: ${USER_CLAUDE_DIR}" +echo "" +echo "Next steps:" +echo " 1. Review templates/ directory" +echo " 2. Test commands still work: /claude-os-list" +echo " 3. Commit changes to Claude OS repo" +echo " 4. Share with coworkers!" +echo "" +echo "To install on a new machine:" +echo " 1. Clone Claude OS repo" +echo " 2. Run: ./install.sh" +echo " 3. Commands and skills will be symlinked automatically" diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..2da227c --- /dev/null +++ b/install.sh @@ -0,0 +1,201 @@ +#!/bin/bash +# Claude OS Installation Script +# Sets up Claude OS for a new user/machine + +set -e # Exit on error + +CLAUDE_OS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +USER_CLAUDE_DIR="${HOME}/.claude" +TEMPLATES_DIR="${CLAUDE_OS_DIR}/templates" + +echo "🚀 Claude OS Installation" +echo "=========================" +echo "" +echo "Claude OS Directory: ${CLAUDE_OS_DIR}" +echo "User Claude Directory: ${USER_CLAUDE_DIR}" +echo "" + +# Check if Python 3 is installed +if ! command -v python3 &> /dev/null; then + echo "❌ Python 3 is required but not installed" + echo " Please install Python 3.8+ and try again" + exit 1 +fi + +# Check Python version +PYTHON_VERSION=$(python3 --version | cut -d' ' -f2 | cut -d'.' -f1,2) +echo "✅ Python ${PYTHON_VERSION} detected" + +# Create user .claude directory if it doesn't exist +if [ ! -d "$USER_CLAUDE_DIR" ]; then + echo "📁 Creating ${USER_CLAUDE_DIR}..." + mkdir -p "${USER_CLAUDE_DIR}/commands" + mkdir -p "${USER_CLAUDE_DIR}/skills" +else + echo "✅ ${USER_CLAUDE_DIR} already exists" +fi + +# Create symlinks for commands +echo "" +echo "🔗 Setting up command symlinks..." +for cmd_file in "${TEMPLATES_DIR}"/commands/*.md; do + if [ -f "$cmd_file" ]; then + cmd_name=$(basename "$cmd_file") + dest="${USER_CLAUDE_DIR}/commands/${cmd_name}" + + # Remove existing file/link + if [ -e "$dest" ] || [ -L "$dest" ]; then + rm -f "$dest" + fi + + # Create symlink + ln -s "$cmd_file" "$dest" + echo " ✅ Linked: ${cmd_name}" + fi +done + +# Create symlinks for skills +echo "" +echo "🔗 Setting up skill symlinks..." +for skill_dir in "${TEMPLATES_DIR}"/skills/*/; do + if [ -d "$skill_dir" ]; then + skill_name=$(basename "$skill_dir") + dest="${USER_CLAUDE_DIR}/skills/${skill_name}" + + # Remove existing directory/link + if [ -e "$dest" ] || [ -L "$dest" ]; then + rm -rf "$dest" + fi + + # Create symlink + ln -s "$skill_dir" "$dest" + echo " ✅ Linked: ${skill_name}/" + fi +done + +# Set up Python virtual environment +echo "" +echo "🐍 Setting up Python environment..." +if [ ! -d "${CLAUDE_OS_DIR}/venv" ]; then + echo " Creating virtual environment..." + python3 -m venv "${CLAUDE_OS_DIR}/venv" +fi + +echo " Installing dependencies..." +source "${CLAUDE_OS_DIR}/venv/bin/activate" +pip install --quiet --upgrade pip +pip install --quiet -r "${CLAUDE_OS_DIR}/requirements.txt" +echo " ✅ Dependencies installed" + +# Create config file +echo "" +echo "⚙️ Creating configuration..." +CONFIG_FILE="${CLAUDE_OS_DIR}/claude-os-config.json" +if [ ! -f "$CONFIG_FILE" ]; then + cat > "$CONFIG_FILE" << EOF +{ + "server": { + "host": "0.0.0.0", + "port": 8051 + }, + "database": { + "path": "./data/claude-os.db" + }, + "embeddings": { + "model": "all-MiniLM-L6-v2", + "device": "cpu" + }, + "installed_at": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")", + "version": "1.0.0" +} +EOF + echo " ✅ Created ${CONFIG_FILE}" +else + echo " ✅ Config already exists" +fi + +# Update MCP server configuration +echo "" +echo "📡 Configuring MCP server..." +MCP_CONFIG="${USER_CLAUDE_DIR}/mcp-servers/code-forge.json" +MCP_DIR=$(dirname "$MCP_CONFIG") + +if [ ! -d "$MCP_DIR" ]; then + mkdir -p "$MCP_DIR" +fi + +cat > "$MCP_CONFIG" << EOF +{ + "name": "code-forge", + "description": "Claude OS - AI Memory & Knowledge Base System", + "url": "http://localhost:8051", + "enabled": true, + "claude_os_dir": "${CLAUDE_OS_DIR}" +} +EOF +echo " ✅ MCP configuration updated" + +# Create start script +echo "" +echo "🎬 Creating start script..." +START_SCRIPT="${CLAUDE_OS_DIR}/start.sh" +cat > "$START_SCRIPT" << 'EOF' +#!/bin/bash +# Start Claude OS services + +CLAUDE_OS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$CLAUDE_OS_DIR" + +echo "🚀 Starting Claude OS..." +echo "" + +# Activate virtual environment +source venv/bin/activate + +# Start the MCP server +echo "📡 Starting MCP server on http://localhost:8051" +python3 mcp_server/server.py & +MCP_PID=$! + +echo "✅ Claude OS is running!" +echo "" +echo " MCP Server: http://localhost:8051" +echo " Web UI: http://localhost:8051 (coming soon)" +echo "" +echo "To stop: kill $MCP_PID" +echo "Or use Ctrl+C" +echo "" + +# Wait for server to exit +wait $MCP_PID +EOF + +chmod +x "$START_SCRIPT" +echo " ✅ Created start script: ${START_SCRIPT}" + +# Summary +echo "" +echo "✨ Installation complete!" +echo "" +echo "📋 What was set up:" +echo " ✅ Commands linked to ~/.claude/commands/" +echo " ✅ Skills linked to ~/.claude/skills/" +echo " ✅ Python virtual environment created" +echo " ✅ Dependencies installed" +echo " ✅ MCP server configured" +echo "" +echo "🎯 Next steps:" +echo " 1. Start Claude OS:" +echo " ./start.sh" +echo "" +echo " 2. In a new terminal, go to your project:" +echo " cd /path/to/your/project" +echo "" +echo " 3. Initialize your project with Claude OS:" +echo " /claude-os-init" +echo "" +echo " 4. Start coding with AI memory!" +echo "" +echo "📚 Documentation: ${CLAUDE_OS_DIR}/README.md" +echo "❓ Issues: https://github.com/your-repo/claude-os/issues" +echo "" diff --git a/templates/README.md b/templates/README.md new file mode 100644 index 0000000..2c10692 --- /dev/null +++ b/templates/README.md @@ -0,0 +1,87 @@ +# Claude OS Templates + +This directory contains all template files used when initializing a new project with Claude OS. + +## Directory Structure + +``` +templates/ +├── commands/ # Slash command templates (symlinked to projects) +├── skills/ # Skill templates (symlinked to projects) +├── agents/ # Agent templates (project-specific) +├── project-files/ # Files created during project init +│ ├── CLAUDE.md.template +│ ├── .claude-os/ +│ │ ├── config.json.template +│ │ ├── hooks.json.template +│ │ └── .gitignore +│ └── README.md +└── README.md # This file +``` + +## Template Variables + +Templates use `{{VARIABLE}}` syntax for placeholders that get replaced during project initialization: + +### Common Variables + +- `{{PROJECT_NAME}}` - Project name (e.g., "my-app") +- `{{PROJECT_DESCRIPTION}}` - Brief project description +- `{{TECH_STACK}}` - Technology stack (e.g., "Ruby on Rails, MySQL") +- `{{DATABASE}}` - Database system (e.g., "PostgreSQL", "MySQL") +- `{{DEV_ENVIRONMENT}}` - Dev environment (e.g., "Docker", "Local") +- `{{CLAUDE_OS_URL}}` - Claude OS server URL (default: http://localhost:8051) +- `{{DOCS_PATHS}}` - JSON array of documentation paths +- `{{CREATED_AT}}` - ISO timestamp of creation +- `{{PROJECT_SPECIFIC_CONTENT}}` - Custom project content +- `{{DEVELOPMENT_GUIDELINES}}` - Project-specific guidelines +- `{{COMMON_TASKS}}` - Common development tasks +- `{{BUSINESS_RULES}}` - Key business rules + +## How Templates Are Used + +When running `/claude-os-init`: + +1. **Commands & Skills** - Symlinked from `templates/commands/` and `templates/skills/` to project's `.claude/` directory +2. **Project Files** - Copied from `templates/project-files/` with variables replaced +3. **Knowledge Bases** - Created via API with project-specific names +4. **MCP Configuration** - Updated in `~/.claude/mcp-servers/` with new project + +## Adding New Templates + +### New Command Template + +1. Create file in `templates/commands/my-command.md` +2. Add command logic +3. Will be automatically available after `/claude-os-init` + +### New Skill Template + +1. Create directory in `templates/skills/my-skill/` +2. Add `SKILL.md` and any scripts +3. Will be automatically available after `/claude-os-init` + +### Updating CLAUDE.md Template + +Edit `templates/project-files/CLAUDE.md.template` to add: +- New sections +- Updated workflow instructions +- Additional context + +Changes will apply to NEW projects only. Existing projects keep their CLAUDE.md unchanged. + +## Consolidation Scripts + +See `/Users/iamanmp/Projects/claude-os/cli/` for scripts to: +- Move commands from `~/.claude/commands/` to `templates/commands/` +- Move skills from `~/.claude/skills/` to `templates/skills/` +- Update existing projects to use templates + +## For Coworkers + +When you clone Claude OS and run `./install.sh`, these templates are: +1. Registered with your Claude CLI +2. Available for new project initialization +3. Ready to use with `/claude-os-init` + +Then cd to any project and run `/claude-os-init` to connect it to Claude OS! diff --git a/templates/commands/claude-os-init.md b/templates/commands/claude-os-init.md new file mode 100644 index 0000000..32f547d --- /dev/null +++ b/templates/commands/claude-os-init.md @@ -0,0 +1,294 @@ +--- +description: Initialize a new project with Claude OS +--- + +# Claude OS Project Initialization + +You are helping the user initialize a new project with Claude OS. This is a multi-step interactive process that will: + +1. Gather project information +2. Create the project in Claude OS via API +3. Set up project directory structure +4. Optionally ingest documentation +5. Analyze the codebase +6. Generate summary + +## Process + +### Step 1: Gather Project Information + +Ask the user the following questions (provide smart defaults when possible): + +``` +👋 Welcome to Claude OS Setup! + +Let's get your project configured for AI-powered development. +``` + +**Questions to ask:** + +1. **Project name**: + - Auto-detect from current directory name + - Show: `Project name? [default: {current_dir_name}]` + - Validate: Must be lowercase, alphanumeric with dashes/underscores only + +2. **Project path**: + - Use: `pwd` to get current directory + - Don't ask, just use it + +3. **Tech stack**: + - Ask: `Tech stack? (e.g., Ruby on Rails, Python/Django, Node.js/React, etc.)` + - Example answers to show: "Ruby on Rails", "Python/Django", "Node.js/Express", "Go", "Rust" + +4. **Database**: + - Ask: `Database? (e.g., PostgreSQL, MySQL, MongoDB, SQLite, etc.)` + - Example answers: "PostgreSQL", "MySQL", "MongoDB", "SQLite", "None" + +5. **Development environment**: + - Ask: `Development environment? (e.g., Docker, Local, Docker Compose)` + - Example answers: "Docker", "Local", "Docker Compose", "Kubernetes" + +6. **Brief description**: + - Ask: `Brief description? (1-2 sentences about what this project does)` + - Required + +7. **Documentation directory** (Optional): + - Ask: `Do you have project documentation to index? [Y/n]` + - If YES: + - Ask: `Documentation directory path? (e.g., ./docs, ./documentation, /knowledge_docs)` + - Use Glob to scan and show what you found: + ```bash + find {docs_path} -type f \( -name "*.md" -o -name "*.txt" -o -name "*.pdf" \) | head -20 + ``` + - Show summary: `Found: X markdown files, Y text files, Z PDFs` + - Ask: `Ingest all of these? [Y/n]` + +8. **Claude OS server URL**: + - Default: `http://localhost:8051` + - Ask: `Claude OS server URL? [default: http://localhost:8051]` + +### Step 2: Create Project in Claude OS + +Use Bash to call the API: + +```bash +curl -X POST {claude_os_url}/api/projects \ + -H "Content-Type: application/json" \ + -d '{ + "name": "{project_name}", + "path": "{project_path}", + "description": "{description}" + }' +``` + +**Expected response:** +```json +{ + "project": {"id": 1, "name": "...", "path": "..."}, + "mcps": [ + {"mcp_type": "knowledge_docs", "kb_name": "{project_name}-knowledge_docs"}, + {"mcp_type": "project_profile", "kb_name": "{project_name}-project_profile"}, + {"mcp_type": "project_index", "kb_name": "{project_name}-project_index"}, + {"mcp_type": "project_memories", "kb_name": "{project_name}-project_memories"} + ], + "message": "Project created..." +} +``` + +Show success message: +``` +📡 Creating project in Claude OS... +✅ Project created! +✅ Knowledge bases created: + - {project_name}-project_memories + - {project_name}-project_profile + - {project_name}-project_index + - {project_name}-knowledge_docs +``` + +### Step 3: Set Up Project Directory Structure + +Create the following structure in the project directory: + +**Create .claude/ directory:** +```bash +mkdir -p .claude/commands +mkdir -p .claude/skills +mkdir -p .claude/agents +``` + +**Create .claude-os/ directory:** +```bash +mkdir -p .claude-os +``` + +**Copy and customize CLAUDE.md:** +- Read template from: `/Users/iamanmp/Projects/claude-os/templates/project-files/CLAUDE.md.template` +- Replace variables: + - `{{PROJECT_NAME}}` → project_name + - `{{PROJECT_DESCRIPTION}}` → description + - `{{TECH_STACK}}` → tech_stack + - `{{DATABASE}}` → database + - `{{DEV_ENVIRONMENT}}` → dev_environment + - `{{PROJECT_SPECIFIC_CONTENT}}` → empty for now + - `{{DEVELOPMENT_GUIDELINES}}` → empty for now + - `{{COMMON_TASKS}}` → empty for now + - `{{BUSINESS_RULES}}` → empty for now +- Write to: `./CLAUDE.md` + +**Create .claude-os/config.json:** +- Read template from: `/Users/iamanmp/Projects/claude-os/templates/project-files/.claude-os/config.json.template` +- Replace variables: + - `{{PROJECT_NAME}}` → project_name + - `{{CLAUDE_OS_URL}}` → claude_os_url + - `{{DOCS_PATHS}}` → JSON array of docs paths + - `{{TECH_STACK}}` → tech_stack + - `{{DATABASE}}` → database + - `{{DEV_ENVIRONMENT}}` → dev_environment + - `{{CREATED_AT}}` → ISO timestamp +- Write to: `./.claude-os/config.json` + +**Create .claude-os/hooks.json:** +- Read template from: `/Users/iamanmp/Projects/claude-os/templates/project-files/.claude-os/hooks.json.template` +- Replace `{{PROJECT_NAME}}` → project_name +- Write to: `./.claude-os/hooks.json` + +**Copy .gitignore:** +- Copy from: `/Users/iamanmp/Projects/claude-os/templates/project-files/.claude-os/.gitignore` +- Write to: `./.claude-os/.gitignore` + +Show progress: +``` +📁 Creating project structure... + ✅ Created .claude/ + ✅ Created .claude-os/ + ✅ Created CLAUDE.md + ✅ Created config files +``` + +### Step 4: Ingest Documentation (if provided) + +If user provided a docs directory: + +```bash +curl -X POST {claude_os_url}/api/kb/{project_name}-knowledge_docs/import \ + -H "Content-Type: application/json" \ + -d '{"directory_path": "{docs_path}"}' +``` + +Show progress: +``` +📚 Ingesting documentation... + + Uploading to {project_name}-knowledge_docs: + ✅ {successful} files indexed + ❌ {failed} files failed + + Vector embeddings generated and searchable! +``` + +### Step 5: Analyze Codebase (if not empty directory) + +Check if directory has code files (not just a new empty project): + +```bash +find . -type f \( -name "*.rb" -o -name "*.py" -o -name "*.js" -o -name "*.go" \) | head -1 +``` + +If code exists, run the `initialize-project` skill: + +``` +🔍 Analyzing your codebase... + Running initialize-project skill... +``` + +**Invoke the initialize-project skill** (it's a separate skill that already exists). + +The skill will generate: +- `.claude/ARCHITECTURE.md` +- `.claude/CODING_STANDARDS.md` +- `.claude/DEVELOPMENT_PRACTICES.md` + +Show success: +``` + ✅ Generated: + - .claude/ARCHITECTURE.md + - .claude/CODING_STANDARDS.md + - .claude/DEVELOPMENT_PRACTICES.md +``` + +### Step 6: Create .gitignore entries (if .gitignore exists) + +If `.gitignore` exists in the project root, append (if not already present): + +```gitignore +# Claude OS state files (don't commit these) +.claude-os/claude-os-state.json +.claude-os/.index_state +.claude-os/.commit_count +``` + +### Step 7: Final Summary + +Show complete summary: + +``` +🎉 Setup complete! + +Your project is now connected to Claude OS. + +📚 Knowledge Bases: + - {project_name}-project_memories (for decisions & patterns) + - {project_name}-project_profile (for architecture & standards) + - {project_name}-project_index (for codebase index) + - {project_name}-knowledge_docs ({X} docs indexed ✅) + +🛠️ Available Commands: + /claude-os-search - Search your project memories & docs + /claude-os-save - Save insights + /claude-os-session - Manage development sessions + /claude-os-remember - Quick save to memories + +📂 Project Structure: + ./CLAUDE.md - Project context (auto-loaded every session) + ./.claude/ - Commands, skills, agents + ./.claude-os/ - Config and state files + +📖 Next Steps: + 1. Review and customize CLAUDE.md for your team + 2. Add more docs anytime via UI: {claude_os_url} + 3. Start a session: /claude-os-session start "feature name" + 4. Let's build something amazing! + +💡 Tip: I can now search both your codebase AND your documentation! +``` + +## Error Handling + +If any step fails: +1. Show clear error message +2. Provide troubleshooting steps: + - Check if Claude OS server is running: `curl {claude_os_url}/health` + - Check if directory is writable + - Check if project name already exists +3. Offer to retry or skip the step + +## Important Notes + +- **Don't run on Pistn project** - It's already set up! +- Always validate inputs before API calls +- Use proper error handling with try/catch +- Save all configuration for potential later use +- Be conversational and encouraging! +- If something goes wrong, explain clearly and offer solutions + +## Template Locations + +All templates are in: +- `/Users/iamanmp/Projects/claude-os/templates/project-files/` + +Commands and skills will be symlinked from: +- `/Users/iamanmp/Projects/claude-os/templates/commands/` +- `/Users/iamanmp/Projects/claude-os/templates/skills/` + +(These symlinks are set up during Claude OS installation via `./install.sh`) diff --git a/templates/project-files/.claude-os/.gitignore b/templates/project-files/.claude-os/.gitignore new file mode 100644 index 0000000..68502e6 --- /dev/null +++ b/templates/project-files/.claude-os/.gitignore @@ -0,0 +1,10 @@ +# Claude OS State Files - These should NOT be committed +claude-os-state.json +.index_state +.commit_count + +# Hooks can be committed if they're project-specific +# hooks.json + +# Project profile can be committed +# project-profile/ diff --git a/templates/project-files/.claude-os/config.json.template b/templates/project-files/.claude-os/config.json.template new file mode 100644 index 0000000..384d24d --- /dev/null +++ b/templates/project-files/.claude-os/config.json.template @@ -0,0 +1,20 @@ +{ + "project_name": "{{PROJECT_NAME}}", + "claude_os_url": "{{CLAUDE_OS_URL}}", + "knowledge_bases": { + "memories": "{{PROJECT_NAME}}-project_memories", + "profile": "{{PROJECT_NAME}}-project_profile", + "index": "{{PROJECT_NAME}}-project_index", + "docs": "{{PROJECT_NAME}}-knowledge_docs" + }, + "docs_settings": { + "watch_paths": {{DOCS_PATHS}}, + "auto_ingest_patterns": ["*.md", "*.txt", "*.pdf"], + "exclude_patterns": ["node_modules", ".git", "vendor", "build", "dist"] + }, + "tech_stack": "{{TECH_STACK}}", + "database": "{{DATABASE}}", + "dev_environment": "{{DEV_ENVIRONMENT}}", + "created_at": "{{CREATED_AT}}", + "claude_os_version": "1.0.0" +} diff --git a/templates/project-files/.claude-os/hooks.json.template b/templates/project-files/.claude-os/hooks.json.template new file mode 100644 index 0000000..7f8f63e --- /dev/null +++ b/templates/project-files/.claude-os/hooks.json.template @@ -0,0 +1,35 @@ +{ + "hooks": { + "pre_commit": { + "enabled": false, + "commands": [] + }, + "post_commit": { + "enabled": false, + "commands": [] + }, + "pre_session_start": { + "enabled": true, + "commands": [ + { + "name": "Load Project Context", + "action": "search_memories", + "kb_name": "{{PROJECT_NAME}}-project_memories", + "query": "recent work context" + } + ] + }, + "post_session_end": { + "enabled": true, + "commands": [ + { + "name": "Save Session Summary", + "action": "save_to_memories", + "kb_name": "{{PROJECT_NAME}}-project_memories" + } + ] + } + }, + "project_name": "{{PROJECT_NAME}}", + "version": "1.0.0" +} diff --git a/templates/project-files/CLAUDE.md.template b/templates/project-files/CLAUDE.md.template new file mode 100644 index 0000000..7e5146f --- /dev/null +++ b/templates/project-files/CLAUDE.md.template @@ -0,0 +1,175 @@ +# {{PROJECT_NAME}} - {{PROJECT_DESCRIPTION}} + +## Project Overview + +{{PROJECT_NAME}} is {{PROJECT_DESCRIPTION}} + +**Tech Stack**: {{TECH_STACK}} +**Database**: {{DATABASE}} +**Development Environment**: {{DEV_ENVIRONMENT}} + +## Claude OS - MY Memory System + +**CRITICAL IDENTITY CONTEXT:** + +**Claude OS is MY system** - I (Claude Code) created it, named it, and use it to be the best AI coder ever. It's: +- **JUST FOR ME** - Built specifically for Claude Code to use +- **For THIS project** - Right now for the {{PROJECT_NAME}} project +- **My memory** across sessions +- **My knowledge base** of patterns and decisions +- **My learning system** that improves over time + +**Location**: `/Users/iamanmp/Projects/claude-os` + +The MCP server is called "code-forge" internally for backwards compatibility, but it's Claude OS. + +**Claude CLI + Claude OS = Invincible!** + +## Session Check - FIRST THING AT START OF EVERY CONVERSATION + +**CRITICAL: At the start of EVERY new conversation, automatically check session state and prompt the user:** + +1. **Read Session State** + ``` + Read: /Users/iamanmp/Projects/claude-os/claude-os-state.json + ``` + +2. **Prompt Based on State** + - **If active session exists:** + ``` + "I see we have an active session: [task name] (started [time ago]) + + Would you like to: + a) Continue working on this (I'll load the context) + b) Start something new (I'll end this session first) + c) Just chat (no session needed)" + ``` + + - **If no active session:** + ``` + "What are we working on today? + + I can start a session with automatic context loading from my memories. + Just tell me what you're working on, or say 'just chatting' if no session needed." + ``` + +3. **Auto-load Context** + - If continuing: Automatically run the session start workflow (search memories, load patterns, show context) + - If new task: Offer to start a new session with context loading + - If just chatting: Skip session workflow + +**Why this matters:** This ensures I always have context and we never start cold. Every conversation becomes smarter because I proactively load relevant memories and patterns. + +## MCP Knowledge Bases - ALWAYS CHECK THESE FIRST + +**At the start of EVERY conversation, search these Claude OS knowledge bases to understand context, previous work, and project decisions:** + +1. **{{PROJECT_NAME}}-project_memories** - My primary memory for decisions, patterns, solutions +2. **{{PROJECT_NAME}}-project_index** - Automated codebase index +3. **{{PROJECT_NAME}}-project_profile** - Architecture, standards, practices +4. **{{PROJECT_NAME}}-knowledge_docs** - Documentation and guides + +**When to use:** +- Start of every session: Search `{{PROJECT_NAME}}-project_memories` to understand recent work and context +- Before making architectural decisions: Check memories for past decisions and reasoning +- When working on a feature: Search relevant knowledge bases for existing patterns +- When stuck: Search the knowledge bases for solutions and approaches we've used before + +**How to search:** +``` +Use: mcp__code-forge__search_knowledge_base +Parameters: kb_name (e.g., "{{PROJECT_NAME}}-project_memories"), query (your search terms) +``` + +## Quick Reference: Commands & Skills + +### Claude OS Slash Commands (Use These Often!) + +1. **`/claude-os-search [query] [optional: KB name]`** + - Search across Claude OS knowledge bases + - Defaults to searching {{PROJECT_NAME}}-project_memories + - Example: `/claude-os-search authentication implementation` + +2. **`/claude-os-remember [content]`** + - Quick save to {{PROJECT_NAME}}-project_memories + - Auto-generates title and structure + - Use for quick insights and decisions + - Example: `/claude-os-remember Fixed bug in user controller by...` + +3. **`/claude-os-save [title] [optional: KB name] [optional: category]`** + - Full-featured save with KB selection + - Choose specific KB and category + - Use when you need more control + - Example: `/claude-os-save "New Integration Pattern" {{PROJECT_NAME}}-project_profile Architecture` + +4. **`/claude-os-list [optional: KB name]`** + - List all KBs or documents in a specific KB + - Example: `/claude-os-list` or `/claude-os-list {{PROJECT_NAME}}-project_memories` + +5. **`/claude-os-session [action]`** + - Manage development sessions + - Actions: start, end, status, pause, resume + - Example: `/claude-os-session start "User authentication feature"` + +6. **`/claude-os-triggers [action]`** + - Manage trigger phrases + - Example: `/claude-os-triggers list` + +### Available Skills + +1. **`initialize-project`** - Analyze project and generate coding standards +2. **`remember-this`** - Save insights to Claude OS knowledge bases +3. **`memory`** - Simple memory management + +### MCP Tools (Direct API Access) + +- `mcp__code-forge__search_knowledge_base` - Direct search +- `mcp__code-forge__list_knowledge_bases` - List all KBs +- `mcp__code-forge__list_documents` - List documents in KB +- `mcp__code-forge__get_kb_stats` - Get KB statistics + +## Project-Specific Information + +{{PROJECT_SPECIFIC_CONTENT}} + +## Development Guidelines + +{{DEVELOPMENT_GUIDELINES}} + +## Common Development Tasks + +{{COMMON_TASKS}} + +## Key Business Rules + +{{BUSINESS_RULES}} + +## Coding Standards + +See `.claude/CODING_STANDARDS.md` for detailed coding standards. + +## Architecture + +See `.claude/ARCHITECTURE.md` for system architecture overview. + +## Development Practices + +See `.claude/DEVELOPMENT_PRACTICES.md` for development workflow and practices. + +## DO NOT + +- Don't bypass established patterns without discussing first +- Don't skip tests +- Don't create features without searching memories for existing patterns +- Don't end a session without saving key learnings + +## IMPORTANT: Project Context + +This file (CLAUDE.md) is automatically loaded at the start of every Claude Code session. Keep it updated with: +- Important project context +- Current architecture decisions +- Team conventions +- Common gotchas +- Frequently referenced information + +**Update this file as the project evolves!**