feat: add exit-session skill
Runs the full /end-session workflow (session log, CONTEXT.md update, doc refresh, git commit + push) then terminates the Claude process via kill -TERM $PPID. Designed for automated shutdown scripts — no interactive prompts.
This commit is contained in:
64
skills/exit-session/SKILL.md
Normal file
64
skills/exit-session/SKILL.md
Normal file
@@ -0,0 +1,64 @@
|
||||
---
|
||||
name: exit-session
|
||||
description: >
|
||||
Run the full /end-session workflow (session log, CONTEXT.md update, doc refresh,
|
||||
git commit + push), then terminate this Claude process. Designed for automated
|
||||
shutdown scripts — no interactive prompts, exits unconditionally when done.
|
||||
allowed-tools: Read, Edit, Write, Grep, Glob, Bash(git log *), Bash(git diff *), Bash(git add *), Bash(git status *), Bash(git commit *), Bash(git push *), Bash(git stash *), Bash(date *), Bash(ls *), Bash(cat *), Bash(find *), Bash(rm *), Bash(mkdir *), Bash(sed *), Bash(python3 -m lib.cp_cli *), Bash(ssh-add *), Bash(kill *)
|
||||
---
|
||||
|
||||
# Exit Session Skill
|
||||
|
||||
**This skill is for automated shutdown. Run the complete end-of-session workflow,
|
||||
then unconditionally terminate this Claude process. No interactive prompts.**
|
||||
|
||||
## Pre-gathered context
|
||||
|
||||
### Session timestamp
|
||||
!`date +%Y%m%d-%H%M%S`
|
||||
|
||||
### SSH agent keys (for pre-flight before push)
|
||||
!`ssh-add -l 2>&1 | head -5`
|
||||
|
||||
---
|
||||
|
||||
## Step 1: Run the end-session workflow
|
||||
|
||||
Use the `Skill` tool to invoke the `end-session` skill. Wait for it to complete all
|
||||
phases (session log, state update, doc updates). Do **not** skip phases or ask for
|
||||
confirmation — run everything.
|
||||
|
||||
## Step 2: Commit and push
|
||||
|
||||
After end-session completes:
|
||||
|
||||
1. Run `git status --short` to see what changed.
|
||||
2. If there are staged or unstaged changes to tracked files:
|
||||
- `git add -u` (stage tracked modifications only — never `git add .`)
|
||||
- `git commit -m "end-session: wrap-up [automated exit]"`
|
||||
3. Verify SSH key is present (`ssh-add -l`). If the relevant key appears, run
|
||||
`git push`. If no key is loaded, **skip the push** and print:
|
||||
`PUSH SKIPPED: no SSH key loaded — push manually after restart.`
|
||||
|
||||
## Step 3: Terminate
|
||||
|
||||
Run the following Bash command to terminate this Claude process:
|
||||
|
||||
```bash
|
||||
kill -TERM $PPID
|
||||
```
|
||||
|
||||
Do not output anything after this command. The process will exit immediately.
|
||||
|
||||
## On any failure
|
||||
|
||||
If end-session fails (disk full, parse error, etc.) or the push fails:
|
||||
- Print a one-line error summary
|
||||
- **Still run `kill -TERM $PPID`** — the shutdown must complete
|
||||
|
||||
## Constraints
|
||||
|
||||
- No interactive prompts — this runs during machine shutdown
|
||||
- Never block on user input
|
||||
- Complete within ~90 seconds where possible
|
||||
- If git operations time out (>30s), skip them and proceed to Step 3
|
||||
Reference in New Issue
Block a user