Memory Sync to Vector DB

VerifiedCaution

Sync all files in .claude/memory/ to pgvector database, with incremental updates and embedding generation.

Sby Skills Guide Bot
Data & AIIntermediate
107/27/2026
Claude Code
#memory-sync#pgvector#database#embedding

Recommended for

Our review

Synchronizes the `.claude/memory/` folder with a pgvector database, updating embeddings accordingly.

Strengths

  • Incremental update (only changed files are processed)
  • Removes orphaned embeddings
  • Uses content hashing to detect modifications

Limitations

  • Requires a configured pgvector database and OpenAI API key
  • Does not support other vector databases
  • Embeddings are fully regenerated for modified files
When to use it

When you manually edit memory files and need the vector database to reflect those changes.

When not to use it

If you do not use pgvector or require bidirectional sync.

Security analysis

Caution
Quality score90/100

The skill instructs the agent to run a bash command that executes a Node.js script for database synchronization. While the described purpose is legitimate and no overtly destructive actions are visible, the script is not included for review, and its execution could potentially read or write sensitive data. Using bash without declared tools introduces power that warrants caution.

Findings
  • Executes a script via bash, which has access to sensitive environment variables (database credentials, OpenAI API key) and can perform arbitrary operations on the host.
  • The skill does not declare any allowed tools, but implicitly requires bash execution.

Examples

Trigger memory sync
/memory-sync

description: "/memory-sync - DB 동기화" keywords: [memory, sync, 동기화, pgvector, DB] argument-hint: "옵션 없이 실행"

/memory-sync - DB 동기화

.claude/memory/ 폴더의 모든 파일을 pgvector DB에 동기화합니다.

사용법

/memory-sync

동기화 로직

  1. memory/ 폴더 스캔 → 파일 목록 + content_hash 계산
  2. DB에서 기존 file_path, content_hash 조회
  3. 비교:
    • 새 파일 → INSERT (임베딩 생성 포함)
    • hash 변경 → DELETE all chunks + re-INSERT
    • 파일 삭제됨 → DELETE
  4. 변경된 파일만 임베딩 생성

환경변수 필요

.env.ai 파일에 다음 환경변수가 필요합니다:

# Vector DB
AI_VECTOR_DB_HOST=localhost
AI_VECTOR_DB_PORT=5432
AI_VECTOR_DB_USER=postgres
AI_VECTOR_DB_PASSWORD=yourpassword
AI_VECTOR_DB_NAME=ai_memory

# OpenAI API
OPENAI_API_KEY=sk-...

Instructions for Claude

사용자가 /memory-sync를 실행하면:

  1. Bash 도구로 sync-db.mjs 스크립트를 실행합니다:
node .claude/hooks/memory/sync-db.mjs
  1. 동기화 결과를 사용자에게 보고합니다:
    • 추가된 파일 수
    • 수정된 파일 수
    • 삭제된 파일 수

사용 시나리오

  • memory 파일을 직접 편집한 후 DB 업데이트
  • 초기 세팅 후 최초 데이터 로드
  • DB와 파일 시스템 동기화 확인
Related skills