mirror of
https://github.com/anthropics/claude-code.git
synced 2026-04-28 00:27:12 +00:00
Add documentation and examples for new teleport hooks that allow users to automate workflows when sessions transfer between web and CLI: - PreTeleport: Runs before teleporting (stash work, sync state) - PostTeleport: Runs after teleporting (pull changes, start dev servers) This addresses the common workflow where users teleport from web to CLI and need to run setup commands like `yarn dev:staging`. Slack thread: https://anthropic.slack.com/archives/C096H3HP75G/p1765833639134099?thread_ts=1765833353.488839&cid=C096H3HP75G
34 lines
960 B
Bash
34 lines
960 B
Bash
#!/bin/bash
|
|
# Example PreTeleport hook for preparing environment before teleporting
|
|
# This script stashes uncommitted changes and saves state for restoration
|
|
|
|
set -euo pipefail
|
|
|
|
# Navigate to project directory
|
|
cd "$CLAUDE_PROJECT_DIR" || exit 0
|
|
|
|
echo "Preparing for teleport..."
|
|
|
|
# Check if we're in a git repository
|
|
if [ ! -d ".git" ]; then
|
|
echo "Not a git repository, skipping pre-teleport preparation"
|
|
exit 0
|
|
fi
|
|
|
|
# Stash uncommitted changes before teleporting
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
echo "📦 Stashing uncommitted changes before teleport..."
|
|
git stash push -m "pre-teleport-stash-$(date +%s)"
|
|
echo "Changes stashed successfully"
|
|
else
|
|
echo "No uncommitted changes to stash"
|
|
fi
|
|
|
|
# Save current branch state for post-teleport restoration
|
|
mkdir -p .claude
|
|
echo "$(git branch --show-current)" > .claude/.teleport-state
|
|
echo "Current branch saved: $(cat .claude/.teleport-state)"
|
|
|
|
echo "Pre-teleport preparation complete"
|
|
exit 0
|