Skip to content

Latest commit

 

History

History
254 lines (211 loc) · 6.28 KB

File metadata and controls

254 lines (211 loc) · 6.28 KB

Infrastructure Setup - AI Execution Guide

Context

You are setting up Git worktrees with DevContainers for the cognitive-memory-mcp project. This creates 5 parallel development environments (dev, product, docs, operations, marketing) with isolated Docker containers sharing a Neo4j database.

Repository: https://github.com/harrymower/cognitive-memory-mcp

Prerequisites Check

# Verify these are installed:
docker --version  # Docker Desktop must be running
git --version     # Must be 2.30+
code --version    # VS Code with Dev Containers extension
gh --version      # GitHub CLI

Setup Commands

1. Create Structure and Clone

# Set your root folder (adjust as needed)
ROOT_FOLDER="$HOME/CodingProjects"  # Mac/Linux
# ROOT_FOLDER="D:\CodingProjects"   # Windows

# Create directories
mkdir -p "$ROOT_FOLDER/cognitive-memory/cognitive-memory-main"
mkdir -p "$ROOT_FOLDER/cognitive-memory/cognitive-memory-worktrees"

# Clone repository
cd "$ROOT_FOLDER/cognitive-memory/cognitive-memory-main"
git clone https://github.com/harrymower/cognitive-memory-mcp .

2. Create Worktrees

# Fetch and checkout all branches
git fetch --all
for branch in dev product docs operations marketing; do
    git checkout $branch
done
git checkout main

# Create worktrees
for branch in dev product docs operations marketing; do
    git worktree add "../cognitive-memory-worktrees/$branch" "$branch"
done

# Verify
git worktree list

3. Create VS Code Configuration

# Create .vscode/settings.json in main repo
mkdir -p .vscode
cat > .vscode/settings.json << 'EOF'
{
  "actionButtons": {
    "defaultColor": "#00D4FF",
    "loadNpmCommands": false,
    "reloadButton": "♻️",
    "commands": [
      {
        "name": "🤖 Claude Regular",
        "color": "#00D4FF",
        "command": "claude-normal",
        "tooltip": "Start Claude Code with permission prompts"
      },
      {
        "name": "⚡ Claude DANGER",
        "color": "#FF4444",
        "command": "claude-danger",
        "tooltip": "⚠️ Start Claude Code WITHOUT permission prompts!"
      }
    ]
  }
}
EOF

4. Deploy Configurations to Worktrees

# Copy devcontainer and vscode configs to all worktrees
for worktree in dev product docs operations marketing; do
    cp -r .devcontainer "../cognitive-memory-worktrees/$worktree/"
    cp -r .vscode "../cognitive-memory-worktrees/$worktree/"
done

5. Create Environment File

# Create .env in main repo
cat > .env << 'EOF'
# Neo4j Configuration
NEO4J_URI=bolt://localhost:7688
NEO4J_USER=neo4j
NEO4J_PASSWORD=cognitive123

# API Keys
ANTHROPIC_API_KEY=your_key_here

# MCP Server Configuration
MCP_SERVER_PORT=3000
MCP_LOG_LEVEL=info
EOF

# Copy to all worktrees
for worktree in dev product docs operations marketing; do
    cp .env "../cognitive-memory-worktrees/$worktree/.env"
done

6. Setup Git Ignore for CLAUDE.md

# Add CLAUDE.md to .gitignore
echo "CLAUDE.md" >> .gitignore
git add .gitignore
git commit -m "Add CLAUDE.md to .gitignore for per-developer customization"

7. Start Neo4j (if needed)

# If project uses Neo4j
cd neo4j
docker-compose up -d
cd ..

8. Create Helper Scripts

create-scripts.sh (Run this to create all helper scripts)

cat > scripts/setup-all.sh << 'SCRIPT'
#!/bin/bash
ROOT_FOLDER=${1:-~/CodingProjects}
cd "$ROOT_FOLDER/cognitive-memory/cognitive-memory-main"

# Fetch and create worktrees
git fetch --all
for branch in dev product docs operations marketing; do
    git checkout $branch
    git worktree add "../cognitive-memory-worktrees/$branch" "$branch" 2>/dev/null || true
done
git checkout main

# Deploy configs
for worktree in dev product docs operations marketing; do
    cp -r .devcontainer "../cognitive-memory-worktrees/$worktree/"
    cp -r .vscode "../cognitive-memory-worktrees/$worktree/"
    [ -f .env ] && cp .env "../cognitive-memory-worktrees/$worktree/.env"
done

echo "Setup complete!"
git worktree list
SCRIPT

chmod +x scripts/setup-all.sh

Verification Steps

# 1. Check worktrees
git worktree list  # Should show 6 entries (main + 5 worktrees)

# 2. Check Docker
docker ps  # Docker should be running

# 3. Check Neo4j (if applicable)
docker ps | grep neo4j

# 4. Test DevContainer
cd "../cognitive-memory-worktrees/dev"
code .
# In VS Code: F1 -> "Dev Containers: Rebuild Container"

DevContainer Files to Verify

Ensure these files exist in .devcontainer/:

  • devcontainer.json
  • docker-compose.yml
  • Dockerfile
  • postCreateCommand.sh
  • smart-git-setup.sh
  • git-main.sh
  • start-claude-with-env.sh
  • start-claude-dangerous.sh

Important Notes

  1. CLAUDE.md: Create your own in each worktree (it's gitignored)
  2. API Keys: Update .env with your actual ANTHROPIC_API_KEY
  3. Claude Desktop Mount: Optionally add to docker-compose.yml:
    # Windows: Adjust username
    - C:\Users\YOUR_USERNAME\AppData\Roaming\Claude:/claude:ro
    # Mac
    - ~/Library/Application Support/Claude:/claude:ro

Quick Deploy Commands

Full Setup (One Command)

# Mac/Linux
curl -o setup.sh https://raw.githubusercontent.com/harrymower/cognitive-memory-mcp/main/scripts/setup-all.sh && bash setup.sh ~/CodingProjects

# Windows (PowerShell as Admin)
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/harrymower/cognitive-memory-mcp/main/scripts/setup-all.bat" -OutFile setup.bat; .\setup.bat D:\CodingProjects

Troubleshooting

Git Worktree Issues

# If "not a git repository" error:
bash .devcontainer/smart-git-setup.sh

# For fetch/pull/push:
git-main fetch
git-main pull
git-main push

Permission Issues

# Fix npm permissions
sudo chown -R $(whoami) ~/.npm

# Fix docker permissions
sudo usermod -aG docker $USER
newgrp docker

Container Issues

# Clean rebuild
docker-compose -f .devcontainer/docker-compose.yml down -v
docker-compose -f .devcontainer/docker-compose.yml build --no-cache

Success Criteria

  • All 5 worktrees created
  • DevContainers build without errors
  • Git operations work in containers
  • Action buttons appear in VS Code
  • Claude Code runs successfully

Next Steps

  1. Open each worktree in VS Code
  2. Start DevContainer (F1 -> Reopen in Container)
  3. Create your personal CLAUDE.md
  4. Test Claude Code with action buttons
  5. Begin development!