Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Guidance for developing lifecycle hooks for Claude Code plugins from the official Anthropic repository.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
examples/load-context.sh
1#!/bin/bash2# Example SessionStart hook for loading project context3# This script detects project type and sets environment variables45set -euo pipefail67# Navigate to project directory8cd "$CLAUDE_PROJECT_DIR" || exit 1910echo "Loading project context..."1112# Detect project type and set environment13if [ -f "package.json" ]; then14echo "๐ฆ Node.js project detected"15echo "export PROJECT_TYPE=nodejs" >> "$CLAUDE_ENV_FILE"1617# Check if TypeScript18if [ -f "tsconfig.json" ]; then19echo "export USES_TYPESCRIPT=true" >> "$CLAUDE_ENV_FILE"20fi2122elif [ -f "Cargo.toml" ]; then23echo "๐ฆ Rust project detected"24echo "export PROJECT_TYPE=rust" >> "$CLAUDE_ENV_FILE"2526elif [ -f "go.mod" ]; then27echo "๐น Go project detected"28echo "export PROJECT_TYPE=go" >> "$CLAUDE_ENV_FILE"2930elif [ -f "pyproject.toml" ] || [ -f "setup.py" ]; then31echo "๐ Python project detected"32echo "export PROJECT_TYPE=python" >> "$CLAUDE_ENV_FILE"3334elif [ -f "pom.xml" ]; then35echo "โ Java (Maven) project detected"36echo "export PROJECT_TYPE=java" >> "$CLAUDE_ENV_FILE"37echo "export BUILD_SYSTEM=maven" >> "$CLAUDE_ENV_FILE"3839elif [ -f "build.gradle" ] || [ -f "build.gradle.kts" ]; then40echo "โ Java/Kotlin (Gradle) project detected"41echo "export PROJECT_TYPE=java" >> "$CLAUDE_ENV_FILE"42echo "export BUILD_SYSTEM=gradle" >> "$CLAUDE_ENV_FILE"4344else45echo "โ Unknown project type"46echo "export PROJECT_TYPE=unknown" >> "$CLAUDE_ENV_FILE"47fi4849# Check for CI configuration50if [ -f ".github/workflows" ] || [ -f ".gitlab-ci.yml" ] || [ -f ".circleci/config.yml" ]; then51echo "export HAS_CI=true" >> "$CLAUDE_ENV_FILE"52fi5354echo "Project context loaded successfully"55exit 056