Extract the per-machine concurrency lock from sync.sh into a sourceable
lib (.claude/scripts/sync-lock.sh) plus a `run <cmd>` wrapper that locks
the current repo (same lock-dir basename, so it mutually excludes with
sync.sh in the ClaudeTools repo and self-scopes in any project repo).
sync.sh now sources it (behavior identical — verified by review). /scc
routes its commit+push through the locked, rebase-safe sync.sh (and drops
the bare YYYY-MM-DD-session.md filename for the per-session-unique one).
/checkpoint now stages+commits atomically under the repo lock so a
concurrent session in a shared worktree can't be swept in. Closes the
remaining commit paths that bypassed the lock shipped in 6b0ce9a.
84 lines
4.1 KiB
Markdown
84 lines
4.1 KiB
Markdown
---
|
|
description: Create detailed git commit with comprehensive commit message
|
|
---
|
|
|
|
Please create a comprehensive git checkpoint with the following steps:
|
|
|
|
## Part 1: Git Checkpoint
|
|
|
|
1. **Initialize Git if needed**: Run `git init` if git has not been instantiated for the project yet.
|
|
|
|
2. **Analyze all changes**:
|
|
|
|
- Run `git status` to see all tracked and untracked files
|
|
- Run `git diff` to see detailed changes in tracked files
|
|
- Run `git log -5 --oneline` to understand the commit message style of this repository
|
|
|
|
3. **Decide what will be staged** (do NOT stage yet):
|
|
|
|
- Identify all tracked changes (modified/deleted) and untracked (new) files via `git status`.
|
|
- Staging is done **atomically with the commit, under the repo lock, in step 5** — do not run a separate `git add` here. This prevents a concurrent session in a shared worktree (e.g. ClaudeTools) from having its dirty files swept into this checkpoint.
|
|
|
|
4. **Draft commit message body via Ollama** (documentation engine):
|
|
|
|
```bash
|
|
# Resolve Ollama
|
|
if curl -s -m 2 http://localhost:11434/api/tags >/dev/null 2>&1; then OLLAMA="http://localhost:11434"
|
|
elif curl -s -m 3 http://100.92.127.64:11434/api/tags >/dev/null 2>&1; then OLLAMA="http://100.92.127.64:11434"
|
|
else OLLAMA=""; fi
|
|
|
|
# Capture diff summary for Ollama prompt
|
|
{ git diff --stat HEAD; echo "---"; git diff HEAD | head -200; } \
|
|
> "C:/Users/guru/AppData/Local/Temp/checkpoint_diff.txt"
|
|
|
|
# Ollama drafts the body; fallback to Claude if unavailable
|
|
if [ -n "$OLLAMA" ]; then
|
|
BODY=$(py -c "
|
|
import urllib.request, json
|
|
diff = open('C:/Users/guru/AppData/Local/Temp/checkpoint_diff.txt', encoding='utf-8').read()
|
|
prompt = 'Write a git commit message BODY only (not the summary line). Imperative mood. What changed and why. No filler. Under 150 words.\n\nDIFF:\n' + diff
|
|
body = json.dumps({'model':'qwen3:14b','messages':[{'role':'user','content':prompt}],'stream':False,'think':False}).encode()
|
|
res = json.loads(urllib.request.urlopen(urllib.request.Request('$OLLAMA/api/chat', body), timeout=60).read())
|
|
print(res['message']['content'])
|
|
")
|
|
fi
|
|
```
|
|
|
|
- **Summary line** (first line): Claude writes — 50-72 chars, imperative mood, from `git diff --stat`
|
|
- **Body**: Ollama draft (Claude reviews); Claude writes directly if Ollama unavailable
|
|
- **Footer**: `Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>`
|
|
|
|
5. **Execute the commit (locked)**: Write the final message (summary line + body + footer) to a temp file, then stage + commit **atomically under the repo's commit lock** so concurrent sessions can't interleave or get swept in:
|
|
|
|
```bash
|
|
# MSG = path to the composed commit-message file; LOCK = the shared lock wrapper
|
|
LOCK="${CLAUDETOOLS_ROOT:-/d/claudetools}/.claude/scripts/sync-lock.sh"
|
|
bash "$LOCK" run bash -c 'git add -A && git commit -F "$1"' _ "$MSG"
|
|
```
|
|
- The lock is scoped to the **current repo** (`git rev-parse --show-toplevel`/.git), so this serializes correctly whether the checkpoint is in ClaudeTools (shares the same lock as `/sync` and `/scc`) or in a project repo (its own lock). The wrapper errors out (exit 2) if you're not in a git repo.
|
|
- If it **exits 75**, another commit/sync holds the lock — wait briefly and retry, or report "checkpoint deferred".
|
|
- This is a **local commit only** (no push), matching checkpoint's purpose.
|
|
- `$CLAUDETOOLS_ROOT` should be set per-machine; the `/d/claudetools` fallback is for this box only — on Mac/Linux it resolves from the env var.
|
|
|
|
## Part 2: Verify Git Checkpoint
|
|
|
|
6. **Verify commit**:
|
|
- Confirm git commit succeeded by running `git log -1`
|
|
- Report commit status to user
|
|
|
|
## Benefits of Git Checkpoint
|
|
|
|
**Git Checkpoint provides:**
|
|
- Code versioning
|
|
- Change history
|
|
- Rollback capability
|
|
- Complete project memory over time
|
|
- Collaboration support through detailed commit messages
|
|
|
|
## IMPORTANT
|
|
|
|
- Do NOT skip any files - include everything
|
|
- Make the commit message descriptive enough that someone reviewing the git log can understand what was accomplished
|
|
- Follow the project's existing commit message conventions (check git log first)
|
|
- Include the Claude Code co-author attribution in the commit message
|