claude-code - 💡(How to fix) Fix Feature Request: Session Templates / Forking - Save compressed state as starting point for new sessions [1 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#51998Fetched 2026-04-23 07:39:18
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
labeled ×2

Ability to save a session's compressed context state as a template, then spawn multiple new sessions that start from that frozen state (not resuming the original session).

Root Cause

Ability to save a session's compressed context state as a template, then spawn multiple new sessions that start from that frozen state (not resuming the original session).

Code Example

Session 1: Read 50 files → /compact → [Rich Context]
Now I want:
  - Session 2: Start from Session 1's state (work on feature A)
  - Session 3: Start from Session 1's state (work on feature B)
  - Session 4: Start from Session 1's state (fix bug)
  
Currently: IMPOSSIBLE
Each session must re-read files = wasted time + tokens

---

# Save current session as template
/session save --name "sprint-5-context" --description "Sprint 5.2 with all domain rules read"

# List available templates
/session list --templates

# Create NEW session from template (NOT resume)
/session new --template "sprint-5-context" --name "Implementing US-53"

# Delete old template
/session delete-template "sprint-5-context"

# Auto-save after file-reading heavy sessions
/session save --name "backend-context" --if-files-read-greater 20

---

# Senior dev: Read entire codebase once
Session 1: Read 100 files → /compact → /session save --name "njordbok-full"

# Junior devs: Start from that context
Session 2: /session new --template "njordbok-full" --name "Feature X"
Session 3: /session new --template "njordbok-full" --name "Bug Y"

---

# After sprint planning meeting
Session 1: Read all sprint docs + domain rules → /session save --name "sprint-6-kickoff"

# Parallel work
Session 2: /session new --template "sprint-6-kickoff" # US-101
Session 3: /session new --template "sprint-6-kickoff" # US-102
Session 4: /session new --template "sprint-6-kickoff" # US-103

---

# Deep dive into auth system once
Session: Read auth//session save --name "auth-expert-context"

# Reuse for all auth-related work
Session: /session new --template "auth-expert-context" # Work on auth bug
Session: /session new --template "auth-expert-context" # Work on RBAC feature

---

# Tech lead creates template
/session save --name "team-shared-context" --description "Q2 architecture decisions"

# Team members use it
/session new --template "team-shared-context" # Everyone starts aligned

---

# Check if template is still valid
/session validate-template "sprint-5-context"
# Warns if:
# - Files have changed (git diff)
# - Project structure changed
# - Template is > 30 days old

---

# Show template sizes
/session list --templates --sizes

# Auto-cleanup
/session cleanup --templates --older-than 90days
RAW_BUFFERClick to expand / collapse

Feature Request: Session Templates / Forking

Summary

Ability to save a session's compressed context state as a template, then spawn multiple new sessions that start from that frozen state (not resuming the original session).

Problem Statement

Current Limitation:

  • Each new session starts with minimal context
  • Must re-read files, re-learn project structure every time
  • Cannot share "rich context" across multiple parallel sessions
  • Session resume only allows ONE continuation, not forking

Real-World Pain Point:

Session 1: Read 50 files → /compact → [Rich Context]
Now I want:
  - Session 2: Start from Session 1's state (work on feature A)
  - Session 3: Start from Session 1's state (work on feature B)
  - Session 4: Start from Session 1's state (fix bug)
  
Currently: IMPOSSIBLE
Each session must re-read files = wasted time + tokens

Proposed Solution

CLI Commands

# Save current session as template
/session save --name "sprint-5-context" --description "Sprint 5.2 with all domain rules read"

# List available templates
/session list --templates

# Create NEW session from template (NOT resume)
/session new --template "sprint-5-context" --name "Implementing US-53"

# Delete old template
/session delete-template "sprint-5-context"

# Auto-save after file-reading heavy sessions
/session save --name "backend-context" --if-files-read-greater 20

UI/UX

In VS Code extension:

  • Right-click session → "Save as Template"
  • New Session → "Start from Template" dropdown
  • Template manager (view/delete/update)

In CLI:

  • Template names with tab completion
  • Show template size/age
  • Validate template integrity

Use Cases

1. Project Onboarding

# Senior dev: Read entire codebase once
Session 1: Read 100 files → /compact → /session save --name "njordbok-full"

# Junior devs: Start from that context
Session 2: /session new --template "njordbok-full" --name "Feature X"
Session 3: /session new --template "njordbok-full" --name "Bug Y"

2. Parallel Feature Development

# After sprint planning meeting
Session 1: Read all sprint docs + domain rules → /session save --name "sprint-6-kickoff"

# Parallel work
Session 2: /session new --template "sprint-6-kickoff" # US-101
Session 3: /session new --template "sprint-6-kickoff" # US-102
Session 4: /session new --template "sprint-6-kickoff" # US-103

3. Knowledge Reuse

# Deep dive into auth system once
Session: Read auth/ → /session save --name "auth-expert-context"

# Reuse for all auth-related work
Session: /session new --template "auth-expert-context" # Work on auth bug
Session: /session new --template "auth-expert-context" # Work on RBAC feature

4. Team Collaboration

# Tech lead creates template
/session save --name "team-shared-context" --description "Q2 architecture decisions"

# Team members use it
/session new --template "team-shared-context" # Everyone starts aligned

Technical Considerations

Storage Location

  • Local: .claude/templates/ (project-specific)
  • Global: ~/.claude/templates/ (shared across projects)
  • Cloud: (future) Sync templates across devices

Template Contents

Should include:

  • ✅ Compressed message history
  • ✅ Files read (with checksums for validation)
  • ✅ Learnings/context from conversation
  • ❌ Sensitive data (API keys, secrets - auto-filter)
  • ❌ Task state (start fresh for new sessions)

Validation

# Check if template is still valid
/session validate-template "sprint-5-context"
# Warns if:
# - Files have changed (git diff)
# - Project structure changed
# - Template is > 30 days old

Size Management

# Show template sizes
/session list --templates --sizes

# Auto-cleanup
/session cleanup --templates --older-than 90days

Alternative Names

  • Session Templates
  • Session Forking
  • Session Snapshots
  • Context Templates
  • Saved States

Priority

High - Would significantly improve workflow for:

  • Large codebases (read files once, reuse everywhere)
  • Teams (shared starting points)
  • Parallel work (multiple sessions from same context)
  • Token efficiency (avoid re-reading same files)

Related Features

  • Memory files (auto-loaded, but manual)
  • Session resuming (continuation, not forking)

Implementation Ideas

Option 1: Full Context Clone

  • Save entire compressed conversation
  • New sessions load this as initial messages
  • Simpler but larger storage

Option 2: Structured Snapshot

  • Extract key learnings, files, context
  • Store as structured JSON
  • More efficient, but complex extraction

Option 3: Hybrid

  • Save summary + file list + key decisions
  • New sessions read files from list (fast, current)
  • Best balance of size/accuracy

Would greatly improve productivity for teams working with large codebases!

extent analysis

TL;DR

Implementing session templates or forking functionality can significantly improve workflow efficiency by allowing multiple sessions to start from a shared context, reducing the need to re-read files and re-learn project structures.

Guidance

  • To achieve this, consider implementing a template saving mechanism that stores the compressed context state of a session, including files read and key learnings, but excludes sensitive data and task state.
  • When creating a new session from a template, validate the template's integrity and warn if files have changed, the project structure has changed, or the template is outdated.
  • Implement a size management system to auto-cleanup old templates and show template sizes to users.
  • Consider using a hybrid approach to store session context, balancing storage size and accuracy.

Example

# Save current session as template
/session save --name "sprint-5-context" --description "Sprint 5.2 with all domain rules read"

# Create new session from template
/session new --template "sprint-5-context" --name "Implementing US-53"

Notes

The implementation details, such as storage location and template contents, will significantly impact the effectiveness and usability of the session template feature. It's essential to consider factors like data validation, size management, and user experience when designing this feature.

Recommendation

Apply a hybrid approach to implement session templates, balancing storage size and accuracy, to improve workflow efficiency for teams working with large codebases. This approach will allow for efficient storage and retrieval of session context while minimizing the risk of data inconsistencies.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING