spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / plugins / plugin-dev / skills / hook-development / examples / post-teleport.sh
52 lines · 1.5 KBRaw
1#!/bin/bash
2# Example SessionStart hook with "teleport" matcher for setting up environment
3# after teleporting from web to CLI. This script pulls changes, installs
4# dependencies, and starts the dev server.
5
6set -euo pipefail
7
8# Navigate to project directory
9cd "$CLAUDE_PROJECT_DIR" || exit 0
10
11echo "Setting up environment after teleport..."
12
13# Pull latest changes if in a git repository
14if [ -d ".git" ]; then
15 current_branch=$(git branch --show-current)
16 echo "🔄 Pulling latest changes for branch: $current_branch"
17 git pull origin "$current_branch" 2>/dev/null || echo "Could not pull (may be offline or no upstream)"
18fi
19
20# Install dependencies based on project type
21if [ -f "package.json" ]; then
22 echo "📦 Installing Node.js dependencies..."
23 npm install --silent 2>/dev/null || npm install
24fi
25
26if [ -f "requirements.txt" ]; then
27 echo "🐍 Installing Python dependencies..."
28 pip install -r requirements.txt --quiet 2>/dev/null || pip install -r requirements.txt
29fi
30
31if [ -f "Cargo.toml" ]; then
32 echo "🦀 Building Rust project..."
33 cargo build 2>/dev/null || true
34fi
35
36# Start development server if available
37if [ -f "package.json" ]; then
38 # Check for common dev server scripts
39 if grep -q '"dev:staging"' package.json; then
40 echo "🚀 Starting staging dev server..."
41 npm run dev:staging &
42 elif grep -q '"dev"' package.json; then
43 echo "🚀 Starting dev server..."
44 npm run dev &
45 elif grep -q '"start"' package.json; then
46 echo "🚀 Starting server..."
47 npm start &
48 fi
49fi
50
51echo "✅ Teleport complete! Environment ready."
52exit 0