Synchronization patterns for CLAUDE.md and GEMINI.md memory files. Covers import syntax, drift detection, and one-way sync. Use when setting up GEMINI.md, detecting context drift between memory files, understanding @import syntax, or troubleshooting sync issues.
Limited to specific tools
Additional assets for this skill
This skill is limited to using the following tools:
STOP - Before providing ANY response about Gemini memory/memport:
- INVOKE
gemini-cli-docsskill- QUERY for the specific memory or import topic
- BASE all responses EXCLUSIVELY on official documentation loaded
This skill provides patterns for keeping Claude Code (CLAUDE.md) and Gemini CLI (GEMINI.md) memory files synchronized. The core principle is CLAUDE.md as source of truth with GEMINI.md importing and adding overrides.
Keywords: sync memory, sync context, claude.md gemini.md, memory import, context drift, @import, memport
Use this skill when:
CLAUDE.md (Source of Truth)
│
│ @import
▼
GEMINI.md (Imports + Overrides)
Why CLAUDE.md is the source:
# GEMINI.md
@CLAUDE.md
## Gemini-Specific Overrides
You are Gemini CLI. Your unique capabilities:
- Large context window (Flash) / Very large (Pro)
- Interactive PTY shell (vim, git rebase -i, htop)
- Checkpointing with instant rollback
- Policy engine for tool control
- Native Google Cloud authentication
### When to Use Your Strengths
- **Bulk analysis**: Use your large context for codebase-wide exploration
- **Interactive tools**: Handle vim, git interactive commands
- **Risky operations**: Use sandbox and checkpointing
- **Second opinions**: Provide independent validation
### Model Selection
- Use **Flash** for bulk analysis and simple tasks
- Use **Pro** for complex reasoning and very large contexts
Gemini CLI uses @ prefix for imports (memport):
# Import entire file
@CLAUDE.md
# Import relative path
@./docs/conventions.md
# Import from parent
@../shared/COMMON.md
Note: Unlike CLAUDE.md's flexible import, GEMINI.md's memport has:
# Quick diff (ignoring Gemini-specific sections)
diff <(grep -v "^## Gemini-Specific" CLAUDE.md) <(grep -v "^## Gemini-Specific\|^@" GEMINI.md)
# Store hash of CLAUDE.md
claude_hash=$(md5sum CLAUDE.md | cut -d' ' -f1)
# Store in sync state
echo "{\"claude_hash\": \"$claude_hash\", \"last_sync\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" > .claude/temp/sync-state.json
# Compare current hash to stored
current_hash=$(md5sum CLAUDE.md | cut -d' ' -f1)
stored_hash=$(cat .claude/temp/sync-state.json 2>/dev/null | jq -r '.claude_hash // ""')
if [ "$current_hash" != "$stored_hash" ]; then
echo "CLAUDE.md has changed since last sync"
fi
GEMINI.md simply imports CLAUDE.md - no sync needed:
# GEMINI.md
@CLAUDE.md
## Gemini-Specific
{overrides here}
Pros:
Cons:
Copy specific sections from CLAUDE.md:
# Extract specific sections
conventions=$(sed -n '/^## Conventions/,/^## /p' CLAUDE.md | head -n -1)
build_commands=$(sed -n '/^## Build/,/^## /p' CLAUDE.md | head -n -1)
# Rebuild GEMINI.md
cat > GEMINI.md << EOF
# GEMINI.md
## Conventions (synced from CLAUDE.md)
$conventions
## Build Commands (synced from CLAUDE.md)
$build_commands
## Gemini-Specific Overrides
{your overrides}
EOF
Pros:
Cons:
Generate GEMINI.md from CLAUDE.md with transformations:
# Transform CLAUDE.md to GEMINI.md
cat CLAUDE.md | \
sed 's/Claude Code/Gemini CLI/g' | \
sed 's/claude/gemini/g' > GEMINI.md
# Append Gemini-specific section
cat >> GEMINI.md << 'EOF'
## Gemini-Specific Overrides
{overrides}
EOF
Symptom: Gemini doesn't see CLAUDE.md content
Fix: Ensure correct path syntax
# Correct
@CLAUDE.md
@./CLAUDE.md
# Incorrect
@/CLAUDE.md (absolute paths may fail)
Symptom: Error about circular references
Fix: Don't have CLAUDE.md import GEMINI.md
Symptom: Nested imports not loading
Fix: Memport has max depth of 5. Flatten import chain.
Symptom: Gemini behaves differently than Claude
Fix:
/sync-context commandAlways prefer import over copy:
# GEMINI.md - Good
@CLAUDE.md
## Gemini-Specific
...
Only override what's truly Gemini-specific:
If using section-based sync, note the source:
## Conventions (synced from CLAUDE.md on 2025-11-30)
Test that Gemini understands the context:
gemini "What are the project conventions?" --output-format json
Include in CI or pre-commit:
# In CI
./scripts/check-memory-drift.sh
# 1. Ensure CLAUDE.md exists
if [ ! -f "CLAUDE.md" ]; then
echo "CLAUDE.md not found. Create it first."
exit 1
fi
# 2. Create GEMINI.md with import
cat > GEMINI.md << 'EOF'
# GEMINI.md
@CLAUDE.md
## Gemini-Specific Overrides
You are Gemini CLI with unique capabilities:
- Large context window (exceeds typical LLM limits)
- Interactive PTY shell
- Checkpointing with rollback
- Policy engine
Prioritize tasks that leverage these strengths.
EOF
# 3. Initialize sync state
mkdir -p .claude/temp
echo "{\"claude_hash\": \"$(md5sum CLAUDE.md | cut -d' ' -f1)\", \"last_sync\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" > .claude/temp/sync-state.json
echo "GEMINI.md created with @import to CLAUDE.md"
# Check if sync needed
if [ "$(md5sum CLAUDE.md | cut -d' ' -f1)" != "$(cat .claude/temp/sync-state.json | jq -r '.claude_hash')" ]; then
echo "CLAUDE.md has changed. If using @import, no action needed."
echo "If using section-based sync, rebuild GEMINI.md sections."
# Update sync state
echo "{\"claude_hash\": \"$(md5sum CLAUDE.md | cut -d' ' -f1)\", \"last_sync\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" > .claude/temp/sync-state.json
fi
gemini-workspace-bridge - Overall workspace architecturegemini-context-bridge - Legacy context sharing/sync-context - Trigger manual sync checkQuery: "How do I set up GEMINI.md to use CLAUDE.md?" Expected Behavior:
Query: "How do I check if my memory files are out of sync?" Expected Behavior:
Query: "My GEMINI.md @import isn't working" Expected Behavior: