Fix skills: replace \${} with \$VAR to pass Bash permission checks

Claude Code's Bash permission checker rejects \${VAR} parameter
substitution in skill ! commands. Replace all occurrences with \$VAR
(identical shell expansion) across log, reflect-logs, and
distill-best-practices skills. Rewrite \${VAR:-default} to use
test -n / || pattern instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul O'Reilly
2026-03-16 14:19:38 +13:00
parent bb6fb72705
commit 24081a1d6f
3 changed files with 37 additions and 17 deletions

View File

@@ -14,35 +14,55 @@ You are extracting generalisable best practices from project-specific memory fil
## Pre-gathered context ## Pre-gathered context
### CLAUDE_PROJECT_ROOT
!`test -n "$CLAUDE_PROJECT_ROOT" && echo "$CLAUDE_PROJECT_ROOT" || echo "NOT_SET"`
### Distill state ### 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 ### 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 ### 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 ### 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 ### 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 ## 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**: `<PROJECT_ROOT>/projects/claude-foundations/settings.yaml`
- **Best practices dir**: `<PROJECT_ROOT>/projects/claude-foundations/best-practices/`
- **Best practices index**: `<PROJECT_ROOT>/projects/claude-foundations/BESTPRACTICES.md`
- **Distill state**: `<PROJECT_ROOT>/projects/claude-foundations/best-practices/.distill-state.json`
### Step 1: Discover changes per project ### 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: `<PROJECT_ROOT>/<projects_dir>/<project_name>`.
Also process any `distill.extra_projects` entries — these have a `path` field relative to `PROJECT_ROOT`.
1. Get the project path: `<projects_dir>/<project_name>` For each project (from both lists):
2. Get current HEAD: `git -C <path> rev-parse HEAD`
3. Look up `last_sha` from `.distill-state.json` for this project 1. Get current HEAD: `git -C <path> rev-parse HEAD`
4. If SHA matches → skip this project (no changes) 2. Look up `last_sha` from `.distill-state.json` for this project
5. If `last_sha` exists → find changed files: `git -C <path> diff --name-only <last_sha>..HEAD -- memory/` 3. If SHA matches → skip this project (no changes)
6. If `last_sha` is missing (first run) → list all memory files: `ls <path>/memory/*.md` 4. If `last_sha` exists → find changed files: `git -C <path> diff --name-only <last_sha>..HEAD -- memory/`
5. If `last_sha` is missing (first run) → list all memory files: `ls <path>/memory/*.md`
Filter to only `memory/*.md` files (exclude `memory/log/` — those are raw, unprocessed). 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: 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) - 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 `<PROJECT_ROOT>/projects/claude-foundations/BESTPRACTICES.md` with a one-line description
### Step 6: Update distill state ### Step 6: Update distill state
Write `best-practices/.distill-state.json`: Write `<PROJECT_ROOT>/projects/claude-foundations/best-practices/.distill-state.json`:
```json ```json
{ {

View File

@@ -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"` !`ls -1 memory/log/ 2>/dev/null || echo "No log directory yet"`
### Settings ### 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) ### Reflection state (to check what has been reflected)
!`cat .reflection-state.json 2>/dev/null || echo "No reflection state yet"` !`cat .reflection-state.json 2>/dev/null || echo "No reflection state yet"`

View File

@@ -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"` !`ls -1 memory/ 2>/dev/null || echo "No memory directory"`
### Settings ### 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) ### Recent git log (for staleness detection)
!`git log --oneline -30 2>/dev/null || echo "Not a git repo"` !`git log --oneline -30 2>/dev/null || echo "Not a git repo"`