Session 2 - Prompt to Command + Session Save
202604 | PM | 30 min
CLAUDE.md 之於 脈絡 | /指令 之於 效率 | /clear 之於 精力
~/.claude/CLAUDE.md個人偏好,跨專案通用
## 偏好
- 繁體中文
- 回覆不超過 300 字
- 整理類用表格
## 工具
- 常用 /kickoff /session
- push 前先跑 test
<repo>/CLAUDE.md這個 repo 的專屬脈絡
## 專案結構
- src/ 投影片原始碼
- theme/ 設計 tokens
- site/ build 產出(勿編輯)
## 慣例
- commit 用 conventional 格式
- 部署走 --public build
啟動時合併讀取。Local 可覆寫 Global。複雜專案的 repo 各自有 CLAUDE.md → 每個子系統的脈絡留在原地。
| 快捷鍵 / 指令 | 作用 |
|---|---|
Esc Esc | 撤銷,還原 Claude 的修改 |
Shift+Tab | 切換權限模式(default → plan → auto) |
Tab | 接受建議的下一步 |
Ctrl+R | 搜尋歷史對話 |
/btw | 側邊問題,不影響主對話 |
! + 指令 | 直接跑 terminal 指令 |
/context | 顯示當前 context 使用量(tokens / %)與分類明細 |
Ctrl+G | 開外部文字編輯器寫長 prompt |
Anthropic Prompt Generator | OpenAI Prompt Optimizer
Read @.claude/commands/kickoff.md,
rewrite it as a structured AGI instruction.
Preserve the original question-collection flow.
請 CC 打開顯示 kickoff.md 看結果。
Context window 會滿 | 換一台 Mac 就斷線 | /clear 之後回不去
需要一個 結構化存放對話脈絡 的方法。
| 指令 | 作用 |
|---|---|
/session save [topic] | 把當前對話寫成結構化 markdown |
/session list | 列出所有 session,按時間排 |
/session resume [topic|#] | 讀檔,回到中斷點 |
/session close [topic|#] | 工作完成,刪檔 |
每個 topic 一個檔,覆寫不累積。
close = 直接刪檔,重要內容先 /kb 入庫再收。
kb/session/
├── ch-monday-sync.md
├── openclaw-training-v3.md
└── s2-live-demo-session.md
每個 .md 包含:
├── frontmatter
├── Goal
├── Key Files
├── Progress
├── Findings
├── Handoff (stopped/next)
└── Notes
# 1. 把本堂課的對話存下來
/session save s2-live-demo
→ 寫出 kb/session/s2-live-demo-session.md
# 2. 確認有存到
/session list
→ 最上面那一行就是
# 3. 模擬中斷:開新 Claude Code chat
(Cmd+N)
# 4. 恢復
/session resume s2-live-demo
→ Claude 讀檔 + 報 handoff
# 5. 證明 context 真的回來了
繼續剛剛的 P9 內容
# 6. 工作中有新進展 → 覆寫
/session save
→ 更新 last_saved + progress
# 7. 完成了 → 收尾
/session close s2-live-demo
→ 檔案刪除
Skill 格式(.claude/skills/)屬於輕量版的 Skill,還未接入外部 API、MCP | 建立 ~/.claude/skills/session/SKILL.md,貼下面整段
---
name: session
description: "Save and restore working context across devices and conversations."
status: active
---
# /session: Cross-Session Context Bridge
Save working context so a future Claude Code conversation can resume seamlessly.
## Sub-commands
| Command | Action |
|---------|--------|
| `/session save [topic]` | Capture current context → write to `kb/session/` |
| `/session list` | Show all sessions with last-saved time |
| `/session resume [topic|#]` | Load a session |
| `/session close [topic|#]` | Delete session file |
## Procedure
### save
1. Determine topic from argument or infer. Ask if ambiguous.
2. Run `date '+%Y-%m-%d %H:%M'` and use as last_saved. Never guess time.
3. Extract: handoff (next + stopped at), goal, key files, progress, findings.
4. Write to `kb/session/{topic}-session.md` using template.
5. Print path + one-line summary.
### resume
1. Read `kb/session/{topic}-session.md`.
2. Skim each key file to verify it still exists.
3. Report (conclusion-first): Next → Stopped at → Resuming meta.
4. Continue from handoff.
### list
List `kb/session/*.md`, read frontmatter, sort desc, print with # column.
### close
Delete `kb/session/{topic}-session.md`.
## Session File Template
```markdown
---
tags: [session]
project: {name}
last_saved: {YYYY-MM-DD HH:MM}
---
# {Topic}: Session Context
## Handoff (Next / Stopped at) ← conclusion first
## Goal | ## Key Files | ## Progress
## Findings | ## Notes for Next Session
```
一條 rule(.claude/rules/interaction-style.md)
# /session resume s2-live-demo 的回報
Next: 部署到 ccc.y6huan9.site
Stopped at: P10 改完 build 完
Resuming: s2-live-demo · 2026-04-15 14:30
(完整 Goal / Findings / Notes 在檔案裡,要看時再看)
判斷放最前 → 接續工作 5 秒進入狀態 | 細節在檔案 → 要的時候才展開
Session 的生命週期管理
save 起始 → list 盤點 → resume 接續 → save 更新 → close 收尾session/ 資料夾,從今天的對話 /session save 開始
未來目標:session/ 放進 iCloud 同步的 Obsidian vault,跨裝置備份 + 閱讀