Agent skill

Restore Legacy Sessions

by zai-org in zai-org/ZCode

A skill your agent uses when ZCode needs to inspect, plan, or execute restoration of old ACP-era ZCode sessions from ~/.zcode/v2/sessions into the new ZCode task/session stores.

Apache-2.0Auto-check passedDatabases

Install Restore Legacy Sessions

skills CLI
$ npx skills add zai-org/ZCode --skill restore-legacy-sessions -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install zai-org/ZCode restore-legacy-sessions --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/zai-org/ZCode.git skills-src && mkdir -p .claude/skills && cp -r skills-src/apps/zcode-cli/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions .claude/skills/restore-legacy-sessions && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
restore-legacy-sessions
GitHub stars
7.7k
Token cost
~1.2k tokens
SKILL.md length
514 words
Files
3 (incl. scripts)
Skills in repo
5
Repo updated
First seen
Licence
Apache-2.0

At a glance

A skill your agent uses when ZCode needs to inspect, plan, or execute restoration of old ACP-era ZCode sessions from ~/.zcode/v2/sessions into the new ZCode task/session stores.

  • Works in 3 steps: previous agent/provider → workspace to restore → conversation to restore
  • ZCode needs to inspect
  • SKILL.md covers Overview, Stores, Selection Workflow and Presenting Choices, plus 2 more sections
  • Runs JavaScript scripts from its folder; calls node and pnpm

What it does

Restore Legacy Sessions is an agent skill from zai-org/ZCode. Use when ZCode needs to inspect, plan, or execute restoration of old ACP-era ZCode sessions from ~/.zcode/v2/sessions into the new ZCode task/session stores. Trigger when the user wants to choose a previous agent, select a workspace to restore, pick a specific historical conversation, dry-run legacy session migration, or reason about tasks-index.sqlite and ~/.zcode/cli/db/db.sqlite consistency.

Its SKILL.md is about 1.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including scripts.

It sits in Databases. It works with SQLite. The repository describes itself as: Z.ai's coding agent harness. Powerful, intelligent, extensible. The licence is Apache-2.0.

When your agent uses it

  • ZCode needs to inspect
  • Execute restoration of old ACP-era ZCode sessions from ~/.zcode/v2/sessions into the new ZCode task/session stores
  • The user wants to choose a previous agent
  • Select a workspace to restore

Example prompts

  • “/restore-legacy-sessions”

Requirements

  • Node.js

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. previous agent/provider
  2. workspace to restore
  3. conversation to restore

What it can do on your machine

Read from SKILL.md and the folder at commit aac4755. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (JavaScript), which the agent can run.

    Shell commands in SKILL.md call:

    • node
    • pnpm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pnpm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Restore Legacy Sessions loads about 1.2k tokens when it runs. Until then it costs about 105 tokens; SKILL.md has 514 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~105
When it runs · the whole SKILL.md, loaded when a task matches
~1.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from zai-org/ZCode at commit aac4755, republished under its Apache-2.0 licence (© zai-org). 514 words, ~1,197 tokens.

Download SKILL.mdSave it as .claude/skills/restore-legacy-sessions/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
restore-legacy-sessions
description
Use when ZCode needs to inspect, plan, or execute restoration of old ACP-era ZCode sessions from ~/.zcode/v2/sessions into the new ZCode task/session stores. Trigger when the user wants to choose a previous agent, select a workspace to restore, pick a specific historical conversation, dry-run legacy session migration, or reason about tasks-index.sqlite and ~/.zcode/cli/db/db.sqlite consistency.

Restore Legacy Sessions

Overview

Use this skill to guide old ACP-era ZCode session restoration. The first job is selection, not mutation: identify the source agent, the workspace, and the exact conversation before proposing any write to the new stores.

Stores

  • Legacy snapshots: ~/.zcode/v2/sessions/{workspaceHash}/{legacyTaskId}.json
  • Task index: ~/.zcode/v2/tasks-index.sqlite
  • New ZCode session DB: ~/.zcode/cli/db/db.sqlite

Use restoredTaskId = meta.acpSessionId || meta.taskId. The legacy snapshot filename and meta.taskId are historical IDs; the app task list often uses meta.acpSessionId as the real task/session ID.

The scan script defaults to the live legacy source ~/.zcode/v2/sessions; pass --legacy-dir <path> only when the user explicitly asks to inspect another source directory.

Restored ACP-era conversations are normal ZCode Agent history, so persisted provider fields must be glm. Treat the snapshot provider as legacy source context only; do not write task-index migration_source or meta_json.migrationSource for these restores. The migrationSource enum is reserved for the existing Claude Code native import path (claudeCode).

Selection Workflow

Resolve script paths relative to this SKILL.md directory. When running from another working directory, use the absolute path to the script inside the plugin cache.

List source agents:

bash
node scripts/scan-legacy-sessions.mjs agents

After the user chooses an agent, list workspaces for that agent:

bash
node scripts/scan-legacy-sessions.mjs workspaces --agent glm

After the user chooses a workspace, list conversations:

bash
node scripts/scan-legacy-sessions.mjs conversations --agent glm --workspace /Users/dev/test/z-m

Use --query <text> to narrow conversations by title, message content, task id, or session id. Use --json when feeding the result into jq or another script.

Presenting Choices

Ask for one choice at a time unless the user already supplied enough filters:

  1. previous agent/provider
  2. workspace to restore
  3. conversation to restore

Show compact numbered options with title, updated time, message count, restoredTaskId, and restore state. If there are many options, show the top 20 by updatedAt and tell the user how to filter with --query.

After the user chooses an exact conversation, run a dry run first:

bash
node scripts/restore-conversation.mjs --snapshot ~/.zcode/v2/sessions/<workspaceHash>/<legacyTaskId>.json --dry-run

Then apply the restore:

bash
node scripts/restore-conversation.mjs --snapshot ~/.zcode/v2/sessions/<workspaceHash>/<legacyTaskId>.json
Show full SKILL.md (214 more words)Show less

Restore States

  • ready: CLI DB and task-index both already contain the restored task id.
  • needs-cli-db: task-index exists, but ~/.zcode/cli/db/db.sqlite has no session row; rebuild the real session from the legacy snapshot.
  • needs-task-index: CLI DB exists, but task-index is missing; backfill task-index only.
  • needs-full-import: both stores are missing; import session history and then index it.

Mutation Rules

Do not write data during selection. Before any apply step:

  • Create timestamped backups of tasks-index.sqlite and db.sqlite.
  • Keep writes idempotent; never overwrite a new real session that already contains user continuation messages.
  • Preserve task-index pinned, archived, deleted, and title_overridden.
  • Use workspaceKey = workspaceIdentity?.trim() || workspacePath for identity/isolation semantics.
  • Write task-index provider = "glm" and CLI message providerID = "glm" regardless of the snapshot provider.
  • Keep task-index.meta_json.taskId = restoredTaskId; never leave it as the old snapshot meta.taskId.
  • Leave task-index migration_source empty for ACP-era restores. If a previous restore wrote legacy-session, clear it before validating visibility.
  • Write CLI DB part rows for visible text and tool calls. The app detail page renders from part; message.data.content alone is not enough.
  • Preserve assistant threading by setting parentID to the preceding user message id when possible.
  • Do not start old ACP runtimes. Restore from snapshots and new ZCode stores only.

For app code changes, update a spec under docs/ before implementation and run pnpm typecheck and pnpm lint.

© zai-org, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (scripts) in apps/zcode-cli/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions of zai-org/ZCode.

  • SKILL.md
  • scripts/restore-conversation.mjs
  • scripts/scan-legacy-sessions.mjs

Open the folder on GitHubat commit aac4755

Compare with similar skills

Restore Legacy Sessions next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Restore Legacy Sessions compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Restore Legacy Sessions this skillzai-org/ZCode7.7k—~1.2kAutomated safety check: PassApache-2.0
Iptvnator Sqlite DB Worker4gray/iptvnator7.3k—~824Automated safety check: PassMIT
Analyze Nsys Profilemlc-ai/pith-train355—~1.9kAutomated safety check: PassApache-2.0
Reactive Sqlite UIfastrepl/anarlog9.5k—~699Automated safety check: PassMIT
Composer Forensicsdxos/dxos526—~3.1kAutomated safety check: PassCustom licence
Sqlite Schema Designfastrepl/anarlog9.5k—~1.9kAutomated safety check: PassMIT

Similar skills

  • A skill your agent uses when changing Electron SQLite IPC, database-worker operations, request-scoped progress or cancellation, worker packaging, or runtime verification of non-EPG database work.

    7.3k GitHub stars~824 tokensUpdated today
    DatabasesAuto-check passed
  • Analyze Nsys Profile

    mlc-ai/pith-train

    Query a captured PithTrain Nsight Systems profile to measure compute/communication overlap, locate exposed comm by DualPipeV stage, and inspect per-rank stream behavior.

    355 GitHub stars~1.9k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Reactive Sqlite UI

    fastrepl/anarlog

    Build SQLite-backed reactive UI in apps/desktop using stable patterns for reads, selection, forms, writes, and loading states.

    9.5k GitHub stars~699 tokensUpdated today
    DatabasesAuto-check passed
  • Forensically inspect and repair Composer browser profiles — offline (Chrome OPFS / SQLite extract) or live via /recovery.html debug port.

    526 GitHub stars~3.1k tokensUpdated today
    DatabasesAuto-check passed
  • Sqlite Schema Design

    fastrepl/anarlog

    Design or review schemas for crates/cloudsync using SQLite Sync constraints, not generic SQLite advice.

    9.5k GitHub stars~1.9k tokensUpdated today
    DatabasesAuto-check passed
  • Makemigrations

    deusXmachina-dev/memorylane

    Create SQLite migrations for MemoryLane storage schema changes.

    121 GitHub stars~973 tokensUpdated 3 days ago
    DatabasesAuto-check passed

More from zai-org/ZCode

All 25 skills in this repo
  • DOCX

    zai-org/ZCode

    Complete DOCX document creation, editing, and analysis capabilities with support for revisions, comments, formatting preservation, and text extraction.

    7.7k GitHub stars~4.9k tokensUpdated yesterday
    Auto-check: notes
  • Visualize

    zai-org/ZCode

    Create visualizations and interactive tools directly in conversation.

    7.7k GitHub stars~8.7k tokensUpdated yesterday
    Auto-check passed
  • PDF

    zai-org/ZCode

    Professional PDF toolkit covering four production workflows: reports, creative visuals, academic LaTeX, and existing PDF processing.

    7.7k GitHub stars~18k tokensUpdated yesterday
    Auto-check: notes
  • Generate, verify, or remove large synthetic ZCode task fixtures in local ~/.zcode persistence for UI/session performance testing.

    7.7k GitHub stars~698 tokensUpdated yesterday
    Auto-check passed
  • Check ZCode module and layer boundaries for code changes. An agent skill from zai-org/ZCode.

    7.7k GitHub stars~1.3k tokensUpdated yesterday
    Auto-check passed
  • XLSX

    zai-org/ZCode

    Use this skill any time a spreadsheet file is the primary input or output.

    7.7k GitHub starsUsed in 1 repo~4.4k tokens
    Auto-check: notes

Works with

Categories

Questions about Restore Legacy Sessions

What does Restore Legacy Sessions do?

A skill your agent uses when ZCode needs to inspect, plan, or execute restoration of old ACP-era ZCode sessions from ~/.zcode/v2/sessions into the new ZCode task/session stores. Restore Legacy Sessions is an agent skill from zai-org/ZCode.zcode/v2/sessions into the new ZCode task/session stores.

When should I use Restore Legacy Sessions?

Restore Legacy Sessions fits situations like: ZCode needs to inspect; execute restoration of old ACP-era ZCode sessions from ~/.zcode/v2/sessions into the new ZCode task/session stores; the user wants to choose a previous agent; select a workspace to restore.

How do I install Restore Legacy Sessions in Claude Code?

Run `npx skills add zai-org/ZCode --skill restore-legacy-sessions -a claude-code`. Or copy the skill folder (apps/zcode-cli/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions in zai-org/ZCode) into .claude/skills/restore-legacy-sessions in your project. Claude Code loads it when a task matches its description.

How do I install Restore Legacy Sessions in Codex?

Run `npx skills add zai-org/ZCode --skill restore-legacy-sessions -a codex`. Or copy the skill folder (apps/zcode-cli/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions in zai-org/ZCode) into .agents/skills/restore-legacy-sessions in your project. Codex loads it when a task matches its description.

Can I use Restore Legacy Sessions in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add zai-org/ZCode --skill restore-legacy-sessions -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/restore-legacy-sessions, .gemini/skills/restore-legacy-sessions, .github/skills/restore-legacy-sessions and .opencode/skills/restore-legacy-sessions in your project.

What does Restore Legacy Sessions need to run?

Going by SKILL.md and its folder, Restore Legacy Sessions needs JavaScript for the scripts in its folder and the command-line tools its instructions call (node and pnpm). Our summary lists: Node.js.

Does Restore Legacy Sessions access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Restore Legacy Sessions safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Restore Legacy Sessions use?

Restore Legacy Sessions is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Restore Legacy Sessions use?

About 1.2k tokens (SKILL.md is roughly 4.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Restore Legacy Sessions?

Skills that share tags, products or a category with Restore Legacy Sessions: Iptvnator Sqlite DB Worker (4gray/iptvnator, 7.3k stars), Analyze Nsys Profile (mlc-ai/pith-train, 355 stars), Reactive Sqlite UI (fastrepl/anarlog, 9.5k stars) and Composer Forensics (dxos/dxos, 526 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Restore Legacy Sessions?

zai-org (a GitHub organization) maintains it in zai-org/ZCode, which has 7,659 GitHub stars. The repository holds 5 skills in this directory. The repository was last updated on October 10, 2026.

Source: zai-org/ZCode on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.