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
| 1 | #!/bin/bash |
| 2 | # Example SessionStart hook for loading project context |
| 3 | # This script detects project type and sets environment variables |
| 4 | |
| 5 | set -euo pipefail |
| 6 | |
| 7 | # Navigate to project directory |
| 8 | cd "$CLAUDE_PROJECT_DIR" || exit 1 |
| 9 | |
| 10 | echo "Loading project context..." |
| 11 | |
| 12 | # Detect project type and set environment |
| 13 | if [ -f "package.json" ]; then |
| 14 | echo "๐ฆ Node.js project detected" |
| 15 | echo "export PROJECT_TYPE=nodejs" >> "$CLAUDE_ENV_FILE" |
| 16 | |
| 17 | # Check if TypeScript |
| 18 | if [ -f "tsconfig.json" ]; then |
| 19 | echo "export USES_TYPESCRIPT=true" >> "$CLAUDE_ENV_FILE" |
| 20 | fi |
| 21 | |
| 22 | elif [ -f "Cargo.toml" ]; then |
| 23 | echo "๐ฆ Rust project detected" |
| 24 | echo "export PROJECT_TYPE=rust" >> "$CLAUDE_ENV_FILE" |
| 25 | |
| 26 | elif [ -f "go.mod" ]; then |
| 27 | echo "๐น Go project detected" |
| 28 | echo "export PROJECT_TYPE=go" >> "$CLAUDE_ENV_FILE" |
| 29 | |
| 30 | elif [ -f "pyproject.toml" ] || [ -f "setup.py" ]; then |
| 31 | echo "๐ Python project detected" |
| 32 | echo "export PROJECT_TYPE=python" >> "$CLAUDE_ENV_FILE" |
| 33 | |
| 34 | elif [ -f "pom.xml" ]; then |
| 35 | echo "โ Java (Maven) project detected" |
| 36 | echo "export PROJECT_TYPE=java" >> "$CLAUDE_ENV_FILE" |
| 37 | echo "export BUILD_SYSTEM=maven" >> "$CLAUDE_ENV_FILE" |
| 38 | |
| 39 | elif [ -f "build.gradle" ] || [ -f "build.gradle.kts" ]; then |
| 40 | echo "โ Java/Kotlin (Gradle) project detected" |
| 41 | echo "export PROJECT_TYPE=java" >> "$CLAUDE_ENV_FILE" |
| 42 | echo "export BUILD_SYSTEM=gradle" >> "$CLAUDE_ENV_FILE" |
| 43 | |
| 44 | else |
| 45 | echo "โ Unknown project type" |
| 46 | echo "export PROJECT_TYPE=unknown" >> "$CLAUDE_ENV_FILE" |
| 47 | fi |
| 48 | |
| 49 | # Check for CI configuration |
| 50 | if [ -f ".github/workflows" ] || [ -f ".gitlab-ci.yml" ] || [ -f ".circleci/config.yml" ]; then |
| 51 | echo "export HAS_CI=true" >> "$CLAUDE_ENV_FILE" |
| 52 | fi |
| 53 | |
| 54 | echo "Project context loaded successfully" |
| 55 | exit 0 |