Goal
Automatically extract and structure the essence of the current conversation, and save it to a specified folder in Obsidian.
Essence Judgment Criteria
Content to Extract
- Problems and Solutions: Specific problem descriptions and solutions
- Code Snippets: Reusable code, configurations, commands
- Decision Rationale: Reasons for technology choices, trade-offs
- New Knowledge: Information not previously known, API pitfalls, best practices
- Error Lessons: Pitfalls encountered, why they failed
Content to Filter Out
- Pure conversational transitions: "OK", "Got it", "Let's try"
- Intermediate debugging output: temporary printed logs
- Failed attempts that ultimately proved useless
Workflow
Step 1: Analyze the Conversation
- Read all the content of the current conversation
- Identify the core theme of the conversation
- Extract the essence content (according to the above criteria)
Step 2: Generate the Note Structure
## 背景
<简述对话背景和问题>
## 核心内容
<主要讨论内容>
## 解决方案
<如果有,列出解决方案>
\`\`\`language
<代码片段>
\`\`\`
## 关键要点
- 要点1
- 要点2
## 相关
- 项目路径: <当前工作目录>
- 相关技术/工具
Important:
- Do not use YAML frontmatter(do not include metadata such as tags, date)
- Do not use an H1 title(the filename is the topic, and the content starts directly from H2)
- Keep the content concise and get straight to the point
Step 3: Save to Obsidian
Use the Bash tool to write directly to the file, no MCP connection required:
# 构建完整文件路径(假设 Obsidian vault 路径由用户自行配置)
OBSDIR="<OBSIDIAN_VAULT>/AI对话精华"
FILENAME="<对话主题标题>.md"
FULLPATH="$OBSDIR/$FILENAME"
# 使用 heredoc 语法写入内容
cat > "$FULLPATH" << 'EOF'
## 背景
<简述对话背景和问题>
## 核心内容
<主要讨论内容>
## 解决方案
<如果有,列出解决方案>
\`\`\`language
<代码片段>
\`\`\`
## 关键要点
- 要点1
- 要点2
## 相关
- 项目路径: <当前工作目录>
- 相关技术/工具
EOF
Note:
- Use
<< 'EOF'(single quotes) to ensure that special characters in the content are not escaped - Wrap the file path in double quotes to handle spaces
- Complete the save in one go, no second confirmation required
Precautions
-
Filename Generation Rules:
- Extract the core theme from the conversation as the filename
- Keep it concise, use Chinese or English
- Avoid special characters (such as
/\:*?<>|) - If the theme is not obvious, use the date + sequence number format (such as
2024-02-01-01.md)
-
Content Quality:
- Ensure the note is independently readable (has context)
- Code snippets must have language identifiers
- Do not omit key information
-
Obsidian Path Configuration:
- Default path:
<OBSIDIAN_VAULT>/AI对话精华/ - If your vault is in another location, modify the
OBSDIRvariable - Ensure the directory exists; if it does not, create it first:
mkdir -p "$OBSDIR"
- Default path:
-
Windows Path Handling:
- Use forward slashes
/or double backslashes\\ - Avoid using single backslashes
\(they will be escaped)
- Use forward slashes
Tool Usage
- Bash Tool: Execute shell commands to write directly to files
- cat command + heredoc: Create files containing multi-line content
- mkdir command: Create directory (if it does not exist)