claude-baton 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +115 -0
- package/bin/claude-baton.js +2 -0
- package/commands/memo-checkpoint.md +43 -0
- package/commands/memo-eod.md +42 -0
- package/commands/memo-resume.md +76 -0
- package/dist/cli.d.ts +22 -0
- package/dist/cli.js +392 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +251 -0
- package/dist/llm.d.ts +16 -0
- package/dist/llm.js +119 -0
- package/dist/store.d.ts +28 -0
- package/dist/store.js +249 -0
- package/dist/types.d.ts +24 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +10 -0
- package/package.json +60 -0
- package/prompts/auto_checkpoint.txt +30 -0
- package/prompts/daily_summary.txt +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 claude-baton contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# claude-baton
|
|
2
|
+
|
|
3
|
+
Never lose context between Claude Code sessions again.
|
|
4
|
+
|
|
5
|
+
claude-baton is an MCP server that gives Claude Code session continuity. It saves checkpoints of your session state, auto-saves before context compaction, and restores full context when you start a new session.
|
|
6
|
+
|
|
7
|
+
## Workflow
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
/memo-resume → work → /memo-checkpoint → /compact or /clear → repeat
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
1. **Resume** — start a session with `/memo-resume` to pick up where you left off
|
|
14
|
+
2. **Work** — do your thing
|
|
15
|
+
3. **Checkpoint** — run `/memo-checkpoint` before `/compact` or `/clear` (or let the auto-checkpoint handle `/compact` for you)
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g claude-baton
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
claude-baton setup
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This:
|
|
30
|
+
- Registers the MCP server in `~/.claude/settings.json`
|
|
31
|
+
- Registers the PreCompact hook for auto-checkpoint
|
|
32
|
+
- Initializes the SQLite database at `~/.claude-baton/store.db`
|
|
33
|
+
- Installs slash commands to `~/.claude/commands/`
|
|
34
|
+
|
|
35
|
+
## MCP Tools
|
|
36
|
+
|
|
37
|
+
| Tool | Description |
|
|
38
|
+
|------|-------------|
|
|
39
|
+
| `save_checkpoint` | Save session state (what was built, current state, next steps, git context) |
|
|
40
|
+
| `get_checkpoint` | Retrieve a checkpoint by ID, or the latest for the project |
|
|
41
|
+
| `list_checkpoints` | List all checkpoints for a date |
|
|
42
|
+
| `daily_summary` | Generate EOD summary from the day's checkpoints |
|
|
43
|
+
|
|
44
|
+
## Slash Commands
|
|
45
|
+
|
|
46
|
+
| Command | Description |
|
|
47
|
+
|---------|-------------|
|
|
48
|
+
| `/memo-checkpoint` | Save session state with git context — safe to `/compact` or `/clear` after |
|
|
49
|
+
| `/memo-resume` | Restore context from last checkpoint at session start |
|
|
50
|
+
| `/memo-eod` | End-of-day summary combining git activity with stored data |
|
|
51
|
+
|
|
52
|
+
## Auto-checkpoint
|
|
53
|
+
|
|
54
|
+
A PreCompact hook automatically saves a checkpoint before Claude Code compacts context. This means you never lose session state during long conversations — it happens transparently.
|
|
55
|
+
|
|
56
|
+
## How it works
|
|
57
|
+
|
|
58
|
+
1. **Checkpoint** — `/memo-checkpoint` (or the MCP tool) captures what you built, current state, next steps, decisions, blockers, and git context. Stored in a local SQLite database.
|
|
59
|
+
|
|
60
|
+
2. **Auto-checkpoint** — Before context compaction, the PreCompact hook reads the conversation transcript, sends it to `claude -p --model haiku` to extract session state, and saves a checkpoint automatically.
|
|
61
|
+
|
|
62
|
+
3. **Resume** — `/memo-resume` fetches the latest checkpoint, compares git state, shows what changed since the checkpoint, and presents a structured handover briefing with actionable next steps.
|
|
63
|
+
|
|
64
|
+
4. **EOD Summary** — `/memo-eod` generates a daily summary from all checkpoints, combining what was built, decisions made, and blockers across sessions.
|
|
65
|
+
|
|
66
|
+
## CLI Commands
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
claude-baton status # checkpoint counts, db size
|
|
70
|
+
claude-baton projects # list tracked projects
|
|
71
|
+
claude-baton export [--project] # export as JSON
|
|
72
|
+
claude-baton import <file> # import from JSON
|
|
73
|
+
claude-baton reset [--project] # clear data (with confirmation)
|
|
74
|
+
claude-baton uninstall # remove hooks, commands, MCP server, and database
|
|
75
|
+
claude-baton uninstall --keep-data # uninstall but preserve the database
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Uninstall
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Remove hooks, MCP server, slash commands, and database
|
|
82
|
+
claude-baton uninstall
|
|
83
|
+
|
|
84
|
+
# Remove the binary
|
|
85
|
+
npm uninstall -g claude-baton
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
To keep your data: `claude-baton uninstall --keep-data`
|
|
89
|
+
|
|
90
|
+
## Data model
|
|
91
|
+
|
|
92
|
+
All data lives in `~/.claude-baton/store.db`:
|
|
93
|
+
|
|
94
|
+
- **checkpoints** — session state snapshots (what was built, current state, next steps, decisions, blockers, git context)
|
|
95
|
+
- **daily_summaries** — LLM-generated EOD summaries
|
|
96
|
+
|
|
97
|
+
## Requirements
|
|
98
|
+
|
|
99
|
+
- Node.js >= 18
|
|
100
|
+
- Claude Code with a Claude subscription (for `claude -p` calls)
|
|
101
|
+
- No API keys needed
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
git clone https://github.com/bakabaka91/claude-baton.git
|
|
107
|
+
cd claude-baton
|
|
108
|
+
npm install
|
|
109
|
+
npm run build
|
|
110
|
+
npm test
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
MIT
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Save session state before context loss.
|
|
2
|
+
|
|
3
|
+
## Steps
|
|
4
|
+
|
|
5
|
+
1. Detect the project from the current working directory.
|
|
6
|
+
|
|
7
|
+
2. Capture git state by running these bash commands:
|
|
8
|
+
- `git branch --show-current`
|
|
9
|
+
- `git status --short`
|
|
10
|
+
- `git diff --name-only HEAD`
|
|
11
|
+
- `git log --since="2 hours ago" --format="%h %s"`
|
|
12
|
+
- `git log --oneline -10` (this becomes the git_snapshot)
|
|
13
|
+
|
|
14
|
+
3. Check if any plan documents exist (PLAN.md, docs/*.md specs, roadmaps). If one is being actively worked on, note the file path and the current phase/step (e.g. "docs/v2-plan.md Phase 2 Step 3").
|
|
15
|
+
|
|
16
|
+
4. Summarize the session state from the conversation context:
|
|
17
|
+
- **what_was_built**: what was accomplished this session
|
|
18
|
+
- **current_state**: where things stand now
|
|
19
|
+
- **next_steps**: what should happen next
|
|
20
|
+
- **decisions**: key choices made and WHY
|
|
21
|
+
- **blockers**: anything blocking progress
|
|
22
|
+
- **plan_reference**: file path and section of the active plan document (e.g. "docs/v2-plan.md Phase 2 Step 3"), or omit if no plan is active
|
|
23
|
+
|
|
24
|
+
5. Call the `save_checkpoint` MCP tool with all fields:
|
|
25
|
+
- what_was_built
|
|
26
|
+
- current_state
|
|
27
|
+
- next_steps
|
|
28
|
+
- decisions
|
|
29
|
+
- blockers
|
|
30
|
+
- plan_reference (from step 3, if applicable)
|
|
31
|
+
- branch (from step 2)
|
|
32
|
+
- uncommitted_files (array of lines from git status --short)
|
|
33
|
+
- git_snapshot (from git log --oneline -10)
|
|
34
|
+
|
|
35
|
+
6. Print structured confirmation:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
Checkpoint saved -- safe to /compact or /clear
|
|
39
|
+
Branch: [branch name]
|
|
40
|
+
State: [current_state summary]
|
|
41
|
+
Next: [next_steps]
|
|
42
|
+
Uncommitted: [count] files
|
|
43
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
End-of-day summary combining git activity with stored checkpoints.
|
|
2
|
+
|
|
3
|
+
## Steps
|
|
4
|
+
|
|
5
|
+
1. Detect the project from the current working directory.
|
|
6
|
+
|
|
7
|
+
2. Collect git activity for today by running:
|
|
8
|
+
- `git log --since="$(date '+%Y-%m-%d') 00:00:00" --until="$(date '+%Y-%m-%d') 23:59:59" --format="%h|||%s|||%ai|||%an" --all`
|
|
9
|
+
- Parse and group commits by conventional commit prefix (feat/fix/chore/refactor/test/docs).
|
|
10
|
+
|
|
11
|
+
3. Review changed files:
|
|
12
|
+
- `git diff --name-only HEAD~10 HEAD 2>/dev/null | head -30`
|
|
13
|
+
|
|
14
|
+
4. Call the `daily_summary` MCP tool (defaults to today).
|
|
15
|
+
This internally gathers checkpoints and sends them to Haiku for synthesis, then stores the result.
|
|
16
|
+
|
|
17
|
+
5. Merge git activity from step 2 with the daily_summary output.
|
|
18
|
+
|
|
19
|
+
6. Display formatted summary:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
## EOD Summary -- [Project Name] -- [DATE]
|
|
23
|
+
|
|
24
|
+
### What Was Built / Shipped
|
|
25
|
+
[Commits grouped by area + what_was_built from daily_summary]
|
|
26
|
+
|
|
27
|
+
### Decisions Made
|
|
28
|
+
[From daily_summary + checkpoint decisions]
|
|
29
|
+
|
|
30
|
+
### Blockers and Failures
|
|
31
|
+
[From daily_summary blockers]
|
|
32
|
+
|
|
33
|
+
### Open Questions / Tomorrow
|
|
34
|
+
[next_steps from daily_summary]
|
|
35
|
+
|
|
36
|
+
### Git Stats
|
|
37
|
+
- Commits today: [count]
|
|
38
|
+
- Files changed: [count]
|
|
39
|
+
- Feature areas: [list of commit prefixes]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
7. Confirm: "EOD saved for [Project Name] -- [DATE]. [N] commits today."
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Restore context from last checkpoint at session start.
|
|
2
|
+
|
|
3
|
+
## Steps
|
|
4
|
+
|
|
5
|
+
1. Detect the project from the current working directory.
|
|
6
|
+
|
|
7
|
+
2. Call the `list_checkpoints` MCP tool with today's date. If multiple checkpoints exist, show them and note which is latest.
|
|
8
|
+
|
|
9
|
+
3. Call the `get_checkpoint` MCP tool (latest by default, or by ID if the user specified one via $ARGUMENTS).
|
|
10
|
+
|
|
11
|
+
4. Capture current git state by running these bash commands:
|
|
12
|
+
- `git branch --show-current`
|
|
13
|
+
- `git status --short`
|
|
14
|
+
- `git log --oneline -10`
|
|
15
|
+
- `git diff --stat main...HEAD`
|
|
16
|
+
|
|
17
|
+
5. If the checkpoint has a `plan_reference` field (e.g. "docs/v2-plan.md Phase 2 Step 3"), read the referenced file and extract the relevant section. Parse the plan_reference to get the file path (everything before the section identifier like "Phase" or "Step") and the section name.
|
|
18
|
+
|
|
19
|
+
6. Diff intelligence -- compare checkpoint state to current state:
|
|
20
|
+
- If checkpoint has a `git_snapshot`, extract the top commit hash and run `git diff --stat <hash>..HEAD` to see what files changed since checkpoint
|
|
21
|
+
- Compare checkpoint `uncommitted_files` vs current `git status --short` -- note any files that were added, removed, or committed since checkpoint
|
|
22
|
+
- If `package.json` appears in changed files, run `git diff <hash>..HEAD -- package.json` to check for dependency changes
|
|
23
|
+
- Summarize as: "X files modified, Y new commits, Z dependency changes" (or "No changes since checkpoint" if clean)
|
|
24
|
+
|
|
25
|
+
7. Present the structured handover briefing:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
## Session Resume -- [Project Name] -- [DATE]
|
|
29
|
+
|
|
30
|
+
Resuming from checkpoint: [timestamp]
|
|
31
|
+
|
|
32
|
+
### Branch
|
|
33
|
+
[checkpoint branch] -- currently on [current branch]
|
|
34
|
+
[Flag if they differ]
|
|
35
|
+
|
|
36
|
+
### Where We Left Off
|
|
37
|
+
[current_state from checkpoint]
|
|
38
|
+
|
|
39
|
+
### What Was Built (Last Session)
|
|
40
|
+
[what_was_built from checkpoint]
|
|
41
|
+
|
|
42
|
+
### Decisions Made
|
|
43
|
+
[decisions from checkpoint -- or "None recorded"]
|
|
44
|
+
|
|
45
|
+
### Blockers
|
|
46
|
+
[blockers from checkpoint -- or "None"]
|
|
47
|
+
[If blockers exist, surface them prominently with a warning]
|
|
48
|
+
|
|
49
|
+
### Active Plan Context
|
|
50
|
+
[If plan_reference exists: show the reference, then the extracted section content from step 5]
|
|
51
|
+
[If no plan_reference: "No active plan"]
|
|
52
|
+
|
|
53
|
+
### Changes Since Checkpoint
|
|
54
|
+
[Diff intelligence summary from step 6]
|
|
55
|
+
[Files changed, new commits, dependency changes]
|
|
56
|
+
|
|
57
|
+
### Next Steps
|
|
58
|
+
Present as numbered action items:
|
|
59
|
+
1. [first action from next_steps]
|
|
60
|
+
2. [second action if applicable]
|
|
61
|
+
...
|
|
62
|
+
|
|
63
|
+
### Uncommitted Work
|
|
64
|
+
[checkpoint uncommitted_files vs current git status]
|
|
65
|
+
[Flag if they differ -- someone may have stashed or committed manually]
|
|
66
|
+
|
|
67
|
+
### Commits From Last Session
|
|
68
|
+
[git_snapshot from checkpoint -- these are the commits made during that session]
|
|
69
|
+
[If empty: "No commits were made in the last session"]
|
|
70
|
+
|
|
71
|
+
### Git Activity Since Checkpoint
|
|
72
|
+
[Any NEW commits since the checkpoint timestamp that were NOT in git_snapshot]
|
|
73
|
+
[If none: "No new commits since checkpoint"]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
8. End with: "Ready to continue. Want me to start with step 1, or are we doing something else?" (referring to the numbered action items above)
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare function handleAutoCheckpoint(): Promise<void>;
|
|
2
|
+
export declare function handleSetup(): Promise<void>;
|
|
3
|
+
export declare function installCommands(): {
|
|
4
|
+
installed: number;
|
|
5
|
+
skipped: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function handleUninstall(opts: {
|
|
8
|
+
keepData?: boolean;
|
|
9
|
+
force?: boolean;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
export declare function handleStatus(opts: {
|
|
12
|
+
project?: string;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
export declare function handleProjects(): Promise<void>;
|
|
15
|
+
export declare function handleExport(opts: {
|
|
16
|
+
project?: string;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
export declare function handleImport(file: string): Promise<void>;
|
|
19
|
+
export declare function handleReset(opts: {
|
|
20
|
+
project?: string;
|
|
21
|
+
force?: boolean;
|
|
22
|
+
}): Promise<void>;
|