pre-session-end
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePre-Session-End Skill
Pre-Session-End Skill
Run this skill before ending a Claude Code session to capture learnings and propagate useful settings.
在结束Claude Code会话前运行此Skill,以捕获经验并同步有用的设置。
When to Activate
激活时机
- User says: "done", "wrapping up", "ending session", "goodbye", "that's all", "I'm finished"
- Significant work completed without explicit continuation request
- User explicitly invokes
/pre-session-end
- 用户说出:"done", "wrapping up", "ending session", "goodbye", "that's all", "I'm finished"
- 已完成大量工作但用户未明确要求继续
- 用户显式调用
/pre-session-end
Workflow
工作流程
Step 0: English Correction
步骤0:英文修正
Before proceeding with other steps, provide a corrected or more natural version of the user's original prompt from this session.
Format:
undefined在执行其他步骤前,提供本次会话中用户原始提示的修正版或更自然的表述。
格式:
undefinedEnglish Correction
English Correction
Original: [user's original prompt]
Corrected: [corrected/more natural version]
[If changes are significant, add brief explanation of what was changed and why]
- Only include this section if corrections are needed
- Focus on grammar, word choice, and natural phrasing
- Keep explanations conciseOriginal: [用户的原始提示]
Corrected: [修正后的更自然表述]
[若改动较大,简要说明修改内容及原因]
- 仅在需要修正时包含此部分
- 重点关注语法、用词和自然表达
- 解释需简洁Step 1: Analyze Session for Learnable Patterns
步骤1:分析会话中的可学习模式
Review the chat history and identify:
回顾聊天历史,识别:
Skill Candidates
技能候选
Patterns that could become reusable skills:
- Repeated workflows (e.g., "always run tests before commit")
- Problem-solving approaches that worked well
- Domain-specific knowledge applied multiple times
- Code patterns or architectures used consistently
可转化为可复用技能的模式:
- 重复的工作流(例如:"提交前始终运行测试")
- 行之有效的问题解决方法
- 多次应用的领域特定知识
- 持续使用的代码模式或架构
Command Candidates
命令候选
Operations that could become slash commands:
- Multi-step sequences performed repeatedly
- Common parameter combinations for tools
- Project-specific workflows
可转化为斜杠命令的操作:
- 重复执行的多步骤序列
- 工具的常见参数组合
- 项目特定的工作流
Agent Candidates
Agent候选
Specialized task patterns that could become agents:
- Complex multi-tool operations
- Tasks requiring specific expertise or context
- Recurring analysis or review patterns
可转化为Agent的专业化任务模式:
- 复杂的多工具操作
- 需要特定专业知识或上下文的任务
- 重复的分析或审查模式
Step 2: Present Extracted Learnings
步骤2:展示提取的经验
For each candidate, present to user:
**Potential Skill: [name]**
- Pattern observed: [description]
- Would save: [how it helps]
- Proposed location: ~/.claude/skills/learned/[name].md
Create this skill? [Yes/No/Edit]针对每个候选,向用户展示:
**Potential Skill: [名称]**
- 观察到的模式:[描述]
- 优势:[它能带来的帮助]
- 建议存储位置:~/.claude/skills/learned/[name].md
是否创建此技能?[是/否/编辑]Step 3: Propagate Project Permissions to Global
步骤3:将项目权限同步到全局设置
- Read project settings:
.claude/settings.local.json - Read global settings:
~/.claude/settings.json - Identify permissions in project but not in global
For each permission found only in project settings:
Categorize the permission:
- Generic tool permissions: ,
Bash(git:*),Bash(npm:*)→ likely useful globallyBash(docker:*) - Domain-specific web: → ask user if generally useful
WebFetch(domain:docs.example.com) - Project-specific paths: Contains project directory paths → skip (not portable)
- MCP server permissions: → ask user (may be project-specific)
mcp__*
Present each selectively:
**Permission found in project settings:**
`Bash(helm template:*)`
This permission allows: Running helm template commands
Currently: Project-only
Recommendation: [Useful globally / Project-specific]
Propagate to global settings? [Yes/No]- 读取项目设置:
.claude/settings.local.json - 读取全局设置:
~/.claude/settings.json - 识别项目中存在但全局中没有的权限
针对每个仅在项目设置中存在的权限:
对权限进行分类:
- 通用工具权限:,
Bash(git:*),Bash(npm:*)→ 可能对全局有用Bash(docker:*) - 领域特定网络权限:→ 询问用户是否普遍有用
WebFetch(domain:docs.example.com) - 项目特定路径权限:包含项目目录路径 → 跳过(不具备可移植性)
- MCP服务器权限:→ 询问用户(可能是项目特定的)
mcp__*
选择性展示每个权限:
**在项目设置中发现的权限:**
`Bash(helm template:*)`
此权限允许:运行helm template命令
当前状态:仅项目可用
建议:[全局可用 / 项目特定]
是否同步到全局设置?[是/否]Step 4: Apply Approved Changes
步骤4:应用已批准的更改
- For approved skills: Create files in
~/.claude/skills/learned/ - For approved permissions: Update
~/.claude/settings.json - Report what was applied
- 对于已批准的技能:在目录下创建文件
~/.claude/skills/learned/ - 对于已批准的权限:更新
~/.claude/settings.json - 报告已应用的更改
Step 5: Session Summary
步骤5:会话总结
Provide a brief summary:
undefined提供简要总结:
undefinedSession Wrap-Up Complete
会话收尾完成
Learnings captured:
- Created skill: skill-name
- Created command: command-name
- Skipped: pattern-name (user declined)
Permissions propagated:
- Bash(helm:*) → global
- WebFetch(domain:internal.corp) → kept project-only
Ready to end session.
undefined已捕获的经验:
- 创建技能:skill-name
- 创建命令:command-name
- 跳过:pattern-name(用户拒绝)
已同步的权限:
- Bash(helm:*) → 全局
- WebFetch(domain:internal.corp) → 保留为仅项目可用
准备结束会话。
undefinedImportant Notes
重要注意事项
- Never auto-apply: Always get user confirmation for each change
- Preserve existing: Don't overwrite existing skills/settings without explicit approval
- Be selective: Only propose truly useful patterns, not every repeated action
- Explain value: For each proposal, explain why it's worth saving
- 切勿自动应用:每项更改都必须获得用户确认
- 保留现有内容:未经明确批准,不得覆盖现有技能/设置
- 有所选择:仅建议真正有用的模式,而非所有重复操作
- 说明价值:针对每个建议,解释为何值得保存