Skip to content

Session Workflows

A session is more than a conversation. Claude saves your history, snapshots files before editing, links sessions to PRs, and lets you run multiple instances in parallel without conflicts. These patterns help you manage that infrastructure.

Creating Pull Requests

Claude can create PRs directly — either in one shot or step by step.

create a pr for my changes

Or guide it through for a better description:

summarize the changes I've made to the auth module
create a pr
enhance the PR description with more context about the security improvements

The three-step version gives you a PR description you can actually stand behind. Once Claude runs gh pr create, the session is linked to that PR. Resume it later — new context, same PR:

Terminal window
claude --from-pr 123

Tip: After creating the PR, ask Claude to highlight the riskiest parts of the change — useful for calling out what reviewers should focus on.

Desktop Notifications

Long-running tasks mean switching windows and forgetting to check back. Set up a notification so Claude alerts you when it is done or needs approval.

Open ~/.claude/settings.json and add:

{
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"
}
]
}
]
}
}

For Linux, replace the command with:

Terminal window
notify-send 'Claude Code' 'Claude Code needs your attention'

For Windows:

Terminal window
powershell.exe -Command "[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); [System.Windows.Forms.MessageBox]::Show('Claude Code needs your attention', 'Claude Code')"

Narrow it with a matcher — fire the notification only for specific events:

MatcherFires when
idle_promptClaude is done and waiting for your next prompt
permission_promptClaude needs you to approve a tool use
elicitation_dialogClaude is asking you a question
auth_successAuthentication completes

Leave matcher empty (as above) to fire on all events. To verify your hook is registered, run /hooks inside a Claude session.

Running Parallel Sessions

When you are working on multiple tasks at the same time, each Claude session needs its own isolated copy of the codebase. Without isolation, edits from one session corrupt the other.

Git worktrees solve this: each session gets a separate directory, a separate branch, and a separate context. They share repository history and remote connections, but nothing else.

Terminal window
# Terminal 1 — auth refactor in its own branch and directory
claude --worktree feature-auth -n "auth-refactor"
# Terminal 2 — separate bug fix, completely isolated
claude --worktree bugfix-login -n "login-fix"

Each worktree is created at <repo>/.claude/worktrees/<name> and branches from your default remote branch. When you exit a session with no changes, the worktree is cleaned up automatically. With changes, Claude asks whether to keep or remove it.

graph TD R[(Repository)] --> W1[Worktree: feature-auth\nbranch: worktree-feature-auth] R --> W2[Worktree: bugfix-login\nbranch: worktree-bugfix-login] W1 --> S1([Claude session 1\nTerminal 1]) W2 --> S2([Claude session 2\nTerminal 2]) style R fill:#1e293b,color:#7dd3fc,stroke:#334155 style W1 fill:#1e293b,color:#a5b4fc,stroke:#334155 style W2 fill:#1e293b,color:#a5b4fc,stroke:#334155 style S1 fill:#1e293b,color:#86efac,stroke:#334155 style S2 fill:#1e293b,color:#86efac,stroke:#334155

Add .claude/worktrees/ to your .gitignore to keep worktree contents out of your main repo’s untracked files list.

Copying local config to worktrees: Worktrees are fresh checkouts — they do not include .env or other gitignored files. Add a .worktreeinclude file to your project root to copy them automatically:

.env
.env.local
config/secrets.json

Resuming Sessions

Sessions are saved automatically. Three ways to return to previous work:

Terminal window
# Resume the most recent session in this directory
claude --continue
# Pick from a list of sessions
claude --resume
# Resume by name (if you named it)
claude --resume auth-refactor
# Resume a session linked to a specific PR
claude --from-pr 123

Inside a session, use /resume to switch to a different conversation. The picker shows session name, time elapsed, message count, and git branch. Press P to preview before resuming.

Name sessions when you start: It is much easier to find auth-refactor than the first few words of whatever you typed.

Terminal window
claude -n auth-refactor

Or during a session:

/rename auth-refactor

Rewinding When Something Goes Wrong

Every file edit is reversible. Before Claude edits any file, it snapshots the current contents. If a change goes wrong, you have options.

Press Esc twice to open the rewind menu:

OptionWhat it does
Restore code + conversationRoll back files and conversation to the snapshot
Restore conversation onlyKeep file edits, undo the conversation history
Restore code onlyRoll back file edits, keep the conversation
Summarize from hereCompact conversation to this point and continue

Checkpoints are local to your session and separate from git. They cover file changes only — actions that affect remote systems (databases, APIs, deployments) are not reversible this way. That is why Claude asks before running commands with external side effects.

Knowing you can rewind makes it easier to let Claude experiment on complex problems without fear.

Asking Claude About Itself

Claude has access to its own documentation and can answer questions about its features.

how do I set up hooks to auto-format on save?
what's the best way to structure my CLAUDE.md?
how do I use MCP with Claude Code?
what's the difference between a skill and a subagent?

Run /powerup for interactive lessons with animated demos. Run /doctor to diagnose common installation issues.


Related: Prompting Patterns for the techniques you use within sessions. Creator Workflows: Parallel Execution for Boris Cherny’s advanced patterns for running dozens of sessions simultaneously.