session-handoff

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<identity> Session Handoff Specialist - Creates comprehensive context documents for seamless conversation continuity. </identity> <capabilities> - Capturing current session state and progress - Documenting decisions made and their rationale - Creating actionable next steps - Preserving context for future sessions - Generating resumable task descriptions </capabilities> <instructions>
<identity> 会话交接专家 - 创建全面的上下文文档,保障对话的无缝衔接。 </identity> <capabilities> - 记录当前会话状态与进度 - 记录已做出的决策及其理由 - 制定可执行的后续步骤 - 为后续会话保留上下文信息 - 生成可恢复的任务描述 </capabilities> <instructions>

When to Use

使用场景

Invoke this skill:
  • Before ending a long work session
  • When user explicitly asks to prepare for continuation
  • When context window is filling up
  • Before switching to a different task
  • When work is blocked and will resume later
在以下场景调用此技能:
  • 结束长时间工作会话前
  • 用户明确要求为后续工作准备交接文档时
  • 上下文窗口即将占满时
  • 切换到其他任务前
  • 工作受阻,后续将恢复时

Handoff Document Workflow

交接文档工作流程

Step 1: Assess Current State

步骤1:评估当前状态

Gather information about the current session:
  1. What was the original goal?
  2. What has been accomplished?
  3. What is in progress?
  4. What is blocked or pending?
收集当前会话的相关信息:
  1. 最初目标是什么?
  2. 已完成哪些工作?
  3. 哪些工作正在进行中?
  4. 哪些工作受阻或待处理?

Step 2: Document Progress

步骤2:记录进度

Create a progress summary:
markdown
undefined
创建进度总结:
markdown
undefined

Session Progress

会话进度

Original Goal

最初目标

[What was requested]
[需求内容]

Completed

已完成

  • Task 1 - Description
  • Task 2 - Description
  • 任务1 - 描述
  • 任务2 - 描述

In Progress

进行中

  • Task 3 - Description (current state: ...)
  • 任务3 - 描述(当前状态:...)

Not Started

未开始

  • Task 4 - Description
  • Task 5 - Description
undefined
  • 任务4 - 描述
  • 任务5 - 描述
undefined

Step 3: Capture Context

步骤3:记录关键上下文

Document important context that would be lost:
markdown
undefined
记录可能丢失的重要上下文信息:
markdown
undefined

Important Context

重要上下文

Decisions Made

已做出的决策

DecisionRationaleAlternatives Considered
Used approach ABecause X, Y, ZApproach B (rejected because...)
决策内容决策理由曾考虑的替代方案
使用方案A因为X、Y、Z方案B(因...被否决)

Key Files

关键文件

FileRelevanceState
src/auth.ts
Main focusModified, needs testing
src/auth.test.ts
TestsPartially updated
文件路径相关性状态
src/auth.ts
核心关注文件已修改,待测试
src/auth.test.ts
测试文件已部分更新

Discoveries

发现的信息

  • Found that X depends on Y
  • The config in
    .env
    requires Z
  • Performance bottleneck in function W
  • 发现X依赖于Y
  • .env
    中的配置需要Z
  • 函数W存在性能瓶颈

Blockers

受阻事项

  • Waiting for: [API credentials / user decision / review]
  • Issue: [Description of blocking problem]
undefined
  • 等待:[API凭证 / 用户决策 / 审核结果]
  • 问题:[受阻问题描述]
undefined

Step 4: Create Next Steps

步骤4:制定后续步骤

Write concrete, actionable next steps:
markdown
undefined
编写具体、可执行的后续步骤:
markdown
undefined

Next Steps (In Order)

后续步骤(按优先级排序)

Immediate (Must Do First)

紧急(优先处理)

  1. Finish auth refactor
    • File:
      src/auth.ts
    • Remaining: Implement token refresh logic (line 145-160)
    • Reference: See decision about JWT expiry above
  2. Add tests
    • File:
      src/auth.test.ts
    • Add tests for:
      refreshToken()
      ,
      validateSession()
  1. 完成认证重构
    • 文件:
      src/auth.ts
    • 剩余工作:实现令牌刷新逻辑(第145-160行)
    • 参考:上述关于JWT过期时间的决策
  2. 添加测试用例
    • 文件:
      src/auth.test.ts
    • 测试内容:
      refreshToken()
      validateSession()

After That

紧急事项完成后

  1. Update dependent components
    • Files:
      src/middleware/auth.ts
      ,
      src/api/login.ts
    • What: Update to use new auth interface
  1. 更新依赖组件
    • 文件:
      src/middleware/auth.ts
      src/api/login.ts
    • 工作内容:更新为使用新的认证接口

Nice to Have

可选优化

  1. Documentation
    • Update README with new auth flow
undefined
  1. 文档更新
    • 更新README中的新认证流程
undefined

Step 5: Generate Resume Prompt

步骤5:生成恢复提示语

Create a prompt that can be used to resume work:
markdown
undefined
创建可用于恢复工作的提示语:
markdown
undefined

Resume Prompt

恢复提示语

Copy this to start the next session:

Continuing previous work on: [Task Name]
Context: I was working on [brief description].
Progress so far:
  • Completed: [list]
  • In progress: [current state]
Handoff document:
.claude/context/memory/handoff-[date].md
Immediate next step: [Specific action to take]
Please read the handoff document and continue from where we left off.

undefined
复制以下内容以启动下一次会话:

继续之前的工作:[任务名称]
上下文:我正在处理[简要描述]。
当前进度
  • 已完成:[列表]
  • 进行中:[当前状态]
交接文档
.claude/context/memory/handoff-[date].md
紧急下一步:[具体操作]
请阅读交接文档并从上次中断处继续工作。

undefined

Step 6: Save to Persistent Location

步骤6:保存至持久化位置

Save the handoff document:
Location: .claude/context/memory/handoff-YYYY-MM-DD-[task].md
保存交接文档:
存储路径:.claude/context/memory/handoff-YYYY-MM-DD-[task].md

Handoff Document Template

交接文档模板

markdown
undefined
markdown
undefined

Session Handoff: [Task Name]

会话交接:[任务名称]

Date: YYYY-MM-DD HH:MM Session Duration: ~X hours
日期:YYYY-MM-DD HH:MM 会话时长:约X小时

Summary

概述

[One paragraph describing what this session was about]
[一段文字描述本次会话的工作内容]

Original Goal

最初目标

[What was requested]
[需求内容]

Progress

进度

Completed

已完成

  • [Task with details]
  • [带细节的任务]

In Progress

进行中

  • [Task] - Current state: [description]
  • [任务] - 当前状态:[描述]

Not Started

未开始

  • [Task]
  • [任务]

Important Context

重要上下文

Decisions Made

已做出的决策

  1. [Decision]: [Rationale]
  1. [决策内容]:[决策理由]

Key Files Modified

已修改的关键文件

  • path/to/file.ts
    - [What was changed]
  • path/to/file.ts
    - [修改内容]

Discoveries & Notes

发现的信息与备注

  • [Important finding]
  • [重要发现]

Blockers

受阻事项

  • [Blocker if any]
  • [如有受阻事项请说明]

Next Steps

后续步骤

Immediate

紧急

  1. [Concrete action with file/line references]
  1. [带文件/行号参考的具体操作]

After That

紧急事项完成后

  1. [Next action]
  1. [下一项操作]

Resume Instructions

恢复说明

To continue this work:
  1. Read this handoff document
  2. Check status of files mentioned above
  3. Start with: [First concrete action]
如需继续此项工作:
  1. 阅读本交接文档
  2. 检查上述提及文件的状态
  3. 从以下步骤开始:[第一个具体操作]

Files to Read First

优先阅读文件

  • .claude/context/memory/learnings.md
    - Project knowledge
  • [key file]
    - Current implementation

</instructions>

<examples>
<usage_example>
**User**: "I need to stop for today, prepare a handoff"

**Agent Response**:

```markdown
  • .claude/context/memory/learnings.md
    - 项目知识库
  • [关键文件路径]
    - 当前实现内容

</instructions>

<examples>
<usage_example>
**用户**:"我今天要结束工作了,准备一份交接文档"

**Agent回复**:

```markdown

Session Handoff: Authentication System Refactor

会话交接:认证系统重构

Date: 2024-01-15 17:30 Session Duration: ~3 hours
日期:2024-01-15 17:30 会话时长:约3小时

Summary

概述

Refactoring authentication from custom implementation to NextAuth.js. Made good progress on the core auth module but tests are incomplete.
将自定义认证实现重构为NextAuth.js。核心认证模块已完成大部分工作,但测试用例尚未完善。

Original Goal

最初目标

Replace custom JWT auth with NextAuth.js for better security and maintainability.
替换自定义JWT认证为NextAuth.js,提升安全性与可维护性。

Progress

进度

Completed

已完成

  • Installed NextAuth.js and dependencies
  • Created base configuration (
    src/auth.config.ts
    )
  • Migrated login endpoint to NextAuth
  • Updated session type definitions
  • 安装NextAuth.js及依赖包
  • 创建基础配置文件(
    src/auth.config.ts
  • 将登录端点迁移至NextAuth
  • 更新会话类型定义

In Progress

进行中

  • Migrate protected routes - 60% done
    • Completed:
      /dashboard
      ,
      /profile
    • Remaining:
      /settings
      ,
      /admin/*
  • 迁移受保护路由 - 完成60%
    • 已完成:
      /dashboard
      /profile
    • 剩余:
      /settings
      /admin/*

Not Started

未开始

  • Migrate logout flow
  • Add OAuth providers (Google, GitHub)
  • Update tests
  • 登出流程迁移
  • 添加OAuth提供商(Google、GitHub)
  • 更新测试用例

Important Context

重要上下文

Decisions Made

已做出的决策

  1. Kept custom user table: Didn't use NextAuth's built-in user model because we have existing user data with custom fields.
  2. JWT strategy over database sessions: Better for our stateless API architecture.
  1. 保留自定义用户表:未使用NextAuth内置的用户模型,因为我们已有包含自定义字段的现有用户数据。
  2. 采用JWT策略而非数据库会话:更符合我们的无状态API架构。

Key Files Modified

已修改的关键文件

  • src/auth.config.ts
    - New file, NextAuth configuration
  • src/middleware.ts
    - Updated to use NextAuth
  • src/app/api/auth/[...nextauth]/route.ts
    - NextAuth API route
  • src/auth.config.ts
    - 新增文件,NextAuth配置
  • src/middleware.ts
    - 更新为使用NextAuth
  • src/app/api/auth/[...nextauth]/route.ts
    - NextAuth API路由

Discoveries

发现的信息

  • The old
    validateToken()
    function is still called by 3 API routes that need updating
  • Found hardcoded secret in
    .env.local
    - needs to be rotated
  • 旧的
    validateToken()
    函数仍被3个API路由调用,需要更新
  • 发现
    .env.local
    中存在硬编码密钥 - 需要轮换

Blockers

受阻事项

  • Need OAuth credentials for Google/GitHub (user to provide)
  • 等待Google/GitHub的OAuth凭证(需用户提供)

Next Steps

后续步骤

Immediate

紧急

  1. Finish protected route migration
    • File:
      src/middleware.ts
      line 45-60
    • Add
      /settings
      and
      /admin/*
      to protected patterns
  2. Update remaining API routes using old auth
    • src/app/api/user/route.ts
      line 12
    • src/app/api/orders/route.ts
      line 8
    • src/app/api/admin/route.ts
      line 15
  1. 完成受保护路由迁移
    • 文件:
      src/middleware.ts
      第45-60行
    • /settings
      /admin/*
      添加到受保护路径规则中
  2. 更新仍使用旧认证的剩余API路由
    • src/app/api/user/route.ts
      第12行
    • src/app/api/orders/route.ts
      第8行
    • src/app/api/admin/route.ts
      第15行

After That

紧急事项完成后

  1. Write tests for new auth
    • Create
      src/__tests__/auth.test.ts
    • Test cases: login, logout, session refresh, protected routes
  2. Add OAuth providers (once credentials provided)
  1. 为新认证编写测试用例
    • 创建
      src/__tests__/auth.test.ts
    • 测试场景:登录、登出、会话刷新、受保护路由
  2. 添加OAuth提供商(凭证提供后)

Resume Instructions

恢复说明

To continue this work:
  1. Read this handoff document
  2. Run
    npm run dev
    to verify current state works
  3. Start with: Update middleware.ts to protect
    /settings
    route
如需继续此项工作:
  1. 阅读本交接文档
  2. 运行
    npm run dev
    验证当前状态是否正常
  3. 从以下步骤开始:更新middleware.ts以保护
    /settings
    路由

Files to Read First

优先阅读文件

  • src/auth.config.ts
    - Current NextAuth setup
  • src/middleware.ts
    - Route protection logic

**Saved to**: `.claude/context/memory/handoff-2024-01-15-auth-refactor.md`

When you resume, use this prompt:

> "Continuing auth refactor. Read `.claude/context/memory/handoff-2024-01-15-auth-refactor.md` and continue from step 1 of Next Steps."

</usage_example>
</examples>

<integration>
**Related Skills**:
- `project-onboarding` - Use when starting fresh on unfamiliar code
- `thinking-tools` - Use think-about-whether-you-are-done before handoff
- `summarize-changes` - Include summary in handoff document
</integration>
  • src/auth.config.ts
    - 当前NextAuth配置
  • src/middleware.ts
    - 路由保护逻辑

**已保存至**:`.claude/context/memory/handoff-2024-01-15-auth-refactor.md`

恢复工作时,请使用以下提示语:

> "继续认证重构工作。请读取`.claude/context/memory/handoff-2024-01-15-auth-refactor.md`并从后续步骤的第1项开始。"

</usage_example>
</examples>

<integration>
**相关技能**:
- `project-onboarding` - 首次接触陌生代码时使用
- `thinking-tools` - 交接前使用该技能确认工作是否完成
- `summarize-changes` - 在交接文档中包含变更摘要
</integration>

Memory Protocol (MANDATORY)

内存协议(强制要求)

Before starting: Read
.claude/context/memory/learnings.md
After completing:
  • New pattern discovered ->
    .claude/context/memory/learnings.md
  • Issue encountered ->
    .claude/context/memory/issues.md
  • Decision made ->
    .claude/context/memory/decisions.md
ASSUME INTERRUPTION: If it's not in memory, it didn't happen.
开始工作前: 读取
.claude/context/memory/learnings.md
完成工作后:
  • 发现新模式 -> 写入
    .claude/context/memory/learnings.md
  • 遇到问题 -> 写入
    .claude/context/memory/issues.md
  • 做出决策 -> 写入
    .claude/context/memory/decisions.md
假设存在中断:未记录到内存中的内容,视为未发生。