session-share

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Session Share

会话共享

Share Claude Code sessions between developers through portable file export/import.
Version: 1.0 | Privacy: Files are never uploaded to cloud unless you choose to share them
通过可移植的文件导出/导入功能,在开发者之间共享Claude Code会话。
版本: 1.0 | 隐私说明: 除非你选择共享,否则文件绝不会上传至云端

Quick Start

快速开始

bash
undefined
bash
undefined

Export current session

导出当前会话

scripts/export.sh
scripts/export.sh

Output: ~/session-shares/session-2024-01-20-my-feature.json

输出: ~/session-shares/session-2024-01-20-my-feature.json

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

通过Slack、邮件、AirDrop等方式共享文件

Other developer imports

其他开发者导入会话

scripts/import.sh ~/Downloads/session-2024-01-20-my-feature.json
scripts/import.sh ~/Downloads/session-2024-01-20-my-feature.json

Session appears in agent-deck, ready to continue

会话将出现在agent-deck中,可直接继续工作

undefined
undefined

Commands

命令说明

Export Session

导出会话

Export the current Claude session to a portable file:
bash
scripts/export.sh [options]
Options:
OptionDescription
--session <id>
Export specific session (default: current)
--output <path>
Custom output path
--include-thinking
Include Claude's thinking blocks
--no-sanitize
Don't redact sensitive data
Examples:
bash
undefined
将当前Claude会话导出为可移植文件:
bash
scripts/export.sh [选项]
选项:
选项说明
--session <id>
导出指定会话(默认:当前会话)
--output <path>
自定义输出路径
--include-thinking
包含Claude的思考块
--no-sanitize
不对敏感数据进行脱敏
示例:
bash
undefined

Export current session

导出当前会话

scripts/export.sh
scripts/export.sh

Export to specific location

导出到指定位置

scripts/export.sh --output /tmp/handoff.json
scripts/export.sh --output /tmp/handoff.json

Export specific session with thinking blocks

导出指定会话并包含思考块

scripts/export.sh --session abc123 --include-thinking

**What gets exported:**
- All conversation messages (user and assistant)
- Tool calls and results
- File modifications tracked
- Session metadata

**What gets redacted (by default):**
- API keys and tokens
- Absolute paths (converted to relative)
- Thinking blocks (Claude's internal reasoning)
scripts/export.sh --session abc123 --include-thinking

**导出内容包括:**
- 所有对话消息(用户和助手)
- 工具调用及结果
- 跟踪到的文件修改记录
- 会话元数据

**默认脱敏内容包括:**
- API密钥和令牌
- 绝对路径(转换为相对路径)
- 思考块(Claude的内部推理过程)

Import Session

导入会话

Import a shared session file and create an agent-deck session:
bash
scripts/import.sh <file-path> [options]
Options:
OptionDescription
--title <name>
Override session title
--project <path>
Import to specific project
--no-start
Don't auto-start the session
Examples:
bash
undefined
导入共享的会话文件并创建agent-deck会话:
bash
scripts/import.sh <文件路径> [选项]
选项:
选项说明
--title <name>
覆盖会话标题
--project <path>
导入到指定项目
--no-start
不自动启动会话
示例:
bash
undefined

Import and start

导入并启动会话

scripts/import.sh ~/Downloads/session-feature.json
scripts/import.sh ~/Downloads/session-feature.json

Import with custom title

导入并自定义标题

scripts/import.sh session.json --title "Feature Work from Alice"
scripts/import.sh session.json --title "来自Alice的功能开发会话"

Import without starting

导入但不启动

scripts/import.sh session.json --no-start
undefined
scripts/import.sh session.json --no-start
undefined

Workflow: Sharing a Session

工作流程:共享会话

Developer A (Exporter)

开发者A(导出方)

  1. Working in agent-deck session on a feature
  2. Needs to hand off to Developer B
  3. Runs:
    scripts/export.sh
  4. Gets file:
    ~/session-shares/session-2024-01-20-feature.json
  5. Sends file to Developer B via Slack DM, email, or AirDrop
  1. 在agent-deck会话中进行功能开发
  2. 需要将工作交接给开发者B
  3. 运行命令:
    scripts/export.sh
  4. 生成文件:
    ~/session-shares/session-2024-01-20-feature.json
  5. 通过Slack私信、邮件或AirDrop将文件发送给开发者B

Developer B (Importer)

开发者B(导入方)

  1. Receives the session file
  2. Runs:
    scripts/import.sh ~/Downloads/session-2024-01-20-feature.json
  3. Session appears in agent-deck as "Imported: feature"
  4. Starts session - Claude has full context from Developer A's work
  5. Continues where Developer A left off
  1. 接收会话文件
  2. 运行命令:
    scripts/import.sh ~/Downloads/session-2024-01-20-feature.json
  3. 会话将以“已导入:feature”的名称出现在agent-deck中
  4. 启动会话 - Claude将拥有开发者A的完整工作上下文
  5. 从开发者A停止的位置继续工作

Export File Format

导出文件格式

json
{
  "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
  }
}
json
{
  "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
  }
}

Security & Privacy

安全与隐私

What's Redacted by Default

默认脱敏内容

Data TypeRedaction
API keysReplaced with
[REDACTED]
TokensReplaced with
[REDACTED]
Home pathsConverted to
~
Username in pathsConverted to
$USER
Thinking blocksRemoved entirely
数据类型脱敏方式
API密钥替换为
[REDACTED]
令牌替换为
[REDACTED]
主目录路径转换为
~
路径中的用户名转换为
$USER
思考块完全移除

Best Practices

最佳实践

  1. Review before sharing - Open the export file and scan for sensitive data
  2. Use direct transfer - Slack DM, email, AirDrop are more private than cloud links
  3. Delete after import - Remove the file once imported successfully
  4. Use
    --include-thinking
    sparingly
    - Thinking blocks may contain sensitive reasoning
  1. 共享前检查 - 打开导出文件并扫描敏感数据
  2. 使用直接传输 - Slack私信、邮件、AirDrop比云链接更私密
  3. 导入后删除 - 成功导入后删除文件
  4. 谨慎使用
    --include-thinking
    - 思考块可能包含敏感推理内容

Troubleshooting

故障排除

IssueSolution
"Could not detect current Claude session"Make sure you're in an agent-deck session with active Claude
"Session file not found"Session may not have been saved yet; send a message first
Import shows wrong projectUse
--project /correct/path
to specify destination
Large file sizeUse default settings (strips thinking blocks)
问题解决方案
"无法检测到当前Claude会话"确保你处于agent-deck的活跃Claude会话中
"会话文件未找到"会话可能尚未保存;先发送一条消息再尝试
导入后显示错误的项目使用
--project /correct/path
指定目标路径
文件过大使用默认设置(会移除思考块)

Technical Details

技术细节

Session Storage

会话存储

Claude stores sessions in:
~/.claude/projects/<encoded-path>/<session-id>.jsonl
Path encoding:
/Users/alice/project
becomes
-Users-alice-project
Claude将会话存储在:
~/.claude/projects/<encoded-path>/<session-id>.jsonl
路径编码规则:
/Users/alice/project
转换为
-Users-alice-project

How Import Works

导入原理

  1. Reads export JSON file
  2. Creates directory:
    ~/.claude/projects/<encoded-current-project>/
  3. Writes messages as JSONL:
    <session-id>.jsonl
  4. Creates agent-deck session pointing to this path
  5. Sets
    claude-session-id
    so restart uses
    --resume
  1. 读取导出的JSON文件
  2. 创建目录:
    ~/.claude/projects/<encoded-current-project>/
  3. 将消息写入JSONL文件:
    <session-id>.jsonl
  4. 创建指向该路径的agent-deck会话
  5. 设置
    claude-session-id
    ,以便重启时使用
    --resume
    参数

Dependencies

依赖项

  • jq
    - JSON processing (install:
    brew install jq
    )
  • agent-deck
    - Session management
  • claude
    - Claude Code CLI
  • jq
    - JSON处理工具(安装:
    brew install jq
  • agent-deck
    - 会话管理工具
  • claude
    - Claude Code命令行工具