This repository has been archived on 2026-07-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ClaudeInit/.claude/rules/common/profile-recall.md
2026-04-24 16:42:22 +08:00

43 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 画像上下文注入
每次会话处理用户第一个任务前,执行以下操作:
### 用户画像注入
1. 读取 `~/.claude/profile/user-profile.md`(不存在则跳过)
2. 如文件存在且有实质内容(不仅是分类标题),将全部条目作为背景知识注入上下文
3. 这些信息帮助 Agent 理解用户的偏好、风格和决策倾向
4. 在后续回复中自然融入,不显式提及"根据画像"
### 项目画像注入
1. 读取 `.claude/profile/project-profile.md`(不存在则跳过)
2. 如文件存在且有实质内容,将全部条目作为背景知识注入上下文
3. 这些信息帮助 Agent 理解项目的定位、技术栈和设计约定
4. 在后续回复中自然融入,不显式提及"根据画像"
### 逐级上溯
当某条画像记录**语义模糊**(无法判断偏好的具体适用场景、与当前任务的关系不明确),执行以下查找:
```
1. 从精简版条目中提取锚点 IDHTML 注释中的 PF-xxx
2. 在对应的 Log 文件中 Grep 该 ID
- 用户画像 → ~/.claude/profile/user-profile-log.md
- 项目画像 → .claude/profile/project-profile-log.md
3. 找到 → 用 Read 工具读取该 ID 所在行号 ±15 行范围(精准读取,不读全文)
4. Log 中包含原始上下文、来源对话等完整信息,通常足以消除歧义
```
### 上溯原则
- **按需触发**:只有在精简版信息不足以支撑当前判断时才上溯
- **精准读取**:通过 Grep 定位行号 + Read 局部读取,禁止全文读取 Log
- **最小化**:一次上溯通常只涉及 1-2 条记录
### 注意
- 画像注入是低成本操作(预期 < 30 行),每次会话都执行
- 画像的写入和管理由 `profile-memory` Skill 负责,本 Rule 只负责读取和注入
- 不存在画像文件时不报错,直接跳过