claude-code-autoconfig: Command for Claude Code

.claude/commands/migrate-new-session.md

migrate-new-session is a command for Claude Code from design-and-deliver/claude-code-autoconfig. It costs 0 tokens per session (1,395 once invoked), scanned A, original, MIT.

A command run in a new session to continue work from an earlier Claude Code session. It finds a prepared handoff or builds one from session title history.

In plain words
What is it for?
Use it after moving to a new session to recover the previous session's scope and context using a handoff keyword or scope name.
Why use it?
It removes the need to manually locate a handoff file or pass recovery details when switching sessions.

Command for Claude Code

Written for Claude Code: $ARGUMENTS substitution. Also seen: reads .claude/ paths.

This is design-and-deliver/claude-code-autoconfig's own configuration. It tells Claude Code how to work on claude-code-autoconfig itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-code-autoconfig configures →

Reuse

Borrowing it

Nothing to install: this file belongs to design-and-deliver/claude-code-autoconfig. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/design-and-deliver/claude-code-autoconfig/main/.claude/commands/migrate-new-session.md
Clone the repo
git clone --depth 1 https://github.com/design-and-deliver/claude-code-autoconfig

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for migrate-new-session

README.md
[![agentmods](https://agentmods.dev/badge/commands/design-and-deliver/claude-code-autoconfig/migrate-new-session.svg)](https://agentmods.dev/commands/design-and-deliver/claude-code-autoconfig/migrate-new-session)
Your own site
<a href="https://agentmods.dev/commands/design-and-deliver/claude-code-autoconfig/migrate-new-session"><img src="https://agentmods.dev/badge/commands/design-and-deliver/claude-code-autoconfig/migrate-new-session.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,395 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.01395
Opus 5 $0.00000 $0.00698
Sonnet 5 $0.00000 $0.00279
Haiku 4.5 $0.00000 $0.00139

Measured 7d ago against content hash 47cf81ffe4e1, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

migrate-new-session scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/migrate-new-session.md · 83 lines

How it starts

The opening of the file, as written. The whole thing — 83 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Run this in the new session. It completes the cutover — no manual /recover-context args, no manual handoff read. Two modes, auto-detected in Step 1.

Step 1: Resolve the keyword — manifest first, else self-package

The keyword is: $ARGUMENTS (trim whitespace/flags). Look for .claude/handoff/<keyword>.manifest.json.

  • It exists → MANIFEST MODE. Read its fields (sid8, boundaryIso, handoffFile) and use them for Steps 2–4 exactly as written.

  • It doesn't → SELF-PACKAGE MODE. The keyword is a scope slug (e.g. the one a scope-drift nudge printed). There is no pre-written prep — derive it from the old session's terminal-title ledger (.titles/{sid}.history.jsonl, one line per title change). Run this to find the source session + boundary (collapses each ledger into scope tenures — scope = segment 1 of the title — and matches the keyword against them, slugified the same way the guard emits it; a just-born session whose first ledger line is under 10 minutes old is skipped, so the session you're running this in never matches its own baseline title):

    node -e "
    const fs=require('fs'),path=require('path');
    const kw=process.argv[1];
    const slug=s=>String(s||'').toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-+|-+\$/g,'').slice(0,40).replace(/-+\$/g,'')||'session';
    const dir=path.join(process.cwd(),'.claude','hooks','.titles');
    let out=[];
    try{for(const f of fs.readdirSync(dir).filter(f=>f.endsWith('.history.jsonl'))){
      const tenures=[];
      for(const line of fs.readFileSync(path.join(dir,f),'utf8').split(/\r?\n/)){
        if(!line.trim())continue;
        let e;try{e=JSON.parse(line)}catch(_){continue}
        const scope=String(e.title||'').split(' — ')[0].trim();
        if(!scope)continue;
        const last=tenures[tenures.length-1];
        if(!last||last.scope!==scope)tenures.push({scope,enteredIso:e.ts});
      }
      if(!tenures.length||Date.now()-Date.parse(tenures[0].enteredIso)<10*60000)continue;
      const hit=[...tenures].reverse().find(t=>slug(t.scope)===kw);
      if(hit)out.push({sid8:f.slice(0,8),boundaryIso:hit.enteredIso,scope:hit.scope,mtime:fs.statSync(path.join(dir,f)).mtimeMs});
    }}catch(_){}
    out.sort((a,b)=>b.mtime-a.mtime);
    console.log(JSON.stringify(out,null,2));
    " "<keyword>"
    
    • One match → that's sid8 and boundaryIso (the matched tenure's first title write). Continue.
    • Several matches → list them (sid8 + scope + recency) and ask which to migrate; stop.
    • No match / no .titles dir (terminal-title module off or ledger absent) → fall back: take the newest *.jsonl in ~/.claude/projects/<cwd-slug>/ that isn't this session as sid8, leave boundaryIso unset, and use recover-context's own 15-min window. Note the degraded mode in Step 4.

Read the full file on GitHub · 83 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 83 lines · 0 tokens per session scan A 47cf81ffe4e1

Subscribe to this mod's changes

migrate-new-session is a command published in the GitHub repository design-and-deliver/claude-code-autoconfig (2 stars, last pushed 4d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,395 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.