session-boundary
Skill94 starsChanged 7 months agoMITView on GitHub
Detect and handle session boundaries for multi-context autopilot workflows. Manage smooth transitions across context windows by: 1. Detecting when context is about to be compacted 2. Generating comprehensive handoff documents 3. Restoring state after context restoration 4. Tracking session metrics for workflow optimization Critical: Never keep state only in conversation memory. Always persist immediately. Added to state.yaml (schema v2.2.0): Located at: {workflow_dir}/sessions/handoff-{timestamp}.md bash /{workflow_type} continue
In this repository48 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .codex/Agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- analysis-phaseSkill
- anti-duplicationSkill
- audit-claude-mdSkill
- breaking-change-detectorSkill
- caching-strategySkill
- clarification-phaseSkill
- create-agent-skillsSkill
- create-hooksSkill
- create-meta-promptsSkill
- create-slash-commandsSkill
- create-subagentsSkill
- debug-phaseSkill
- dependency-conflict-resolverSkill
- design-tokensSkill
- domain-memorySkill
- dry-runSkill
- epic-meta-promptingSkill
- epic-scopingSkill
- epic-sprintsSkill
- epic-walkthroughSkill
- error-recoverySkill
- finalize-phaseSkill
- git-workflow-enforcerSkill
- hallucination-detectorSkill
- implementation-phaseSkill
- mockup-extractionSkill
- multi-agent-votingSkill
- optimization-phaseSkill
- parallel-execution-optimizerSkill
- planning-phaseSkill
- production-deployment-phaseSkill
- project-initialization-phaseSkill
- regression-test-generatorSkill
- roadmap-integrationSkill
- shadcn-integrationSkill
- specification-phaseSkill
- staging-deployment-phaseSkill
- staging-validation-phaseSkill
- task-breakdown-phaseSkill
- task-status-syncSkill
- theme-consistencySkill
- ultrathinkSkill
- workflow-detectionSkill
- worktree-contextSkill
- x-announcementSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
Critical: Never keep state only in conversation memory.
- Distinctive: line 176
Check for and display handoff documents
- Distinctive: line 177
Start a new session for tracking
- Very specific: line 201
Stop hook can return {"decision": "block"} to continue execution
- Distinctive: line 204
Only blocks on actual failures (CI, tests, deployment)
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Session Boundary Skill
Detect and handle session boundaries for multi-context autopilot workflows.
Purpose
Manage smooth transitions across context windows by:
- Detecting when context is about to be compacted
- Generating comprehensive handoff documents
- Restoring state after context restoration
- Tracking session metrics for workflow optimization
When to Invoke
- Automatically via SessionStart hook (startup, resume, compact triggers)
- Automatically via PreCompact hook (before context compaction)
- Automatically via Stop hook (session end)
- Manually via
/context nextor/context status - During
/feature continueor/epic continue
Core Concepts
Write-Through State Pattern
Critical: Never keep state only in conversation memory. Always persist immediately.
# Good: Write to state.yaml immediately
session:
id: "session-20251204-143000"
started_at: "2025-12-04T14:30:00Z"
phase_at_start: "implement"
decisions_made: ["Redis for token blacklist"]
# Bad: Keeping state only in conversation
# "I decided to use Redis..." (lost on compaction)Session Lifecycle
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ SessionStart │───▶│ Working │───▶│ Stop │
│ (restore) │ │ (track) │ │ (checkpoint) │
└──────────────┘ └──────────────┘ └──────────────┘
│
▼
┌──────────────┐
│ PreCompact │
│ (handoff) │
└──────────────┘
│
▼
┌──────────────┐
│ SessionStart │
│ (restore) │
└──────────────┘Hook Integration
| Hook | Trigger | Purpose |
| SessionStart | startup, resume, compact | Restore workflow context |
| PreCompact | auto, manual | Generate handoff before context loss |
| Stop | session end | Checkpoint current state |
Session Manager Commands
# Start new session (with optional autopilot)
bash .spec-flow/scripts/bash/session-manager.sh start --autopilot
# View current status
bash .spec-flow/scripts/bash/session-manager.sh status
# Record important decision
bash .spec-flow/scripts/bash/session-manager.sh decision "Using Redis for caching"
# Generate handoff manually
bash .spec-flow/scripts/bash/session-manager.sh handoff
# End session with summary
bash .spec-flow/scripts/bash/session-manager.sh end --summary "Completed auth implementation"
# Control autopilot mode
bash .spec-flow/scripts/bash/session-manager.sh autopilot on|off|status
# View session history
bash .spec-flow/scripts/bash/session-manager.sh historyState Schema (session block)
Added to state.yaml (schema v2.2.0):
session:
id: "session-20251204-143000"
started_at: "2025-12-04T14:30:00Z"
ended_at: null
last_activity: "2025-12-04T16:45:00Z"
phase_at_start: "implement"
tasks_at_start: 12
tasks_completed_this_session: 4
decisions_made:
- "Redis for token blacklist"
- "JWT expiry 15min"
handoffs:
- id: "handoff-20251204-163000"
at: "2025-12-04T16:30:00Z"
last_handoff_id: "handoff-20251204-163000"
last_handoff_at: "2025-12-04T16:30:00Z"
autopilot_enabled: false
duration_seconds: null
summary: nullHandoff Document Structure
Located at: {workflow_dir}/sessions/handoff-{timestamp}.md
# Session Handoff: {slug}
> Generated: {timestamp}
> Trigger: {context compaction | manual | session end}
> Phase: {current_phase}
> Status: {current_status}
## Quick Resume
```bash
/{workflow_type} continueCurrent State
| Metric | Value |
| Workflow Type | feature/epic |
| Slug | {slug} |
| Current Phase | {phase} |
| Phase Status | {status} |
| Tasks Progress | {completed} / {total} |
Next Task
{next_uncompleted_task}
Recent Decisions
{list_of_recent_decisions}
Key Artifacts
- State:
state.yaml - Tasks:
tasks.md - Notes:
NOTES.md...
Context for Next Session
- Read state.yaml for complete workflow state
- Check tasks.md for task completion status
- Review NOTES.md for recent decisions and blockers
- Use
/context nextfor detailed next steps
## Integration Points
### /feature continue and /epic continue
Both commands now:
1. Display session status before resuming
2. Check for and display handoff documents
3. Start a new session for tracking
### /context Command
- `/context status` - Shows session and workflow status
- `/context next` - Generates handoff document
- `/context add` - Records item to backlog
### NOTES.md Session Markers
Session boundaries are recorded in NOTES.md:
```markdown
---
## Session Boundary: 2025-12-04T16:30:00Z
*Context compaction occurred. Handoff saved to: sessions/handoff-20251204-163000.md*Autopilot Mode
When autopilot_enabled: true:
- Stop hook can return
{"decision": "block"}to continue execution - Workflow continues through context compaction automatically
- Session boundaries are transparent to the workflow
- Only blocks on actual failures (CI, tests, deployment)
Enable via:
bash .spec-flow/scripts/bash/session-manager.sh autopilot onOr during session start:
bash .spec-flow/scripts/bash/session-manager.sh start --autopilotMetrics Tracked
- Session duration
- Tasks completed per session
- Decisions made per session
- Handoffs generated
- Phase transitions within session
Used for:
- Workflow optimization
- Velocity analysis
- Context usage patterns
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

