From 38c1b78e68d924405bff6775f71912e0bdcc52f6 Mon Sep 17 00:00:00 2001 From: William Stuckey Date: Thu, 26 Mar 2026 18:56:01 -0500 Subject: [PATCH] Add Roo Code context sync: .clinerules symlink and sync script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add .clinerules symlink → CLAUDE.md so Roo Code reads same project context - Add sync-context.sh: copies global context to ~/.claude/ for Claude Code and prints content for manual paste into Roo Code Custom Instructions - Update CLAUDE.md: note .clinerules symlink, add sync-context.sh to file list - Update CONTEXT.md: add AI context file mapping table, update file structure - Update README.md: rewrite AI Context Files section to cover both tools, document symlink strategy and sync workflow --- .clinerules | 1 + CLAUDE.md | 2 ++ CONTEXT.md | 16 +++++++++++++++- README.md | 47 +++++++++++++++++++++++++++++++---------------- sync-context.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 17 deletions(-) create mode 120000 .clinerules create mode 100755 sync-context.sh diff --git a/.clinerules b/.clinerules new file mode 120000 index 0000000..681311e --- /dev/null +++ b/.clinerules @@ -0,0 +1 @@ +CLAUDE.md \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md index 85c384b..2729931 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,6 +1,7 @@ # Ein AI Proxy - Project Context Anthropic-compatible proxy that routes AI requests to multiple providers based on model name: sonnet→GLM-4.7 (Z.ai), opus→Anthropic, haiku→DeepSeek. +`.clinerules` is a symlink to this file so Roo Code reads the same context. ## File Structure - `proxy.mjs` - Main proxy server (zero dependencies, Node.js built-ins only) @@ -8,6 +9,7 @@ Anthropic-compatible proxy that routes AI requests to multiple providers based o - `config.example.json` - Template config - `ein-ai-proxy.service` - Systemd unit file - `deploy.sh` - Deployment and testing script +- `sync-context.sh` - Syncs global context to Claude Code and Roo Code ## Development Run locally: `node proxy.mjs` (requires `config.json`) diff --git a/CONTEXT.md b/CONTEXT.md index 07d2562..5f5655a 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -161,6 +161,16 @@ Three profiles configured: | "opus" | claude-opus-4-6 | Anthropic Opus | ON | 1M context enabled | | "cheap" | claude-haiku-4-5 | DeepSeek V3.2 | OFF | Fast/cheap tasks | +### AI Context File Mapping +Both Claude Code and Roo Code use context files, but with different conventions: + +| Level | Claude Code | Roo Code | Source of truth | +|-------|-------------|----------|-----------------| +| Project | `CLAUDE.md` | `.clinerules` (symlink → CLAUDE.md) | `CLAUDE.md` | +| Global | `~/.claude/CLAUDE.md` | Custom Instructions in Roo UI | `global-claude-md/CLAUDE.md` | + +Run `./sync-context.sh` from the repo root to sync global context to both tools. + ## Proxy Internals ### File Structure @@ -171,10 +181,14 @@ Three profiles configured: ├── config.example.json # Template config ├── ein-ai-proxy.service # Systemd unit file ├── deploy.sh # Deployment script +├── sync-context.sh # Syncs global context to Claude Code & Roo Code ├── package.json # Package metadata ├── .gitignore # Excludes config.json ├── CONTEXT.md # This file -├── CLAUDE.md # Project-level context +├── CLAUDE.md # Project-level context (Claude Code) +├── .clinerules # Symlink → CLAUDE.md (Roo Code) +├── global-claude-md/ # Global context source of truth +│ └── CLAUDE.md # Synced to ~/.claude/ and Roo Custom Instructions └── README.md # Public documentation ``` diff --git a/README.md b/README.md index faddb7d..bc44392 100644 --- a/README.md +++ b/README.md @@ -212,31 +212,44 @@ To route additional models, add entries to the `MODEL_ROUTES` object in `proxy.m ## AI Context Files -This repo includes context files for AI coding agents (Claude Code CLI and Roo Code). There are three levels: +This repo includes context files for both **Claude Code CLI** and **Roo Code** (VS Code). The two tools use different file conventions, so we keep them in sync: -| File | Scope | Loaded when... | +### Project-level context + +| Claude Code reads | Roo Code reads | Source of truth | |---|---|---| -| `CLAUDE.md` | Project-level | AI agent is working inside this repo | -| `CONTEXT.md` | Project-level | Referenced from CLAUDE.md; agent reads on demand | -| `global-claude-md/CLAUDE.md` | User-level | Every AI session, regardless of project | +| `CLAUDE.md` | `.clinerules` | `CLAUDE.md` | +| `CONTEXT.md` | `CONTEXT.md` | `CONTEXT.md` | -**`global-claude-md/CLAUDE.md`** is the source of truth for the global file. It gets copied to `~/.claude/CLAUDE.md` on each machine. To update it: +`.clinerules` is a **git-tracked symlink** pointing to `CLAUDE.md`. Both tools read the same content from the same source — edit `CLAUDE.md` and both stay in sync automatically. + +`CONTEXT.md` is the detailed infrastructure reference. Both tools can read it directly when needed. + +### Global context + +| Claude Code | Roo Code | +|---|---| +| `~/.claude/CLAUDE.md` (file on disk) | Custom Instructions setting (in Roo Code UI) | + +The source of truth is `global-claude-md/CLAUDE.md` in this repo. To update both tools, run the sync script: ```bash -# 1. Edit the source in this repo +# 1. Edit the source vim global-claude-md/CLAUDE.md # 2. Commit and push -git add -A && git commit -m "Update global CLAUDE.md" && git push +git add -A && git commit -m "Update global context" && git push -# 3. Copy to work laptop -cp global-claude-md/CLAUDE.md ~/.claude/CLAUDE.md - -# 4. Copy to mini-server -scp global-claude-md/CLAUDE.md mini-server:~/.claude/CLAUDE.md +# 3. Sync to both tools +./sync-context.sh ``` -The project-level files (`CLAUDE.md` and `CONTEXT.md`) are picked up automatically when an AI agent opens this repo — no copying needed. +The script copies the file to `~/.claude/CLAUDE.md` (for Claude Code) and prints the content for you to paste into Roo Code's Custom Instructions (Roo sidebar → gear icon → Custom Instructions). + +To also update mini-server's Claude Code: +```bash +scp global-claude-md/CLAUDE.md mini-server:~/.claude/CLAUDE.md +``` ## Files @@ -247,10 +260,12 @@ The project-level files (`CLAUDE.md` and `CONTEXT.md`) are picked up automatical | `config.example.json` | Template config — copy to `config.json` and fill in | | `ein-ai-proxy.service` | Systemd unit file for running as a service | | `deploy.sh` | Deployment script — validates config, tests proxy, installs service | +| `sync-context.sh` | Syncs global AI context to Claude Code and Roo Code | | `package.json` | Package metadata (no dependencies) | -| `CLAUDE.md` | Project-level context loaded by AI coding agents | +| `CLAUDE.md` | Project-level context for Claude Code | +| `.clinerules` | Symlink → `CLAUDE.md` — project-level context for Roo Code | | `CONTEXT.md` | Full infrastructure documentation (network, servers, operations) | -| `global-claude-md/CLAUDE.md` | User-level context to copy to `~/.claude/CLAUDE.md` | +| `global-claude-md/CLAUDE.md` | Source of truth for global context (both tools) | ## License diff --git a/sync-context.sh b/sync-context.sh new file mode 100755 index 0000000..3023107 --- /dev/null +++ b/sync-context.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# ============================================================= +# Sync global AI context to Claude Code and Roo Code +# +# Source of truth: global-claude-md/CLAUDE.md +# +# This script: +# 1. Copies to ~/.claude/CLAUDE.md (Claude Code CLI reads this) +# 2. Prints content for manual paste into Roo Code Custom Instructions +# ============================================================= +set -e + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +SOURCE="$SCRIPT_DIR/global-claude-md/CLAUDE.md" + +if [ ! -f "$SOURCE" ]; then + echo "[!] Source file not found: $SOURCE" + exit 1 +fi + +# --- Claude Code CLI --- +CLAUDE_DIR="$HOME/.claude" +CLAUDE_TARGET="$CLAUDE_DIR/CLAUDE.md" + +mkdir -p "$CLAUDE_DIR" +cp "$SOURCE" "$CLAUDE_TARGET" +echo "[✓] Claude Code: copied to $CLAUDE_TARGET" + +# --- Roo Code (VS Code) --- +echo "" +echo "============================================" +echo " Roo Code: Manual Step Required" +echo "============================================" +echo "" +echo "Copy the text between the lines below, then paste it into:" +echo " Roo Code sidebar → Settings (gear icon) → Custom Instructions" +echo "" +echo "────────────────────────────────────────────" +cat "$SOURCE" +echo "────────────────────────────────────────────" +echo "" +echo "Done. Both tools are now in sync."