From copilot-cli-toolkit
Validates and completes Claude Code session logs before commit by auto-populating git SHA, lint results, memory updates, then runs validation. Use when finishing sessions.
npx claudepluginhub rjmurillo/ai-agentsThis skill uses the workspace's default tool permissions.
Validate and complete session logs before commit. Complements `session-init` (which handles creation).
Validates and completes session logs before commit by auto-populating git commit SHA, lint results, memory updates, then runs validation. Use when finishing sessions or before committing.
Creates protocol-compliant JSON session logs with git-derived state, auto-incremented numbers, and validation enforcement. Use when starting new sessions to ensure CI compliance.
Verifies session work against agreed plan, creates issues for gaps and carryover tasks, runs quality gates, commits changes, mirrors to GitHub, and generates summary. Triggered by /close.
Share bugs, ideas, or general feedback.
Validate and complete session logs before commit. Complements session-init (which handles creation).
python3 .claude/skills/session-end/scripts/complete_session_log.py
The script will:
python3 .claude/skills/session-end/scripts/complete_session_log.py --dry-run
| Phrase | Action |
|---|---|
/session-end | Complete and validate current session log |
complete session | Natural language activation |
finalize session | Alternative trigger |
validate session end | Alternative trigger |
finish session | Alternative trigger |
| Input | Output | Quality Gate |
|---|---|---|
| Session log (auto-detected or specified) | Validated, completed session log | Exit code 0 from validation |
REQUIRED before closing any session. The Stop hook at .claude/hooks/Stop/invoke_session_validator.py enforces this — sessions will not close until protocolCompliance.sessionEnd MUST items are complete. If you attempt to close without running session-end, the hook will force continuation.
Specifically:
Use session-init instead when:
Use session-log-fixer instead when:
User Request: /session-end
|
v
+---------------------------------------------+
| Phase 1: FIND SESSION LOG |
| - Auto-detect most recent .json in |
| .agents/sessions/ |
| - Prefer today's sessions |
| - Accept explicit -SessionPath |
+---------------------------------------------+
|
v
+---------------------------------------------+
| Phase 2: GATHER EVIDENCE |
| - Ending commit SHA (git rev-parse) |
| - HANDOFF.md modification check |
| - Serena memory update check |
| - Run markdown lint on changed files |
| - Check for uncommitted changes |
+---------------------------------------------+
|
v
+---------------------------------------------+
| Phase 3: UPDATE SESSION LOG |
| - Auto-populate evidence fields |
| - Mark completed items |
| - Evaluate checklist completeness |
| - Write updated JSON |
+---------------------------------------------+
|
v
+---------------------------------------------+
| Phase 4: VALIDATE |
| - Run validate_session_json.py |
| - Update validationPassed field |
| - Report pass/fail with details |
+---------------------------------------------+
|
v
Completed Session Log (or actionable errors)
| Field | Source | Level |
|---|---|---|
endingCommit | git rev-parse --short HEAD | Top-level |
handoffNotUpdated | Check git diff for HANDOFF.md | MUST NOT |
serenaMemoryUpdated | Check .serena/memories/ changes | MUST |
markdownLintRun | Run markdownlint on changed .md files | MUST |
changesCommitted | Check git status for uncommitted changes | MUST |
checklistComplete | Evaluate all MUST items | MUST |
validationPassed | Run validate_session_json.py | MUST |
Before running this skill, ensure you have:
# Auto-detect and complete
python3 .claude/skills/session-end/scripts/complete_session_log.py
# Or specify session explicitly
python3 .claude/skills/session-end/scripts/complete_session_log.py --session-path ".agents/sessions/2026-02-07-session-05.json"
# Preview only
python3 .claude/skills/session-end/scripts/complete_session_log.py --dry-run
If validation fails, the output shows exactly what is missing:
[TODO] Serena memory not updated - update .serena/memories/ before completing
[TODO] Uncommitted changes exist - commit before completing
Fix the issues and re-run the skill.
After the skill reports PASS, commit the updated session log:
git add .agents/sessions/*.json
git commit -m "docs: complete session log"
Before reporting success, the script verifies:
| Avoid | Why | Instead |
|---|---|---|
| Skipping session-end before commit | Validation only catches errors at CI time | Run /session-end before every commit |
| Manually editing session end fields | Error-prone, misses evidence | Let the script auto-populate |
| Running without committing first | changesCommitted will fail | Commit work, then run session-end |
| Ignoring TODO warnings | Session will fail CI validation | Address each TODO before final commit |
Success:
Auto-detected session log: .agents/sessions/2026-02-07-session-05.json
=== Session End Completion ===
File: .agents/sessions/2026-02-07-session-05.json
Running markdown lint...
--- Changes ---
Set endingCommit: abc1234
Confirmed HANDOFF.md not modified
Confirmed Serena memory updated
Markdown lint: 3 files linted
All changes committed
Updated: .agents/sessions/2026-02-07-session-05.json
Running validation...
=== Session Validation ===
File: .agents/sessions/2026-02-07-session-05.json
[PASS] Session log is valid
[PASS] Session log completed and validated
Failure:
=== Session End Completion ===
--- Changes ---
Set endingCommit: abc1234
Confirmed HANDOFF.md not modified
[TODO] Serena memory not updated - update .serena/memories/ before completing
Markdown lint: 2 files linted
[TODO] Uncommitted changes exist - commit before completing
[FAIL] Session validation failed. Fix issues above and re-run.
| Script | Purpose | Exit Codes |
|---|---|---|
| complete_session_log.py | Auto-populate and validate session end | 0=success, 1=validation failed |
| Parameter | Type | Required | Description |
|---|---|---|---|
--session-path | string | No | Path to session log. Auto-detects if omitted. |
--dry-run | flag | No | Preview changes without writing to file. |
| Skill | Relationship |
|---|---|
| session-init | Creates session logs (this skill completes them) |
| session-log-fixer | Reactive fix after CI failure (this skill prevents the need) |
| session | Session management utilities |
This skill follows the shift-left principle: catch errors at development time, not CI time.
| Aspect | Without Skill | With Skill |
|---|---|---|
| When errors found | CI pipeline (minutes later) | Before commit (immediately) |
| Feedback loop | Push, wait, read logs, fix, push again | Run script, see errors, fix, done |
| Cost | CI minutes + developer context switch | Seconds of local validation |
| Reliability | Same script as CI | Same script as CI |