agentleFS
fatih-developerfatih-developer/fth-skills/skills/session-transfer/SKILL.md

session-transfer

Skill7 starsChanged 43 days agoMITView on GitHub

Create and resume agent-aware session handoffs across Codex, Claude Code, OpenCode, and unknown runtimes. Triggers on save state, create handoff, resume latest session, context pressure, /goal completion, or continue where we left off. Persists indexed, immutable handoffs so a new session can continue without chat or terminal history.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

18 rules. About 0 are common, 10 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do not treat this skill as Codex-only.

    line 16
  2. Very specific:

    Before CREATE or RESUME, detect the active runtime.

    line 20
  3. Very specific:

    Use local project time when reliable.

    line 55
  4. Distinctive:

    Run the shipped helper (it detects the agent, writes the handoff, appends JSONL, and rewrites both indexes):

    line 71
  5. Very specific:

    Write handoffs/YYYY-MM-DD-HHmm.md (suffix on collision).

    line 82
  6. Very specific:

    Update <agent-dir>/INDEX.md and .session-transfer/INDEX.md.

    line 84
  7. Very specific:

    Do not finalize if secrets are detected or the score is below 70.

    line 102
  8. Distinctive:

    Prefer fast, low-context navigation.

    line 106
  9. Very specific:

    Read .session-transfer/INDEX.md first when present.

    line 114
  10. Distinctive:

    Prefer the current agent’s relevant unfinished handoff.

    line 115
  11. Distinctive:

    Read only the selected handoff initially.

    line 117
  12. Very specific:

    Follow references/resume-checklist.md.

    line 123
  13. Distinctive:

    Not purely manual. At most one automatic handoff per logical work boundary.

    line 127
  14. Distinctive:

    Do not auto-CREATE for a tiny copy change, simple formatting, or an isolated low-impact fix.

    line 131
  15. Distinctive:

    When the runtime indicates remaining context is low enough to threaten reliable completion, persist before continuing or stopping:

    line 137
  16. Distinctive:

    Do not hard-code a percentage that only works for one agent.

    line 144
  17. Very specific:

    Every /goal that performed meaningful work (completed, partial, blocked, or interrupted/aborted) must run CREATE and succeed at …

    line 148
  18. Distinctive:

    Read the global index before history.

    line 167

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Session Transfer

Persist substantial work as an immutable, indexed handoff so a later session — or a different coding agent — can continue without reconstructing chat or terminal history.

Mode Selection

CREATE — save state, pause, context is getting full, /goal is closing, or an automatic trigger fires.

RESUME — continue previous work, load the latest session, or resume unfinished work on a topic.

Do not treat this skill as Codex-only. Detect the active runtime, then write under that agent’s directory.

Agent Detection

Before CREATE or RESUME, detect the active runtime. Do not pick Codex, Claude Code, or OpenCode just because .codex, .claude, or .opencode already exist (a repo may contain all three).

Signal priority:

  1. Runtime / environment signals (CODEX_*, CLAUDECODE / CLAUDE_CODE*, OPENCODE*)
  2. Agent-specific execution or configuration context
  3. Explicit user instruction (--agent, or “create this as a Claude handoff”)
  4. Reliable agent self-identification
  5. Existing agent directory only as a weak supporting signal — never the sole reason
  6. Fallback: unknown / future runtime → .agent

Directory mapping:

RuntimeDirectory
Codex.codex
Claude Code.claude
OpenCode.opencode
Unknown / future.agent

Storage Layout

<agent-dir>/
├── INDEX.md
├── handoffs.jsonl
└── handoffs/
    └── YYYY-MM-DD-HHmm.md

.session-transfer/
└── INDEX.md

Examples: .codex/handoffs/2026-08-18-1704.md, .claude/handoffs/2026-08-18-1830.md.

Use local project time when reliable. Timestamped files are immutable history — never overwrite an older one. On collision append a deterministic suffix (-2, -3, …). Older YYYY-MM-DD-HHMMSS-slug.md files stay readable for RESUME.

.session-transfer/INDEX.md is the primary navigation layer: current/recommended handoff, last source agent, topic, status, branch if known, next recommended action, recent cross-agent handoffs. Keep it compact. Do not copy full handoff bodies into any index. Do not invent git, repo, or agent fields you cannot verify.

Each agent INDEX.md is a lightweight current + recent table. handoffs.jsonl is one compact JSON object per line (fields only when known): id, created, agent, topic, status, trigger, branch, commit, file, previous_session, resumed_from, goal_status.

Status and Triggers

Status: completed | in-progress | partial | blocked | interrupted

Trigger: manual | goal-completion | substantial-work | context-pressure | agent-transfer | interrupted

Optional goal_status may track /goal outcome separately. Do not invent extra statuses or triggers.

CREATE

Run the shipped helper (it detects the agent, writes the handoff, appends JSONL, and rewrites both indexes):

python skills/session-transfer/scripts/create_handoff.py <topic> --status <status> --trigger <trigger>

Useful flags: --agent, --workspace, --branch, --commit, --goal-status, --next-action, --continues-from, --resumed-from. Pass known fields; omit unknown ones.

  1. Detect the runtime (priority above).
  2. Inspect current repo/work state needed for an accurate handoff (git branch/commit/modified files when available).
  3. Determine status and trigger from the vocabularies above.
  4. Write handoffs/YYYY-MM-DD-HHmm.md (suffix on collision).
  5. Append one JSONL line.
  6. Update <agent-dir>/INDEX.md and .session-transfer/INDEX.md.
  7. Reply with a concise confirmation only unless the user asks for the full document:
Session handoff created.
Status: completed
Handoff: .codex/handoffs/2026-08-18-1709.md
Global index updated: .session-transfer/INDEX.md

Fill the handoff so a fresh session can continue without chat/terminal history. Use references/handoff-template.md. Include compact YAML metadata when known (session_id, created, source_agent, source_model, trigger, status, goal_status, topic, working_directory, branch, commit, previous_session, resumed_from). Prefer precise file paths, decisions, verification outcomes (passed / failed / not run), remaining work, and a single Next Recommended Action.

Then validate:

python skills/session-transfer/scripts/validate_handoff.py <handoff-file>

Do not finalize if secrets are detected or the score is below 70. After a cross-agent resume, the next CREATE must record lineage: source_agent, resumed_from, previous_session.

RESUME

Prefer fast, low-context navigation. Do not scan every historical handoff unless indexes are missing.

python skills/session-transfer/scripts/resume_handoff.py
python skills/session-transfer/scripts/list_handoffs.py
python skills/session-transfer/scripts/check_staleness.py <handoff-file>
  1. Read .session-transfer/INDEX.md first when present.
  2. Prefer the current agent’s relevant unfinished handoff.
  3. Otherwise resume the latest compatible cross-agent handoff (Codex ↔ Claude Code ↔ OpenCode ↔ .agent).
  4. Read only the selected handoff initially.
  5. Inspect current git/repo state. Verify referenced files still exist. Detect changes after the handoff (check_staleness.py: FRESH / SLIGHTLY_STALE / STALE / VERY_STALE).
  6. Continue from Next Recommended Action only after reconciliation. Never blindly trust a stale handoff over the repository.

If the global index is missing or corrupted: fall back to agent INDEX.md, then JSONL / handoff metadata. Reconstruct the smallest needed index with the resume --recover path (or recover_indexes); never delete timestamped handoffs. If JSONL and Markdown indexes disagree, verify against actual handoff files and repo state.

Follow references/resume-checklist.md. For chained work, read the newest handoff first; open a predecessor only if needed.

Automatic CREATE

Not purely manual. At most one automatic handoff per logical work boundary.

Treat work as substantial when any of these apply: feature/module implemented; architecture, schema/migration, API contract, auth/security, or deploy/infra changed; 5+ meaningful files; multi-phase work; meaningful build/test/debug; large context; continuation would otherwise require reconstructing state. A critical one-file architecture, migration, security, or contract change still qualifies.

Do not auto-CREATE for a tiny copy change, simple formatting, or an isolated low-impact fix.

A large /goal with many substeps gets one handoff at the end, not one after every substep. Intermediate auto-handoffs only when: context pressure, agent change, interruption, an explicit checkpoint, or an explicit user request.

Context pressure

When the runtime indicates remaining context is low enough to threaten reliable completion, persist before continuing or stopping:

trigger: context-pressure
status: in-progress

Do not hard-code a percentage that only works for one agent. If there is no context signal, use session-length / complexity indicators — do not invent a percent.

/goal completion contract

Every /goal that performed meaningful work (completed, partial, blocked, or interrupted/aborted) must run CREATE and succeed at persistence/indexing before the goal is considered closed. Do not add or depend on other goal-workflow skills.

/goal → implement → verify → determine status → session-transfer CREATE → indexes → concise reply

Implementation ✓
Verification   ✓
Handoff        ✓
Index update   ✓
----------------
GOAL DONE      ✓

Recovery

Indexes are navigation. Timestamped handoffs are history. If an index is missing, stale, or corrupted: do not delete handoffs; rebuild the smallest index from JSONL / handoff metadata; report the repair concisely.

Token efficiency

Read the global index before history. Read one selected handoff before older sessions. Keep indexes and JSONL compact. Do not print the full handoff after CREATE. Prefer repo verification over replaying chat.

Usage examples

Use session-transfer to create a handoff.
Use session-transfer to resume the latest session.
Use session-transfer to resume the latest unfinished billing work.
/goal ...
# session-transfer runs as the terminal persistence step

Scripts

ScriptPurpose
scripts/create_handoff.py <topic>CREATE: immutable handoff + JSONL + indexes
scripts/resume_handoff.pyRESUME: select current-agent or cross-agent handoff
scripts/list_handoffs.py [path]List handoffs across agent dirs
scripts/validate_handoff.py <file>Completeness, quality, secrets
scripts/check_staleness.py <file>Whether repo state still matches

Resources

  • references/handoff-template.md — required sections and metadata
  • references/resume-checklist.md — reconcile before continuing

🔗 Next Steps & Handoffs

<!-- BEGIN GENERATED: handoffs (generated from the ecosystem workflow map by build_ecosystems.py — do not edit by hand) -->

Ecosystem: @ecosystem-orchestration — Agent Orchestration.

Workflows:

  • Failure & Context Pressure Flow (orch-resilience, step 3 of 3): last step → once it passes, complete the workflow and report the outcome.

Direct handoffs:

  • @memory-ledger — A resumed session needs an in-task ledger again.

Handoff contract: pass results to the next skill through an inline Handoff block in your reply with the fields skill, workflow, created_at, inputs, summary, and next (the handoff contract of @ecosystem-orchestration). If a next skill is not installed, continue with its step from the ecosystem map, or install it with npx skills add fatih-developer/fth-skills --skill <name> after the user agrees.

<!-- END GENERATED: handoffs -->

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.