Add best practices, hooks, memory files, and scripts from recent sessions
Includes: spec-driven and test-driven development best practices, reproduce-before-fixing debugging workflow, require-plan-file hook, find-project-root script, session logs, memory files for decisions/ gotchas/process-lessons, and updates to existing best practice topics. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
30
scripts/find-project-root
Executable file
30
scripts/find-project-root
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
# Walk up from CWD to find the highest directory containing CLAUDE.md.
|
||||
# Usage:
|
||||
# eval "$(scripts/find-project-root)" # sets CLAUDE_PROJECT_ROOT
|
||||
# export CLAUDE_PROJECT_ROOT="$(scripts/find-project-root --print)"
|
||||
#
|
||||
# With --print: outputs just the path (for subshell capture).
|
||||
# Without flags: outputs an export statement (for eval).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
root=""
|
||||
dir="$(pwd)"
|
||||
while [[ "$dir" != "/" ]]; do
|
||||
if [[ -f "$dir/CLAUDE.md" ]]; then
|
||||
root="$dir"
|
||||
fi
|
||||
dir="$(dirname "$dir")"
|
||||
done
|
||||
|
||||
if [[ -z "$root" ]]; then
|
||||
echo "ERROR: No CLAUDE.md found in any parent directory of $(pwd)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "${1:-}" == "--print" ]]; then
|
||||
echo "$root"
|
||||
else
|
||||
echo "export CLAUDE_PROJECT_ROOT=\"$root\""
|
||||
fi
|
||||
Reference in New Issue
Block a user