#!/usr/bin/env bash
# start-claude — Launch Claude Code with pre-loaded project context
#
# Runs context-load to gather CLAUDE.md files, directory trees,
# CONTEXT.md files, cwd markdown, and git status, then passes
# the result as an appended system prompt.
#
# All arguments are forwarded to claude.
set -uo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
CONTEXT_LOADER="${SCRIPT_DIR}/context-load"

if [[ ! -x "$CONTEXT_LOADER" ]]; then
    echo "Error: context-load not found at $CONTEXT_LOADER" >&2
    exit 1
fi

context="$("$CONTEXT_LOADER")"

if [[ -n "$context" ]]; then
    exec claude --append-system-prompt "$context" "$@"
else
    exec claude "$@"
fi
