mcpField
S
session-share

session-share

github.com/asheshgoplaniAgent 工作流1.2k51 次安装3 天前更新
代码仓库

关于 session-share

Session Share 技能将 Claude Code 会话导出为可移植文件,并导入 agent-deck 供其他开发者继续使用。默认会隐藏敏感信息;文件仅在主动分享时才离开本地。

主要功能

  1. 01导出当前或指定会话
  2. 02选择是否包含思考内容
  3. 03隐藏密钥、令牌和路径
  4. 04将会话导入 agent-deck
  5. 05指定项目与启动方式

适用场景

  1. 01将 Claude Code 会话交接给同事
  2. 02在另一个项目中继续共享会话

安装

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

$npx skills add https://github.com/asheshgoplani/agent-deck --skill session-share

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

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

evals/
evals.json
RUNNER.md
scripts/
.gitkeep
export.sh
import.sh
utils.sh
tests/
test_export_895_regression.sh

详细介绍

会话共享

通过便携式文件导出/导入,在开发者之间共享 Claude Code 会话。

版本: 1.0 | 隐私: 除非你选择共享,否则文件绝不会上传到云端

脚本路径解析(重要)

此技能的 scripts/ 子目录中包含辅助脚本。当 Claude Code 加载此技能时,会显示类似这样的一行:

Base directory for this skill: /path/to/.../skills/session-share

必须使用该基础目录路径来解析所有脚本引用。 将其存储为 SKILL_DIR:

# Set SKILL_DIR to the base directory shown when this skill was loaded
SKILL_DIR="/path/shown/in/base-directory-line"

# Then run scripts as:
$SKILL_DIR/scripts/export.sh
$SKILL_DIR/scripts/import.sh ~/Downloads/session-file.json

快速开始

# Export current session
$SKILL_DIR/scripts/export.sh
# Output: ~/session-shares/session-2024-01-20-my-feature.json

# Share the file via Slack, email, AirDrop, etc.

# Other developer imports
$SKILL_DIR/scripts/import.sh ~/Downloads/session-2024-01-20-my-feature.json
# Session appears in agent-deck, ready to continue

命令

导出会话

将当前 Claude 会话导出为便携式文件:

$SKILL_DIR/scripts/export.sh [options]

选项:

选项说明
--session <id>导出指定会话(默认:当前会话)
--output <path>自定义输出路径
--include-thinking包含 Claude 的思考块
--no-sanitize不对敏感数据进行脱敏

示例:

# Export current session
$SKILL_DIR/scripts/export.sh

# Export to specific location
$SKILL_DIR/scripts/export.sh --output /tmp/handoff.json

# Export specific session with thinking blocks
$SKILL_DIR/scripts/export.sh --session abc123 --include-thinking

导出的内容:

  • 所有对话消息(用户和助手)
  • 工具调用及结果
  • 跟踪的文件修改
  • 会话元数据

默认会被脱敏的内容:

  • API 密钥和令牌
  • 绝对路径(转换为相对路径)
  • 思考块(Claude 的内部推理)
导入会话

导入共享的会话文件并创建 agent-deck 会话:

$SKILL_DIR/scripts/import.sh <file-path> [options]

选项:

选项说明
--title <name>覆盖会话标题
--project <path>导入到指定项目
--no-start不自动启动会话

示例:

# Import and start
$SKILL_DIR/scripts/import.sh ~/Downloads/session-feature.json

# Import with custom title
$SKILL_DIR/scripts/import.sh session.json --title "Feature Work from Alice"

# Import without starting
$SKILL_DIR/scripts/import.sh session.json --no-start

工作流:共享会话

开发者 A(导出方)
  1. 在 agent-deck 会话中开发某项功能
  2. 需要将工作移交给开发者 B
  3. 运行:$SKILL_DIR/scripts/export.sh
  4. 获取文件:~/session-shares/session-2024-01-20-feature.json
  5. 通过 Slack 私信、电子邮件或 AirDrop 将文件发送给开发者 B
开发者 B(导入方)
  1. 收到会话文件
  2. 运行:$SKILL_DIR/scripts/import.sh ~/Downloads/session-2024-01-20-feature.json
  3. 会话以“Imported: feature”的名称显示在 agent-deck 中
  4. 启动会话 — Claude 将获得开发者 A 工作的完整上下文
  5. 从开发者 A 停下的地方继续

导出文件格式

{
  "version": "1.0",
  "exported_at": "2024-01-20T15:30:00Z",
  "exported_by": "alice",
  "session": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "title": "Feature Implementation",
    "original_project": "/Users/alice/my-project"
  },
  "context": {
    "summary": "Last few user messages for quick context",
    "modified_files": ["src/auth.ts", "src/middleware.ts"]
  },
  "messages": [ /* JSONL records as JSON array */ ],
  "stats": {
    "total_messages": 150,
    "user_messages": 45,
    "assistant_messages": 105
  }
}

安全与隐私

默认脱敏内容
数据类型脱敏方式
API 密钥替换为 [REDACTED]
令牌替换为 [REDACTED]
主目录路径转换为 ~
路径中的用户名转换为 $USER
思考块完全移除
最佳实践
  1. 共享前先检查 - 打开导出文件并检查是否包含敏感数据
  2. 直接传输 - 相比云链接,Slack 私信、电子邮件和 AirDrop 更私密
  3. 导入后删除 - 成功导入后删除文件
  4. 谨慎使用 --include-thinking - 思考块可能包含敏感推理

故障排除

问题解决方案
“Could not detect current Claude session”确保你处于有活跃 Claude 的 agent-deck 会话中
“Session file not found”会话可能尚未保存;请先发送一条消息
导入后显示的项目不正确使用 --project /correct/path 指定目标位置
文件过大使用默认设置(会剥除思考块)

技术详情

会话存储

Claude 将会话存储在:~/.claude/projects/<encoded-path>/<session-id>.jsonl

路径编码:/Users/alice/project 会变为 -Users-alice-project

导入工作原理
  1. 读取导出 JSON 文件
  2. 创建目录:~/.claude/projects/<encoded-current-project>/
  3. 将消息写入 JSONL:<session-id>.jsonl
  4. 创建指向此路径的 agent-deck 会话
  5. 设置 claude-session-id,以便重启时使用 --resume
依赖项
  • jq - JSON 处理(安装:brew install jq)
  • agent-deck - 会话管理
  • claude - Claude Code CLI

向后兼容性

此技能的脚本仅使用 agent-deck add/基本会话创建和 claude --resume,这些功能在 v1.16.11 之前就已稳定——此技能的任何部分都不依赖近期添加的 CLI 功能(会话发送投递结果、上下文检查器、健康状态、远程死信)。只要 deck 版本支持创建指向现有 .jsonl 记录文件的 Claude 会话,此技能就能原样运行。

评论

支持 Markdown