diff --git a/skills/distill-best-practices/SKILL.md b/skills/distill-best-practices/SKILL.md index a79c8e9..cb410da 100644 --- a/skills/distill-best-practices/SKILL.md +++ b/skills/distill-best-practices/SKILL.md @@ -14,35 +14,55 @@ You are extracting generalisable best practices from project-specific memory fil ## Pre-gathered context +### CLAUDE_PROJECT_ROOT +!`test -n "$CLAUDE_PROJECT_ROOT" && echo "$CLAUDE_PROJECT_ROOT" || echo "NOT_SET"` + ### Distill state -!`cat ../claude-foundations/best-practices/.distill-state.json 2>/dev/null || echo "{}"` +!`cat $CLAUDE_PROJECT_ROOT/projects/claude-foundations/best-practices/.distill-state.json 2>/dev/null || echo "{}"` ### Settings -!`cat settings.yaml 2>/dev/null || cat ../claude-foundations/settings.yaml 2>/dev/null || echo "No settings file found"` +!`cat $CLAUDE_PROJECT_ROOT/projects/claude-foundations/settings.yaml 2>/dev/null || echo "Settings not found — CLAUDE_PROJECT_ROOT may not be set"` ### Current best-practices index -!`cat ../claude-foundations/BESTPRACTICES.md 2>/dev/null || echo "No index found"` +!`cat $CLAUDE_PROJECT_ROOT/projects/claude-foundations/BESTPRACTICES.md 2>/dev/null || echo "Index not found"` ### Available best-practices files -!`ls -1 ../claude-foundations/best-practices/ 2>/dev/null || echo "No best-practices directory"` +!`ls -1 $CLAUDE_PROJECT_ROOT/projects/claude-foundations/best-practices/ 2>/dev/null || echo "No best-practices directory"` ### Projects directory listing -!`ls -1d ../*/ 2>/dev/null || echo "No projects directory"` +!`ls -1d $CLAUDE_PROJECT_ROOT/projects/*/ 2>/dev/null || echo "No projects directory"` ## Instructions +### Step 0: Detect project root + +Check the pre-gathered `CLAUDE_PROJECT_ROOT` value above. If it shows `NOT_SET` or the pre-gathered context is missing: + +1. Walk up from the current working directory to find the **highest** parent directory containing a `CLAUDE.md` file — that is the project root. +2. Use that path as `PROJECT_ROOT` for all subsequent steps. + +If `CLAUDE_PROJECT_ROOT` was set, use that value as `PROJECT_ROOT`. + +The key paths derived from the root: +- **Settings**: `/projects/claude-foundations/settings.yaml` +- **Best practices dir**: `/projects/claude-foundations/best-practices/` +- **Best practices index**: `/projects/claude-foundations/BESTPRACTICES.md` +- **Distill state**: `/projects/claude-foundations/best-practices/.distill-state.json` + ### Step 1: Discover changes per project -Read `settings.yaml` for the list of tracked projects and `projects_dir`. +Read `settings.yaml` (pre-gathered above, or read it now if Step 0 detected the root manually). -For each project in `distill.projects`: +For each project in `distill.projects`, get its path: `//`. +Also process any `distill.extra_projects` entries — these have a `path` field relative to `PROJECT_ROOT`. -1. Get the project path: `/` -2. Get current HEAD: `git -C rev-parse HEAD` -3. Look up `last_sha` from `.distill-state.json` for this project -4. If SHA matches → skip this project (no changes) -5. If `last_sha` exists → find changed files: `git -C diff --name-only ..HEAD -- memory/` -6. If `last_sha` is missing (first run) → list all memory files: `ls /memory/*.md` +For each project (from both lists): + +1. Get current HEAD: `git -C rev-parse HEAD` +2. Look up `last_sha` from `.distill-state.json` for this project +3. If SHA matches → skip this project (no changes) +4. If `last_sha` exists → find changed files: `git -C diff --name-only ..HEAD -- memory/` +5. If `last_sha` is missing (first run) → list all memory files: `ls /memory/*.md` Filter to only `memory/*.md` files (exclude `memory/log/` — those are raw, unprocessed). @@ -106,11 +126,11 @@ For each approved proposal: If a new best-practices topic file is needed: - Create it following the format of existing files (top-level heading, subheadings per entry, 2-6 lines per entry) -- Add it to `BESTPRACTICES.md` (in the claude-foundations project root) with a one-line description +- Add it to `/projects/claude-foundations/BESTPRACTICES.md` with a one-line description ### Step 6: Update distill state -Write `best-practices/.distill-state.json`: +Write `/projects/claude-foundations/best-practices/.distill-state.json`: ```json { diff --git a/skills/log/SKILL.md b/skills/log/SKILL.md index 1ede5e4..9104179 100644 --- a/skills/log/SKILL.md +++ b/skills/log/SKILL.md @@ -21,7 +21,7 @@ You are capturing key points from the current session into a structured log file !`ls -1 memory/log/ 2>/dev/null || echo "No log directory yet"` ### Settings -!`cat settings.yaml 2>/dev/null || cat ../claude-foundations/settings.yaml 2>/dev/null || echo "No settings file found — using defaults: retention_days=7, warn_unreflected_days=14"` +!`cat settings.yaml 2>/dev/null || cat $CLAUDE_PROJECT_ROOT/projects/claude-foundations/settings.yaml 2>/dev/null || echo "No settings file found — using defaults: retention_days=7, warn_unreflected_days=14"` ### Reflection state (to check what has been reflected) !`cat .reflection-state.json 2>/dev/null || echo "No reflection state yet"` diff --git a/skills/reflect-logs/SKILL.md b/skills/reflect-logs/SKILL.md index 1eefc1b..e3c80fe 100644 --- a/skills/reflect-logs/SKILL.md +++ b/skills/reflect-logs/SKILL.md @@ -26,7 +26,7 @@ You are processing session logs into structured, topic-based memory files. !`ls -1 memory/ 2>/dev/null || echo "No memory directory"` ### Settings -!`cat settings.yaml 2>/dev/null || cat ../claude-foundations/settings.yaml 2>/dev/null || echo "No settings file found — using defaults: max_logs_per_run=10, retention_days=7, warn_unreflected_days=14"` +!`cat settings.yaml 2>/dev/null || cat $CLAUDE_PROJECT_ROOT/projects/claude-foundations/settings.yaml 2>/dev/null || echo "No settings file found — using defaults: max_logs_per_run=10, retention_days=7, warn_unreflected_days=14"` ### Recent git log (for staleness detection) !`git log --oneline -30 2>/dev/null || echo "Not a git repo"`