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:
@@ -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**: `<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
|
||||
|
||||
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>`
|
||||
2. Get current HEAD: `git -C <path> 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 <path> diff --name-only <last_sha>..HEAD -- memory/`
|
||||
6. If `last_sha` is missing (first run) → list all memory files: `ls <path>/memory/*.md`
|
||||
For each project (from both lists):
|
||||
|
||||
1. Get current HEAD: `git -C <path> 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 <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).
|
||||
|
||||
@@ -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 `<PROJECT_ROOT>/projects/claude-foundations/BESTPRACTICES.md` with a one-line description
|
||||
|
||||
### Step 6: Update distill state
|
||||
|
||||
Write `best-practices/.distill-state.json`:
|
||||
Write `<PROJECT_ROOT>/projects/claude-foundations/best-practices/.distill-state.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user