|
|
|
|
@@ -3,7 +3,7 @@ name: distill-best-practices
|
|
|
|
|
description: >
|
|
|
|
|
Cross-project best practices distillation. Reads changed memory files from all tracked
|
|
|
|
|
projects and proposes additions, updates, or removals to claude-foundations/best-practices/.
|
|
|
|
|
Run from any project — always targets claude-foundations as output. Interactive — presents
|
|
|
|
|
Run from any project -- always targets claude-foundations as output. Interactive -- presents
|
|
|
|
|
proposals for approval before making changes.
|
|
|
|
|
allowed-tools: Read, Edit, Write, Glob, Grep, Bash(git -C *), Bash(git rev-parse *), Bash(ls *), Bash(cat *), Bash(head *), Bash(date *)
|
|
|
|
|
---
|
|
|
|
|
@@ -14,47 +14,30 @@ 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_PROJECT_ROOT/projects/claude-foundations/best-practices/.distill-state.json 2>/dev/null || echo "{}"`
|
|
|
|
|
|
|
|
|
|
### Settings
|
|
|
|
|
!`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_PROJECT_ROOT/projects/claude-foundations/BESTPRACTICES.md 2>/dev/null || echo "Index not found"`
|
|
|
|
|
|
|
|
|
|
### Available best-practices files
|
|
|
|
|
!`ls -1 $CLAUDE_PROJECT_ROOT/projects/claude-foundations/best-practices/ 2>/dev/null || echo "No best-practices directory"`
|
|
|
|
|
|
|
|
|
|
### Projects directory listing
|
|
|
|
|
!`ls -1d $CLAUDE_PROJECT_ROOT/projects/*/ 2>/dev/null || echo "No projects directory"`
|
|
|
|
|
### Pre-gathered context (read at runtime)
|
|
|
|
|
The following files should be read using the Read tool at the start of execution:
|
|
|
|
|
- `~/dev/claude/projects/claude-foundations/best-practices/.distill-state.json` — Distill state (if not found, treat as `{}`)
|
|
|
|
|
- `~/dev/claude/projects/claude-foundations/settings.yaml` — Settings (if not found, use defaults from instructions)
|
|
|
|
|
- `~/dev/claude/projects/claude-foundations/BESTPRACTICES.md` — Current best-practices index
|
|
|
|
|
- Use Glob to list `~/dev/claude/projects/claude-foundations/best-practices/*.md` for available topic files
|
|
|
|
|
- Use Glob to list `~/dev/claude/projects/*/` for the projects directory listing
|
|
|
|
|
|
|
|
|
|
## 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` (pre-gathered above, or read it now if Step 0 detected the root manually).
|
|
|
|
|
The project root is `~/dev/claude` (hardcoded — change at the top of the `!`command`` blocks if your layout differs).
|
|
|
|
|
|
|
|
|
|
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`.
|
|
|
|
|
Key paths:
|
|
|
|
|
- **Settings**: `~/dev/claude/projects/claude-foundations/settings.yaml`
|
|
|
|
|
- **Best practices dir**: `~/dev/claude/projects/claude-foundations/best-practices/`
|
|
|
|
|
- **Best practices index**: `~/dev/claude/projects/claude-foundations/BESTPRACTICES.md`
|
|
|
|
|
- **Distill state**: `~/dev/claude/projects/claude-foundations/best-practices/.distill-state.json`
|
|
|
|
|
|
|
|
|
|
Read `settings.yaml` (pre-gathered above).
|
|
|
|
|
|
|
|
|
|
For each project in `distill.projects`, get its path: `~/dev/claude/<projects_dir>/<project_name>`.
|
|
|
|
|
Also process any `distill.extra_projects` entries — these have a `path` field relative to `~/dev/claude`.
|
|
|
|
|
|
|
|
|
|
For each project (from both lists):
|
|
|
|
|
|
|
|
|
|
@@ -126,11 +109,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 `<PROJECT_ROOT>/projects/claude-foundations/BESTPRACTICES.md` with a one-line description
|
|
|
|
|
- Add it to `~/dev/claude/projects/claude-foundations/BESTPRACTICES.md` with a one-line description
|
|
|
|
|
|
|
|
|
|
### Step 6: Update distill state
|
|
|
|
|
|
|
|
|
|
Write `<PROJECT_ROOT>/projects/claude-foundations/best-practices/.distill-state.json`:
|
|
|
|
|
Write `~/dev/claude/projects/claude-foundations/best-practices/.distill-state.json`:
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
|