mcpField
C
Context Preserver

Context Preserver

github.com/daffy0208生产力38136 次安装44 周前更新
代码仓库

关于 Context Preserver

Context Preserver 是帮助开发者在暂停或切换任务时保留工作进度的技能。它描述了如何保存项目与思路记录、Git 历史及后续步骤,便于之后继续工作。

主要功能

  1. 01定期捕获工作上下文
  2. 02记录项目与思路状态
  3. 03通过单条命令恢复工作
  4. 04保存会话时创建 WIP 提交
  5. 05导出上下文并查看历史

适用场景

  1. 01休息后恢复编码工作
  2. 02切换项目时保留后续步骤
  3. 03结对协作时分享当前工作上下文
  4. 04查看先前工作会话的记录

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/daffy0208/ai-dev-standards --skill context-preserver

安装后在 Claude Code 中输入/context-preserver确认已加载。

附带文件README.mdmanifest.yaml

详细介绍

上下文保留

永不忘记做到哪里。5 分钟内恢复工作。告别“我刚才做到哪儿了?”

核心原则

ADHD 大脑切换上下文的成本很高,工作记忆也有限。每次被打断,都要花 15-30 分钟“重新进入状态”。解决方案:自动捕获并恢复思维状态,让你能在 5 分钟内恢复工作。

**关键见解:**保存上下文这一行为本身具有疗愈作用——它传递出“我可以安心停下来”的信号。


上下文问题

问题 1:上下文切换成本高

**问题:**休息后,要花 15-30 分钟回忆自己刚才在做什么
**结果:**效率降低、感到沮丧、逃避休息

问题 2:工作记忆受限

**问题:**无法在脑中保持复杂的状态
**结果:**不断重读代码,忘记下一步要做什么

问题 3:对被打断感到焦虑

**问题:**害怕忘记进度,因此不敢进行必要的休息
**结果:**倦怠、健康问题、质量下降

问题 4:“我刚才做到哪儿了?”综合征

**问题:**回来工作时,完全不记得自己刚才在做什么
**结果:**忙乱无序、从头开始、浪费时间


阶段 1:自动捕获上下文

保存内容(每 15 分钟自动保存)

文件上下文:

  • 当前文件路径
  • 行号和函数
  • 相关文件(导入项、依赖项)
  • Git 分支

思维状态:

  • 刚才在想什么
  • 刚完成了什么
  • 接下来要做什么
  • 阻碍或疑问

环境:

  • 开发服务器状态
  • 已打开的终端
  • 数据库状态
  • 已加载的 API 密钥

时间上下文:

  • 开始时间
  • 已工作时长
  • 计划停止时间
自动保存
触发器 1:每 15 分钟(后台)
[15:30] Auto-save triggered

Context saved:

- File: src/components/login.tsx:42
- Function: handleSubmit()
- Status: Adding API call
- Next: Error handling for 401
- Time working: 45 min

✅ Saved to .adhd/context.json
✅ Micro-commit created (WIP)
触发器 2:休息前(手动命令)
# You run: ./save-context.sh --break lunch

Context saved for lunch break:
- Current task: Implementing password reset
- Progress: 70% complete
- File: src/auth/reset.ts:67
- Next step: Test email delivery
- Resume command ready: ./resume.sh

✅ Safe to take break!
触发器 3:Claude 会话结束时(自动)
[Session ending]

Preserving your context:

- Saved current task
- Created WIP commit
- Noted next 3 steps
- Logged session progress

Resume anytime: Just start new Claude session
Context will load automatically
触发器 4:被打断时(自动检测)
[No activity detected for 10 min]

Looks like you got interrupted!
Auto-saved context:

- Last active: 10 min ago
- Working on: Dashboard layout
- File: src/pages/dashboard.tsx:125
- Next: Add user stats widget

When you return: Context ready to resume

阶段 2:上下文结构

.adhd/context.json 文件
{
  "timestamp": "2025-10-22T15:30:00Z",
  "session": {
    "started": "2025-10-22T14:00:00Z",
    "duration_minutes": 90,
    "breaks_taken": 1,
    "focus_sessions": 3
  },
  "files": {
    "current": {
      "path": "src/components/login.tsx",
      "line": 42,
      "column": 12,
      "function": "handleSubmit",
      "content_preview": "async function handleSubmit(e: FormEvent) {"
    },
    "related": ["src/api/auth.ts", "src/types/user.ts"]
  },
  "mental_state": {
    "doing": "Adding API call to /auth/login endpoint",
    "just_finished": "Added email validation",
    "next_steps": [
      "Add fetch call to /auth/login",
      "Handle 401/500 errors",
      "Add loading state to button"
    ],
    "blockers": ["Need to check API error format"],
    "notes": "Using fetch (not axios) per team standard"
  },
  "environment": {
    "branch": "feature/auth-flow",
    "uncommitted_changes": true,
    "dev_server_running": true,
    "last_command": "npm run dev"
  },
  "progress": {
    "current_task": "Build authentication flow",
    "phase": "Phase 2: API Integration",
    "percent_complete": 60,
    "estimated_remaining": "45 minutes"
  }
}

阶段 3:自动恢复上下文

快速恢复(< 5 分钟)
一条命令恢复
# You run: ./resume.sh

╔══════════════════════════════════════╗
║  Resuming Work Session              ║
║  Last saved: 12:15 PM (1 hour ago) ║
╚══════════════════════════════════════╝

📂 Restoring context...

✅ Opened: src/components/login.tsx
✅ Cursor positioned: Line 42
✅ Dev server started
✅ Git branch: feature/auth-flow

💭 You were:
  - Adding API call to /auth/login
  - Just finished: Email validation
  - Next: Handle 401/500 errors

📊 Progress: 60% complete
⏱️ Estimated remaining: 45 minutes

🎯 Next micro-task: Add fetch call (15 min)

[Opens file at exact line in VS Code]
[Starts dev server]
[Shows mental state notes]

✅ Ready to code! Resume time: 4 minutes
Claude 自动恢复

启动新的 Claude 会话时:

You: [start new session]

Claude: Welcome back! I see you were working on authentication flow.

Let me catch you up:

📍 Last Location:
File: src/components/login.tsx:42
Function: handleSubmit()

💭 Mental State (from 1 hour ago):

- You were adding API call to /auth/login
- Email validation is done ✅
- Next: Handle 401/500 errors

📊 Progress: 60% complete (Phase 2/3)

🎯 Quick options:
A) Resume where you left off (add fetch call)
B) See full context (detailed notes)
C) Start something new

What would you like to do?

阶段 4:捕获思维状态的技巧

捕获“刚才在想什么?”
3 个问题法(自动提示)

每隔 30 分钟,Claude 会询问:

[Quick context check - 1 minute]

To help you resume later:

1. What are you working on right now?

   > Adding password reset functionality

2. What's the next small step?

   > Test email delivery locally

3. Any blockers or questions?
   > Need to configure SendGrid API key

✅ Saved! This will help Future You.
意识流笔记
## Mental State Notes (Auto-saved)

15:00 - Started password reset feature
15:15 - Generated reset token, stored in DB
15:30 - Building email template now
15:35 - Wondering if I should use SendGrid or Postmark
15:40 - Going with SendGrid (already have account)
15:45 - Configured API key, testing send...
[Break]

Resume thoughts:

- Was about to test email delivery
- SendGrid configured, key in .env
- Next: Trigger reset email from form
面包屑线索
## Breadcrumb Trail (Auto-generated)

14:00 ✅ Created reset-password.tsx
14:15 ✅ Added form with email input
14:30 ✅ Connected to /api/reset-password
14:45 ✅ Generated reset token
15:00 ✅ Stored token in database
15:15 🔄 Building email template ← YOU ARE HERE
15:30 ⬜ Test email delivery
15:45 ⬜ Add reset confirmation page

You're making great progress! 🎉

阶段 5:上下文感知工作流

休息前检查清单(自动触发)
[You haven't saved context in 45 min]

⏸️ Taking a break soon?

Quick save checklist:

- [ ] Commit current work (WIP okay!)
- [ ] Write next step (one sentence)
- [ ] Note any blockers
- [ ] Close unneeded tabs (reduce clutter)

Takes 2 minutes, saves 20 minutes later!

[Save Context Now] [Remind Me in 15m] [I'm not taking a break]
每日结束仪式(下午 5 点自动提示)
[17:00] End of day approaching!

🌙 Let's wrap up for easy tomorrow start:

1. Current Progress:
   Built authentication flow
   Progress: 75% complete
   Status: Working well, needs testing

2. Tomorrow's First Task:
   → Test password reset flow (30 min)
   → File: src/auth/reset.ts
   → Should be quick!

3. Blockers for Tomorrow:
   None! Ready to go.

4. Wins Today:
   ✅ Completed login form
   ✅ Added validation
   ✅ Connected to API
   ✅ Fixed bug #234

5. Mental Dump:
   [Anything else to remember?]
   > Remember to check email error handling

✅ Context saved! Tomorrow You will thank you. 🙏

[Finish Day] [Keep Working]

阶段 6:Git 集成

自动创建微型提交

每次保存上下文都会创建一个 WIP 提交:

# Auto-runs every 15 min
git add .
git commit -m "WIP: $(cat .adhd/context.json | jq -r '.mental_state.doing') [15:30]"

# Example commits:
git commit -m "WIP: Adding API call to login endpoint [15:30]"
git commit -m "WIP: Testing password reset flow [15:45]"
git commit -m "PAUSE: About to add error handling [16:00]"
从 Git 历史恢复
# See what you were doing
git log -1 --pretty=%B

# Output:
WIP: Testing password reset flow [15:45]

# Context notes:
- File: src/auth/reset.ts:67
- Next: Add error toast for failed reset
- Blocker: None

阶段 7:处理中断

中断类型
类型 1:会议(已安排)
[14:45] Meeting in 15 minutes

Auto-save triggering:

- Current work committed
- Context snapshot created
- Resume script generated

After meeting: Run ./resume.sh
Estimated resume time: 5 minutes
类型 2:紧急错误(计划外)
You: "Urgent bug in production, need to switch"

Claude: No problem! Let me save your context first.

✅ Saved: Authentication flow work
✅ Stashed: Uncommitted changes
✅ Switched: To main branch

Work on the bug, I'll help you resume after.

Resume command: ./resume-auth-work.sh
类型 3:注意力涣散(ADHD 分心)
[You've been browsing docs for 20 min]

💭 Gentle reminder:

You were working on: Password reset form
Current file: src/auth/reset.tsx:45
Next step: Add email input field (5 min)

Research is good, but maybe time to apply?

[Resume Coding] [Continue Research] [Take Break]

阶段 8:高级上下文功能

上下文共享
# Share context with teammate
./export-context.sh

Generated: context-snapshot.md

Send this to teammate for pairing:
- What you're working on
- Current progress
- What you need help with
- Exact file locations
上下文历史记录
# View past contexts

./context-history.sh

Recent Work Sessions:

1. 2025-10-22 14:00 - Auth flow (90 min) ✅ Completed
2. 2025-10-22 10:30 - Dashboard UI (2 hours) 🔄 In progress
3. 2025-10-21 15:00 - Bug fix #234 (45 min) ✅ Completed

[Load Context] [Delete] [Archive]
智能上下文建议
[Starting new session]

Claude: I notice you often work on:

- Authentication (70% of time)
- Dashboard UI (20%)
- Bug fixes (10%)

Would you like to:
A) Resume auth flow (where you left off)
B) Continue dashboard work (60% complete)
C) Check open bugs
D) Start something new

Based on your patterns, auth flow is most likely.

阶段 9:上下文模式

模式 1:深度工作时段
[Session Start]
Auto-save every: 15 minutes
Break reminders: Every 60 minutes
Context snapshots: On demand

[Session End]
Final save includes:

- Total focus time
- Tasks completed
- Progress made
- Tomorrow's start point
模式 2:上下文切换型项目
Project A → Project B

Auto-stash Project A:

- Commit WIP
- Save context
- Close related tabs

Load Project B:

- Restore last context
- Open relevant files
- Show next task

Switch time: < 5 minutes
模式 3:结对编程
Before pairing:

- Export current context
- Share with partner
- They see exactly what you're doing

After pairing:

- Update context with decisions made
- Log next steps
- Easy solo resume

自动化脚本

设置(仅一次)
cd your-project
mkdir .adhd
cp ~/ai-dev-standards/TEMPLATES/adhd/scripts/* ./
chmod +x .adhd/*.sh

# Scripts installed:
# - save-context.sh (manual save)
# - resume.sh (quick resume)
# - context-history.sh (view history)
# - export-context.sh (share with team)
日常使用(全自动)
# Morning: One command start
./resume.sh

# During work: Auto-saves every 15 min
# (runs in background)

# Before break: Quick save
./save-context.sh --break lunch

# After break: One command resume
./resume.sh

# End of day: Auto-prompted at 5pm
# (saves automatically)

反模式

❌ 手动记录上下文

**不妥:**指望自己手动写笔记
**原因:**ADHD 大脑无法坚持这样做
**建议:**每 15 分钟自动保存

❌ 完美文档

**不妥:**撰写详细的状态报告
**原因:**浪费时间,而且无法持续维护
**建议:**快速记录意识流笔记

❌ 单一上下文文件

**不妥:**反复覆盖同一个上下文文件
**原因:**丢失历史记录,无法回溯
**建议:**按时间戳保存历史记录,以便浏览过去的上下文


成功指标

当你做到以下几点时,就说明你很好地运用了这个技能:

  • ✅ 恢复工作所需时间 < 5 分钟(之前需要 30 分钟)
  • ✅ 永远不用问“我做到哪儿了?”
  • ✅ 休息时不焦虑
  • ✅ 上下文自动保存(无需费心)
  • ✅ 轻松切换项目

相关技能

  • task-breakdown-specialist - 拆解后续步骤
  • focus-session-manager - 管理工作时段
  • adhd-workflow-architect - 设计自动化工作流

保存进度,消除焦虑,5 分钟内恢复工作。 💾

评论

支持 Markdown