core/capabilities/context/session-bridge/SKILL.md
Preserves and restores context across agent sessions using plan file checkboxes as source of truth. Use when starting a new session, resuming previous work, ending a session, or when the user says "continue from last time", "what was I doing", or "save progress".
npx skillsauth add xoai/sage session-bridgeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Maintain continuity across sessions using the plan file as the source of truth.
Core Principle: The file system is the source of truth. What artifacts
exist in .sage/work/ and their frontmatter status tells you where things
stand. decisions.md provides reasoning context that helps find the active work quickly.
State updates happen at checkpoints (Rule 7), not per-task.
Two levels of state, each with a different purpose:
.sage/work/<feature>/ contains artifacts with YAML frontmatter:
brief.md, spec.md, plan.md — each with status and phasepending, in-progress, completed, blockedThis is always accurate because artifacts are created and updated as part of the workflow. No separate "save" action needed.
Each initiative's .sage/work/[initiative]/decisions.md is the
per-cycle log; the global .sage/decisions.md is a shared
cross-initiative log. Both are places where the agent and human
write significant decisions and context. It provides reasoning that
artifact frontmatter doesn't capture — WHY decisions were made,
what alternatives were considered, and what the human's priorities are.
When resuming work, follow this priority order:
Scan .sage/work/ for active initiatives. Read frontmatter from
manifest.md, brief.md, spec.md, or plan.md (whichever exists). Note
title, status, phase. If a plan exists, scan the task checkboxes to
understand how far implementation progressed.
This is the source of truth — what artifacts exist tells you where the project stands.
Branch matching (git projects): read the current branch and
match it against the recorded branch: field in each
initiative's manifest frontmatter (git-discipline records it at
branch creation — match on the recorded field, never re-derive from
branch or directory names). Prefer the initiative whose recorded
branch matches HEAD in the resume menu; if HEAD is on the default
branch while initiative branches exist, list them.
Owner exclusion (parallel worktrees): exclude initiatives whose
manifest carries an owner: pointing at a different checkout —
compare git rev-parse --show-toplevel against the recorded
owner: after path normalization (trailing slashes, symlinks).
They belong to another worktree's session. A session opened inside
a worktree auto-resumes that worktree's checked-out initiative by
the same branch-matching rule.
Read the matched initiative's own decision log first —
.sage/work/[initiative]/decisions.md — then the global
.sage/decisions.md (cross-initiative decisions; older projects
may have only the global file). Read the last 3-5 entries of each.
These capture recent decisions and direction changes — WHY the
project is in its current state, not just WHAT state it's in.
If artifacts and the codebase disagree (e.g., plan says "spec phase" but implementation files exist), trust the codebase. The file system is the ultimate source of truth. Update artifacts to match reality.
Sage: Resuming [feature name]. [Phase] phase. [Summary of what exists and what's next.]
State updates happen ONLY at checkpoints (Rule 7), not per-task:
Prepend significant decisions to the initiative's decision log
(.sage/work/[initiative]/decisions.md; cross-initiative decisions
go to the global .sage/decisions.md):
### 2025-03-13 — Token storage decision
Chose httpOnly cookies over localStorage for JWT storage.
XSS protection outweighs CSRF handling cost.
spec.md updated with cookie-based auth approach.
Update artifact frontmatter if status changed.
Append to .sage/conventions.md:
### Error handling
Project uses a centralized error handler in src/middleware/error-handler.ts.
All route handlers throw typed errors; the middleware formats the response.
If the session is ending gracefully (human says "stop", "done for now"):
If the session ends abruptly: the artifacts in .sage/work/ and
their frontmatter reflect the real state. The next session's slash
command auto-pickup reads them to orient.
FIX mode typically doesn't have plan artifacts. For FIX mode:
/fix command scans for in-progress fix workNo artifacts found: "Sage: Fresh project, no work in progress."
All artifacts completed: "Previous initiative [name] is complete. Ready for a new task."
Artifacts and codebase disagree: Always trust the codebase (git log, file existence) over artifacts. Update artifact frontmatter to match.
.sage/work/ are the ground truth for state.development
Branch-per-initiative git discipline for all delivery workflows. Defines branch naming by workflow, the propose-confirm creation protocol, dirty-tree and detached-HEAD handling, the always user-gated merge protocol, worktree support for parallel sessions, and abandonment cleanup. Activates only in git repositories — silently inactive everywhere else. Use when starting /build, /fix, /architect, or /build-x at Standard+ scope, when resuming an initiative, when offering a merge at a completion checkpoint, or when the user wants a second concurrent initiative.
development
Drives task-by-task execution from an approved plan with quality gates between each task. Reads the plan, finds the next incomplete task, dispatches implementation, validates, updates progress, and continues. Use after a plan is approved and the user says "go", "start building", "execute the plan", or "implement the feature".
tools
Captures agent mistakes, corrections, and discovered gotchas so they are not repeated. Use when: (1) a command or operation fails unexpectedly, (2) the user corrects the agent, (3) the agent discovers non-obvious behavior through debugging, (4) an API or tool behaves differently than expected, (5) a better approach is found for a recurring task. Also searches past learnings before starting tasks to avoid known pitfalls. Activate alongside the sage-memory skill — they share the same MCP backend but serve different purposes (sage-memory = codebase knowledge, sage-self-learning = agent mistakes and gotchas).
development
Typed knowledge graph stored in sage-memory. Use when creating or querying structured entities (Person, Project, Task, Event, Document), linking related objects, checking dependencies, planning multi-step actions as graph transformations, or when skills need to share structured state. Trigger on "remember that X is Y", "what do I know about", "link X to Y", "show dependencies", "what blocks X", entity CRUD, cross-skill data access, or any request involving structured relationships between things.