Skip to content

Commit b1d9344

Browse files
authored
fix(skills): anchor bundled-script calls to the loaded skill dir (#1009)
1 parent 5e7d413 commit b1d9344

5 files changed

Lines changed: 55 additions & 16 deletions

File tree

skills/ce-optimize/SKILL.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,13 @@ mkdir -p .context/compound-engineering/ce-optimize/<spec-name>/
251251

252252
**This phase is a HARD GATE. The user must approve baseline and parallel readiness before Phase 2.**
253253

254+
**Bundled scripts.** Phases 1 and 3 call helper scripts that ship in this skill's `scripts/` directory (`measure.sh`, `parallel-probe.sh`, `experiment-worktree.sh`). The Bash tool's working directory is the user's project, not the skill directory, so a bare `scripts/<name>` path will not resolve — invoke each by the skill's own absolute path. Every runnable block below already sets `SKILL_DIR` inline (shell state does not persist between Bash tool calls, so each block must carry it); just replace the `<absolute path …>` placeholder with the directory you loaded this `ce-optimize` SKILL.md from before running. The shape:
255+
256+
```bash
257+
SKILL_DIR="<absolute path of the directory containing this SKILL.md>"
258+
bash "$SKILL_DIR/scripts/<name>"
259+
```
260+
254261
### 1.1 Clean-Tree Gate
255262

256263
Verify no uncommitted changes to files within `scope.mutable` or `scope.immutable`:
@@ -269,7 +276,8 @@ Filter the output against the scope paths. If any in-scope files have uncommitte
269276
**If user provides a measurement harness** (the `measurement.command` already exists):
270277
1. Run it once via the measurement script:
271278
```bash
272-
bash scripts/measure.sh "<measurement.command>" <timeout_seconds> "<measurement.working_directory or .>"
279+
SKILL_DIR="<absolute path of the directory containing this SKILL.md>"
280+
bash "$SKILL_DIR/scripts/measure.sh" "<measurement.command>" <timeout_seconds> "<measurement.working_directory or .>"
273281
```
274282
2. Validate the JSON output:
275283
- Contains keys for all degenerate gate metric names
@@ -312,7 +320,8 @@ If primary type is `judge`, also run the judge evaluation on baseline output to
312320

313321
Run the parallelism probe script:
314322
```bash
315-
bash scripts/parallel-probe.sh "<project_directory>" "<measurement.command>" "<measurement.working_directory>" <shared_files...>
323+
SKILL_DIR="<absolute path of the directory containing this SKILL.md>"
324+
bash "$SKILL_DIR/scripts/parallel-probe.sh" "<project_directory>" "<measurement.command>" "<measurement.working_directory>" <shared_files...>
316325
```
317326

318327
Read the JSON output. Present any blockers to the user with suggested mitigations. Treat the probe as intentionally narrow: it should inspect the measurement command, the measurement working directory, and explicitly declared shared files, not the entire repository.
@@ -321,7 +330,8 @@ Read the JSON output. Present any blockers to the user with suggested mitigation
321330

322331
Count existing worktrees:
323332
```bash
324-
bash scripts/experiment-worktree.sh count
333+
SKILL_DIR="<absolute path of the directory containing this SKILL.md>"
334+
bash "$SKILL_DIR/scripts/experiment-worktree.sh" count
325335
```
326336

327337
If count + `execution.max_concurrent` would exceed 12:
@@ -437,10 +447,13 @@ If the backlog is non-empty but no runnable hypotheses remain because everything
437447

438448
For each hypothesis in the batch, dispatch according to `execution.mode`. In `serial` mode, run exactly one experiment to completion before selecting the next hypothesis. In `parallel` mode, dispatch the full batch concurrently.
439449

450+
The Phase 3 blocks below each set `SKILL_DIR` inline as well (the loaded `ce-optimize` skill directory; see the Bundled scripts note in Phase 1) — shell state does not persist from Phase 1, so each block carries its own assignment.
451+
440452
**Worktree backend:**
441453
1. Create experiment worktree:
442454
```bash
443-
WORKTREE_PATH=$(bash scripts/experiment-worktree.sh create "<spec_name>" <exp_index> "optimize/<spec_name>" <shared_files...>) # creates optimize-exp/<spec_name>/exp-<NNN>
455+
SKILL_DIR="<absolute path of the directory containing this SKILL.md>"
456+
WORKTREE_PATH=$(bash "$SKILL_DIR/scripts/experiment-worktree.sh" create "<spec_name>" <exp_index> "optimize/<spec_name>" <shared_files...>) # creates optimize-exp/<spec_name>/exp-<NNN>
444457
```
445458
2. Apply port parameterization if configured (set env vars for the measurement script)
446459
3. Fill the experiment prompt template (`references/experiment-prompt-template.md`) with:
@@ -474,7 +487,8 @@ For each completed experiment, **immediately**:
474487

475488
1. **Run measurement** in the experiment's worktree:
476489
```bash
477-
bash scripts/measure.sh "<measurement.command>" <timeout_seconds> "<worktree_path>/<measurement.working_directory or .>" <env_vars...>
490+
SKILL_DIR="<absolute path of the directory containing this SKILL.md>"
491+
bash "$SKILL_DIR/scripts/measure.sh" "<measurement.command>" <timeout_seconds> "<worktree_path>/<measurement.working_directory or .>" <env_vars...>
478492
```
479493
- If stability mode is `repeat`, run the measurement harness `repeat_count` times in that working directory and aggregate the results exactly as in Phase 1 before evaluating gates or ranking the experiment.
480494
- Use the aggregated metrics as the experiment's score; if variance exceeds `noise_threshold`, record that in learnings so the operator knows the result is noisy.

skills/ce-polish/SKILL.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,25 @@ Start the dev server, open the feature in a browser, and iterate. You use the fe
1717

1818
## Phase 1: Start the dev server
1919

20+
The scripts below ship in this skill's `scripts/` directory. The Bash tool's working directory is the user's project, not the skill directory, so a bare `scripts/<name>` path will not resolve — invoke each by the skill's own absolute path. Every runnable block below sets `SKILL_DIR` inline (shell state does not persist between Bash tool calls, so each command must carry it); replace the `<absolute path …>` placeholder with the directory you loaded this `ce-polish` SKILL.md from before running.
21+
2022
### 1.1 Check for `.claude/launch.json`
2123

22-
Run `bash scripts/read-launch-json.sh`. If it finds a configuration, use it — the user already told us how to start the project.
24+
```bash
25+
SKILL_DIR="<absolute path of the directory containing this SKILL.md>"
26+
bash "$SKILL_DIR/scripts/read-launch-json.sh"
27+
```
28+
29+
If it finds a configuration, use it — the user already told us how to start the project.
2330

2431
### 1.2 Auto-detect (when no launch.json)
2532

26-
Run `bash scripts/detect-project-type.sh` to identify the framework.
33+
Identify the framework:
34+
35+
```bash
36+
SKILL_DIR="<absolute path of the directory containing this SKILL.md>"
37+
bash "$SKILL_DIR/scripts/detect-project-type.sh"
38+
```
2739

2840
Route by type to the matching recipe reference for start command and port defaults:
2941

@@ -39,9 +51,19 @@ Route by type to the matching recipe reference for start command and port defaul
3951
| `procfile` | `references/dev-server-procfile.md` |
4052
| `unknown` | Ask the user how to start the project |
4153

42-
For framework types that need a package manager, run `bash scripts/resolve-package-manager.sh` and substitute the result into the start command.
54+
For framework types that need a package manager, run the resolver and substitute the result into the start command:
4355

44-
Resolve the port with `bash scripts/resolve-port.sh --type <type>`.
56+
```bash
57+
SKILL_DIR="<absolute path of the directory containing this SKILL.md>"
58+
bash "$SKILL_DIR/scripts/resolve-package-manager.sh"
59+
```
60+
61+
Resolve the port:
62+
63+
```bash
64+
SKILL_DIR="<absolute path of the directory containing this SKILL.md>"
65+
bash "$SKILL_DIR/scripts/resolve-port.sh" --type <type>
66+
```
4567

4668
### 1.3 Start the server
4769

@@ -82,7 +104,7 @@ Reference files (loaded on demand):
82104
- `references/dev-server-sveltekit.md` — SvelteKit dev-server defaults
83105
- `references/dev-server-procfile.md` — Procfile-based dev-server defaults
84106

85-
Scripts (invoked via `bash scripts/<name>`):
107+
Scripts (invoked via `bash "$SKILL_DIR/scripts/<name>"` — see Phase 1 for `SKILL_DIR`):
86108
- `scripts/read-launch-json.sh` — launch.json reader
87109
- `scripts/detect-project-type.sh` — project-type classifier
88110
- `scripts/resolve-package-manager.sh` — lockfile-based package-manager resolver

skills/ce-riffrec-feedback-analysis/SKILL.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ When the input is ambiguous (e.g., a zip arrived without context), inspect the r
2525

2626
## Analyzer entrypoint
2727

28-
All non-setup paths share the same analyzer:
28+
All non-setup paths share the same analyzer, which ships in this skill's `scripts/` directory. The Bash tool's working directory is the user's project, not the skill directory, so a bare `scripts/<name>` path will not resolve. Invoke it by the skill's own absolute path: set `SKILL_DIR` to the directory you loaded this `ce-riffrec-feedback-analysis` SKILL.md from, in the same command (shell state does not persist between Bash calls):
2929

3030
```bash
31-
python scripts/analyze_riffrec_zip.py /path/to/input
31+
SKILL_DIR="<absolute path of the directory containing this SKILL.md>"
32+
python "$SKILL_DIR/scripts/analyze_riffrec_zip.py" /path/to/input
3233
```
3334

3435
Accepted inputs: a Riffrec `.zip`, an `.mp4` / `.mov` / `.webm` video, an `.m4a` / `.mp3` / `.wav` audio file, or a meeting-notes `.md`. Use `--output-dir <dir>` to control where artifacts land. In repos with `docs/brainstorms/`, the default is `docs/brainstorms/riffrec-feedback/`. The quick path overrides the output dir to a temp location so nothing pollutes the repo.

skills/ce-riffrec-feedback-analysis/references/extensive-analysis.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ Use this path when the input is a longer recording (over ~60 seconds), contains
44

55
## Workflow
66

7-
1. Run the analyzer:
7+
1. Run the analyzer (`SKILL_DIR` is the directory containing the `ce-riffrec-feedback-analysis` SKILL.md; set it in the same command — shell state does not persist between Bash calls):
88

99
```bash
10-
python scripts/analyze_riffrec_zip.py /path/to/input
10+
SKILL_DIR="<absolute path of the directory containing the ce-riffrec-feedback-analysis SKILL.md>"
11+
python "$SKILL_DIR/scripts/analyze_riffrec_zip.py" /path/to/input
1112
```
1213

1314
Use `--output-dir <dir>` when the artifact should live somewhere specific. In a repo with `docs/brainstorms/`, the default output goes under `docs/brainstorms/riffrec-feedback/`.

skills/ce-riffrec-feedback-analysis/references/quick-bug-report.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ Use this path when the input is a short recording (under ~60 seconds), the user
44

55
## Workflow
66

7-
1. Run the analyzer to a temp directory so nothing pollutes the repo:
7+
1. Run the analyzer to a temp directory so nothing pollutes the repo (`SKILL_DIR` is the directory containing the `ce-riffrec-feedback-analysis` SKILL.md; set it in the same command — shell state does not persist between Bash calls):
88

99
```bash
10-
python scripts/analyze_riffrec_zip.py /path/to/input --output-dir "$(mktemp -d -t riffrec-quick-XXXXXX)"
10+
SKILL_DIR="<absolute path of the directory containing the ce-riffrec-feedback-analysis SKILL.md>"
11+
python "$SKILL_DIR/scripts/analyze_riffrec_zip.py" /path/to/input --output-dir "$(mktemp -d -t riffrec-quick-XXXXXX)"
1112
```
1213

1314
Capture the printed output directory; later steps read from it.

0 commit comments

Comments
 (0)