sync
The `/nemp:sync` command establishes bidirectional synchronization between Nemp Memory and a CLAUDE.md file, enabling users to import manually written project context into Nemp memories, detect conflicts between documented and actual project state, and export updated memories back to CLAUDE.md. Use it when maintaining a project documentation file that needs to stay aligned with Nemp's stored context, with options for import-only, export-only, or conflict-checking modes.
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/SukinShetty/Nemp-memory/HEAD/commands/sync.md -o ~/.claude/commands/sync.mdsync.md
# /nemp:sync
Two-way bridge between Nemp Memory and CLAUDE.md. Import user-written context from CLAUDE.md into Nemp, detect conflicts with actual project state, and update the Nemp section.
## Usage
```
/nemp:sync # Full two-way sync
/nemp:sync --import-only # Only read from CLAUDE.md into Nemp, don't write back
/nemp:sync --export-only # Same as /nemp:export
/nemp:sync --check # Only detect conflicts, don't change anything
```
## Arguments
- `--import-only` (optional): Only import from CLAUDE.md to Nemp memories, skip export
- `--export-only` (optional): Only export Nemp memories to CLAUDE.md (same as /nemp:export)
- `--check` (optional): Dry run - detect conflicts without making any changes
## Instructions
When the user invokes `/nemp:sync`, follow these steps:
### Step 1: Parse Arguments
Extract the mode from arguments:
- No arguments → full sync (import + conflict check + export)
- `--import-only` → only import from CLAUDE.md
- `--export-only` → only export to CLAUDE.md
- `--check` → only detect conflicts, no changes
### Step 2: Read CLAUDE.md
Check if CLAUDE.md exists and read its contents:
```bash
[ -f "CLAUDE.md" ] && cat CLAUDE.md || echo "CLAUDE_MD_NOT_FOUND"
```
If CLAUDE.md doesn't exist:
```
⚠️ No CLAUDE.md found.
Nothing to import. You can:
/nemp:export - Create CLAUDE.md from Nemp memories
/nemp:init - Auto-detect project stack first
```
### Step 3: Parse CLAUDE.md Content
Split CLAUDE.md into two parts:
**Nemp Section (SKIP):**
- Starts with: `## Project Context (via Nemp Memory)`
- Ends at: next `## ` heading, or `---` on its own line, or end of file
- This is Nemp's own output — do NOT re-import it
**User Content (IMPORT):**
- Everything OUTSIDE the Nemp section
- This includes manually written context, rules, preferences, architecture notes
### Step 4: Extract Importable Context
Scan the user content for importable information. Look for patterns like:
| Pattern | Memory Key |
|---------|------------|
| "Tech stack:", "Stack:", "We use" | `stack` |
| "Framework:", "Built with" | `framework` |
| "Database:", "DB:", "ORM:" | `database` |
| "Auth:", "Authentication:" | `auth` |
| "Styling:", "CSS:", "UI:" | `styling` |
| "Testing:", "Tests:" | `testing` |
| "Package manager:", "Use npm/pnpm/yarn/bun" | `package-manager` |
| "Architecture:", "Structure:" | `architecture` |
| "Rules:", "Conventions:", "Preferences:" | `conventions` |
| "API:", "Endpoints:" | `api` |
| Bullet points under headings | Extract as relevant memory |
**Parsing strategies:**
1. Look for markdown headings (`##`, `###`) and extract content under them
2. Look for bold labels (`**key:**`) followed by values
3. Look for bullet lists that describe project aspects
4. Look for code blocks with configuration hints
### Step 5: Load Existing Nemp Memories
```bash
[ -f ".nemp/memories.json" ] && cat .nemp/memories.json || echo "{}"
```
### Step 6: Import New Memories
For each piece of context extracted from CLAUDE.md:
1. **Check for duplicates**: If a memory with the same key already exists in `.nemp/memories.json`, SKIP it
2. **Create new memory**: If the key doesn't exist, create it with:
```json
{
"key": "<extracted-key>",
"value": "<extracted-value>",
"created": "<ISO-8601-timestamp>",
"updated": "<ISO-8601-timestamp>",
"tags": ["from-claude-md"],
"source": "CLAUDE.md"
}
```
Track what was imported for the summary.
### Step 7: Read Project Config Files
Scan the actual project state by reading configuration files:
```bash
# Check for package.json
[ -f "package.json" ] && cat package.json
# Check for tsconfig
[ -f "tsconfig.json" ] && echo "TYPESCRIPT: true"
# Check for common configs
[ -f "next.config.js" ] || [ -f "next.config.mjs" ] || [ -f "next.config.ts" ] && echo "NEXTJS: true"
[ -f "vite.config.ts" ] || [ -f "vite.config.js" ] && echo "VITE: true"
[ -f "tailwind.config.js" ] || [ -f "tailwind.config.ts" ] && echo "TAILWIND: true"
```
Extract actual values from package.json:
- `dependencies` and `devDependencies` for frameworks, ORMs, auth libraries
- `name` for project name
- `scripts` for available commands
### Step 8: Detect Conflicts
Compare three sources for conflicts:
1. **CLAUDE.md content** (user-written)
2. **Nemp memories** (stored in .nemp/memories.json)
3. **Actual project state** (from package.json, config files)
**Conflict detection rules:**
| Check | Conflict Example |
|-------|------------------|
| ORM mismatch | CLAUDE.md says "Prisma" but package.json has `drizzle-orm` |
| Framework mismatch | Memory says "React 18" but package.json has `react: ^19.0.0` |
| Auth mismatch | CLAUDE.md says "Clerk" but package.json has `next-auth` |
| Database mismatch | Memory says "MongoDB" but dependencies show `pg` |
| Package manager mismatch | CLAUDE.md says "yarn" but `pnpm-lock.yaml` exists |
| Styling mismatch | Memory says "styled-components" but `tailwindcss` is installed |
**Conflict output format:**
```
⚠️ Conflicts Detected
┌─────────────────────────────────────────────────────────────┐
│ CONFLICT 1: Database/ORM │
├─────────────────────────────────────────────────────────────┤
│ CLAUDE.md says: Prisma ORM │
│ package.json shows: drizzle-orm ^0.30.0 │
│ │
│ Action needed: Update CLAUDE.md or Nemp memory │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ CONFLICT 2: React Version │
├─────────────────────────────────────────────────────────────┤
│ Nemp memory says: React 18 │
│ package.json shows: react ^19.0.0 │
│ │
│ Action needed: Run /nemp:save framework to update │
└────────────Activate Nemp Pro with your license key
View captured activity log
Enable or disable automatic activity capture
Enable or disable automatic cross-provider memory export
Enable or disable automatic syncing to CLAUDE.md
Search memories by keyword and show relevant context
Nemp Cortex — memory intelligence layer (Pro)
Cortex decay engine — auto-archive stale memories (Pro)