0Pricing
Claude Architect · บทเรียน

การจัดการเซสชัน

เซสชันที่ตั้งชื่อด้วย --resume และสาขาด้วย fork_session

การจัดการเซสชัน เป็นบทเรียน Claude Architect ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Claude Architect และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Claude Architect มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Why Session Management Matters

The Claude API keeps no server-side state — every request sends the FULL message history. So "a session" is really a saved conversation transcript you can persist, reopen, and branch.

In Claude Code, session tooling lets you resume a named line of work later and fork a shared starting point into parallel explorations. Mastering this is core to D5 (Context Management) and D3 (Claude Code Workflows) on the architect exam.

Resume vs Fork at a Glance

Two primitives solve two different problems:

  • --resume <name> — continue a single, named session linearly. Same thread, picked up where you left off.
  • fork_session — branch from a shared point into multiple independent lines that don't interfere with each other.

Resume = one timeline continued. Fork = one timeline split into parallel timelines.

Resuming a Named Session

Use --resume <name> to reopen the exact conversation you left, with its full accumulated context. This is ideal for multi-day work on a single task: a long refactor, an incremental investigation, or a feature you're building across sessions.

The name is your handle — give sessions meaningful names so you can find them later.

# Continue a named, persisted session
claude --resume payment-refactor

# Pick up an investigation from yesterday
claude --resume auth-bug-triage

Forking from a Shared Point

fork_session branches from a common starting state — for example, after you've loaded the codebase context and agreed on an approach. Each fork explores a different option without polluting the others' history.

This is the session-level analogue of "try three solutions in parallel": shared setup, independent outcomes.

# Establish shared context, then branch
claude --resume api-redesign

# Fork two independent approaches from that point
claude --fork-session api-redesign --name approach-rest
claude --fork-session api-redesign --name approach-graphql

When to Resume

Reach for --resume when the work is genuinely continuous and the prior context still holds:

  • A linear task spanning multiple work sessions.
  • Incremental investigation where earlier findings remain valid.
  • You want the full reasoning trail intact, not summarized.

Resuming preserves nuance that a summary would flatten — but only if that context is still accurate.

The Stale Context Trap

Here's the architect-grade caveat: resumed tool results can be STALE if the codebase changed. If files moved, tests were rewritten, or a dependency was upgraded since you last ran, the old Read and Grep outputs in history now describe a world that no longer exists.

Claude will reason over outdated facts unless you correct them. Resume is not free — it carries whatever was true at capture time.

Fresh Session + Structured Summary

When context has drifted, a fresh session seeded with a structured summary is often better than resuming. You discard stale tool output and re-ground the model on current reality.

Keep transactional facts — file paths, decisions, open questions — verbatim in a "case facts" block so progressive summarization doesn't make them vague.

# Fresh session, hand it a curated summary instead of stale history
claude --name payment-refactor-v2

# Paste a structured brief:
# DECISIONS: use Stripe PaymentIntents; keep idempotency keys
# DONE: extracted billing/ module; tests green
# OPEN: webhook retry policy undecided
# NOTE: re-read files — repo changed since last session

Fork for Parallel Exploration

Forking shines when you want to compare alternatives fairly. Branch from identical context so the only variable is the approach itself, then evaluate the outcomes side by side.

  • Two refactor strategies from the same baseline.
  • Different prompt phrasings tested against the same loaded context.
  • A risky experiment isolated from your main line.

Because forks don't share ongoing history, one branch's mistakes never contaminate another.

Sessions and Decomposition

Session strategy mirrors task decomposition. For known sequential steps, a single resumed session acts like a fixed pipeline carrying state forward. For open-ended investigation with multiple viable directions, forking supports adaptive exploration.

Don't force a branch where a line suffices — and don't cram divergent experiments into one ever-growing linear session.

Sessions Are Not Subagents

Don't confuse sessions with multi-agent context. Forking branches your own conversation. By contrast, subagents do NOT inherit the coordinator's history — each subagent must be handed its context explicitly in its prompt.

Use sessions to manage your continuity across time; use the hub-and-spoke coordinator pattern to fan work out to fresh agents. They solve different problems.

A Practical Workflow

Putting it together for a multi-day feature:

  • Start named, do the shared setup (load context, agree on plan).
  • Fork when you need to trial competing approaches.
  • --resume the winner across days as you build it out.
  • When the repo shifts under you, abandon the stale session and re-seed a fresh one with a verbatim case-facts summary.

Continuity by default, branch when exploring, refresh when reality moves.

# Day 1: set up + branch
claude --name search-feature
claude --fork-session search-feature --name try-elastic
claude --fork-session search-feature --name try-postgres-fts

# Day 3: continue the chosen path
claude --resume search-feature

# Day 5: repo changed a lot -> fresh + summary
claude --name search-feature-v2

Quick Check

Apply the stale-context principle to a real decision.

Recap: Resume, Fork, Refresh

Key takeaways:

  • --resume <name> continues one named session linearly — great for continuous, multi-session work.
  • fork_session branches from a shared point into independent parallel lines that don't interfere.
  • Resumed tool results can be stale if the code changed — sometimes a fresh session with a structured summary is the better call.
  • Keep transactional facts verbatim outside summaries; sessions manage YOUR continuity, while subagents need context passed explicitly.

Continuity by default, branch to explore, refresh when reality moves.

คำถามที่พบบ่อย

บทเรียน “การจัดการเซสชัน” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “การจัดการเซสชัน” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Claude Architect ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Claude Architect มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “การจัดการเซสชัน”

เซสชันที่ตั้งชื่อด้วย --resume และสาขาด้วย fork_session คุณปฏิบัติ Claude Architect ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Claude Architect หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Claude Architect บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน

บทเรียน “การจัดการเซสชัน” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Claude Architect นี้ได้ไหม

ได้ บทเรียน Claude Architect ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. กระบวนการทำงานแบบตายตัวเทียบกับการแยกย่อยแบบปรับตัว
  2. การแยกย่อยหลายรอบ
  3. การจัดการเซสชัน
  4. บริบทเก่าและการเริ่มต้นใหม่
← กลับไปที่ Claude Architect