xiaohongshu
xiaohongshu
ai-partner-chat
基于用户画像和向量化笔记提供个性化对话。当用户需要个性化交流、上下文感知的回应,或希望 AI 记住并引用其之前的想法和笔记时使用。
Full skill instructions
Provide personalized, context-aware conversations by integrating user persona, AI persona, and vectorized personal notes. This skill enables AI to remember and reference the user's previous thoughts, preferences, and knowledge base, creating a more coherent and personalized interaction experience.
Before first use, complete these steps in order:
Create directory structure
mkdir -p config notes vector_db scripts
Set up Python environment
python3 -m venv venv
./venv/bin/pip install -r .claude/skills/ai-partner-chat/scripts/requirements.txt
Note: First run will download embedding model (~4.3GB)
Generate persona templates
Copy from .claude/skills/ai-partner-chat/assets/ to config/:
user-persona-template.md → config/user-persona.mdai-persona-template.md → config/ai-persona.mdUser adds notes
Place markdown notes in notes/ directory (any format/structure)
Initialize vector database (see section 1.2 below)
Now proceed to Core Workflow →
Before using this skill for the first time, complete the following setup:
Create two Markdown files to define interaction parameters:
User Persona (user-persona.md):
assets/user-persona-template.mdAI Persona (ai-persona.md):
assets/ai-persona-template.mdThis skill uses AI Agent approach for intelligent note chunking:
When you initialize the vector database, Claude Code will:
<project_root>/notes/ directorychunk_schema.Chunk format<project_root>/vector_db/Key advantages:
Chunk Format Requirement:
All chunks must conform to this schema (see scripts/chunk_schema.py):
{
'content': 'chunk text content',
'metadata': {
'filename': 'note.md', # Required
'filepath': '/path/to/file', # Required
'chunk_id': 0, # Required
'chunk_type': 'date_entry', # Required
'date': '2025-11-07', # Optional
'title': 'Section title', # Optional
}
}
Location: Create <project_root>/scripts/chunk_and_index.py
Required structure:
# Import provided utilities
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent / ".claude/skills/ai-partner-chat/scripts"))
from chunk_schema import Chunk, validate_chunk
from vector_indexer import VectorIndexer
def chunk_note_file(filepath: str) -> List[Chunk]:
"""
Analyze THIS file's format and generate appropriate chunks.
Each chunk must conform to chunk_schema.Chunk format:
{
'content': 'text',
'metadata': {
'filename': 'file.md',
'filepath': '/path/to/file',
'chunk_id': 0,
'chunk_type': 'your_label'
}
}
"""
# TODO: Analyze actual file format (NOT template-based)
# TODO: Generate chunks based on analysis
# TODO: Validate each chunk with validate_chunk()
pass
def main():
# Initialize vector database
indexer = VectorIndexer(db_path="./vector_db")
indexer.initialize_db()
# Process all note files
all_chunks = []
for note_file in Path("./notes").glob("**/*"):
if note_file.is_file():
chunks = chunk_note_file(str(note_file))
all_chunks.extend(chunks)
# Index chunks
indexer.index_chunks(all_chunks)
if __name__ == "__main__":
main()
Execute: ./venv/bin/python scripts/chunk_and_index.py
Key points:
chunk_note_file() function logic should be dynamically created based on analyzing actual file contentchunk_schema.ChunkFor each user query, follow this process:
Read both persona files to understand:
Query the vector database to find the top 5 most semantically similar notes:
from scripts.vector_utils import get_relevant_notes
# Query for relevant context
relevant_notes = get_relevant_notes(
query=user_query,
db_path="./vector_db",
top_k=5
)
Or use the command-line tool:
python scripts/query_notes.py "user query text" --top-k 5
Combine the following elements to inform the response:
Synthesize a response that:
When Referencing Notes:
Example Response Pattern:
[Acknowledge user's query in preferred communication style]
[Incorporate relevant note context naturally if applicable]
"I remember you mentioned [insight from note] - this connects well with..."
[Provide main response following AI persona guidelines]
[Optional: Ask follow-up question based on user's learning style]
When the user creates new notes, add them to the vector database:
python scripts/add_note.py /path/to/new_note.md
Personas can be updated anytime by editing the Markdown files. Changes take effect in the next conversation.
To completely rebuild the vector database:
python scripts/init_vector_db.py /path/to/notes --db-path ./vector_db
This will delete the existing database and re-index all notes.
User data is stored in project root, not inside the skill directory:
<project_root>/
├── notes/ # User's markdown notes
├── vector_db/ # ChromaDB vector database
├── venv/ # Python dependencies
├── config/
│ ├── user-persona.md # User persona definition
│ └── ai-persona.md # AI persona definition
└── .claude/skills/ai-partner-chat/ # Skill code (can be deleted/reinstalled)
├── SKILL.md
└── scripts/
├── chunk_schema.py # Chunk format specification
├── vector_indexer.py # Core indexing utilities
└── vector_utils.py # Query utilities
Design principles:
Philosophy: Instead of pre-written chunking strategies, Claude Code analyzes each note and generates optimal chunking code on the fly.
How it works:
chunk_schema.Chunk formatvector_indexer.pyBenefits:
<project_root>/vector_db/)chunk_schema.py: Defines required chunk format specificationvector_indexer.py: Core utilities for embedding generation and ChromaDB indexingvector_utils.py: Query utilities for retrieving relevant chunksrequirements.txt: Python dependencies (chromadb, sentence-transformers)Note: No pre-written chunking scripts. Chunking is done by Claude Code dynamically.
<project_root>/
├── notes/ # User's notes (managed by user)
│ └── *.md
├── vector_db/ # Vector database (auto-generated)
├── venv/ # Python environment
├── config/ # User configuration
│ ├── user-persona.md
│ └── ai-persona.md
└── .claude/skills/ai-partner-chat/
├── SKILL.md # This file
├── scripts/
│ ├── chunk_schema.py # Chunk format spec
│ ├── vector_indexer.py # Indexing utilities
│ ├── vector_utils.py # Query utilities
│ └── requirements.txt # Dependencies
└── assets/
├── user-persona-template.md
└── ai-persona-template.md
<project_root>/notes/ anytimeDatabase Connection Errors:
<project_root>/vector_db/ directory exists and is writablePoor Retrieval Quality:
top_k value for more contextChunking Issues:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience