Skip to content

Commit b5633aa

Browse files
authored
fix(skills): migrate ${CLAUDE_SKILL_DIR} script guards to the portable SKILL_DIR anchor (#1010)
1 parent b1d9344 commit b5633aa

4 files changed

Lines changed: 41 additions & 30 deletions

File tree

skills/ce-resolve-pr-feedback/references/full-mode.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ gh pr view --json number -q .number
1212
Then fetch all feedback using the GraphQL script at [scripts/get-pr-comments](../scripts/get-pr-comments):
1313

1414
```bash
15-
if [ -n "${CLAUDE_SKILL_DIR}" ] && [ -f "${CLAUDE_SKILL_DIR}/scripts/get-pr-comments" ]; then
16-
SCRIPT_DIR="${CLAUDE_SKILL_DIR}/scripts"
17-
else
18-
echo "ce-resolve-pr-feedback bundled scripts are unavailable in this harness; use the fallback gh commands below." >&2
15+
# SKILL_DIR = the absolute directory you loaded the ce-resolve-pr-feedback SKILL.md from.
16+
# The Bash tool's CWD is the user's project, not the skill dir, and shell state does not
17+
# persist between Bash calls — set SKILL_DIR in each block below that runs a bundled script.
18+
SKILL_DIR="<absolute path of the directory containing the ce-resolve-pr-feedback SKILL.md>"
19+
SCRIPT_DIR="$SKILL_DIR/scripts"
20+
if [ ! -f "$SCRIPT_DIR/get-pr-comments" ]; then
21+
echo "ce-resolve-pr-feedback bundled scripts not found under $SCRIPT_DIR; use the fallback gh commands below." >&2
1922
exit 1
2023
fi
2124

@@ -170,10 +173,10 @@ For `needs-human` verdicts, post the reply but do NOT resolve the thread. Leave
170173

171174
0. **Verify the thread ID** before replying. GitHub Enterprise can return inconsistent node IDs for the same thread depending on the query path. Always confirm the ID from `get-pr-comments` resolves to the correct thread using [scripts/get-thread-for-comment](../scripts/get-thread-for-comment) with the comment's numeric URL ID:
172175
```bash
173-
if [ -n "${CLAUDE_SKILL_DIR}" ] && [ -f "${CLAUDE_SKILL_DIR}/scripts/get-thread-for-comment" ]; then
174-
SCRIPT_DIR="${CLAUDE_SKILL_DIR}/scripts"
175-
else
176-
echo "ce-resolve-pr-feedback bundled scripts are unavailable in this harness; use gh api to inspect the review thread." >&2
176+
SKILL_DIR="<absolute path of the directory containing the ce-resolve-pr-feedback SKILL.md>"
177+
SCRIPT_DIR="$SKILL_DIR/scripts"
178+
if [ ! -f "$SCRIPT_DIR/get-thread-for-comment" ]; then
179+
echo "ce-resolve-pr-feedback bundled scripts not found under $SCRIPT_DIR; use gh api to inspect the review thread." >&2
177180
exit 1
178181
fi
179182

@@ -185,10 +188,10 @@ The returned `id` is the authoritative thread ID to use for reply and resolve. I
185188

186189
1. **Reply** using [scripts/reply-to-pr-thread](../scripts/reply-to-pr-thread):
187190
```bash
188-
if [ -n "${CLAUDE_SKILL_DIR}" ] && [ -f "${CLAUDE_SKILL_DIR}/scripts/reply-to-pr-thread" ]; then
189-
SCRIPT_DIR="${CLAUDE_SKILL_DIR}/scripts"
190-
else
191-
echo "ce-resolve-pr-feedback bundled scripts are unavailable in this harness; post the reply with gh api or gh pr comment as appropriate." >&2
191+
SKILL_DIR="<absolute path of the directory containing the ce-resolve-pr-feedback SKILL.md>"
192+
SCRIPT_DIR="$SKILL_DIR/scripts"
193+
if [ ! -f "$SCRIPT_DIR/reply-to-pr-thread" ]; then
194+
echo "ce-resolve-pr-feedback bundled scripts not found under $SCRIPT_DIR; post the reply with gh api or gh pr comment as appropriate." >&2
192195
exit 1
193196
fi
194197

@@ -198,10 +201,10 @@ Check that the returned comment URL contains the correct `OWNER/REPO` and PR num
198201

199202
2. **Resolve** using [scripts/resolve-pr-thread](../scripts/resolve-pr-thread):
200203
```bash
201-
if [ -n "${CLAUDE_SKILL_DIR}" ] && [ -f "${CLAUDE_SKILL_DIR}/scripts/resolve-pr-thread" ]; then
202-
SCRIPT_DIR="${CLAUDE_SKILL_DIR}/scripts"
203-
else
204-
echo "ce-resolve-pr-feedback bundled scripts are unavailable in this harness; resolve the thread with gh api if supported." >&2
204+
SKILL_DIR="<absolute path of the directory containing the ce-resolve-pr-feedback SKILL.md>"
205+
SCRIPT_DIR="$SKILL_DIR/scripts"
206+
if [ ! -f "$SCRIPT_DIR/resolve-pr-thread" ]; then
207+
echo "ce-resolve-pr-feedback bundled scripts not found under $SCRIPT_DIR; resolve the thread with gh api if supported." >&2
205208
exit 1
206209
fi
207210

@@ -223,10 +226,10 @@ Include enough quoted context in the reply so the reader can follow which commen
223226
Re-fetch feedback to confirm resolution:
224227

225228
```bash
226-
if [ -n "${CLAUDE_SKILL_DIR}" ] && [ -f "${CLAUDE_SKILL_DIR}/scripts/get-pr-comments" ]; then
227-
SCRIPT_DIR="${CLAUDE_SKILL_DIR}/scripts"
228-
else
229-
echo "ce-resolve-pr-feedback bundled scripts are unavailable in this harness; use the fallback gh commands from Step 1." >&2
229+
SKILL_DIR="<absolute path of the directory containing the ce-resolve-pr-feedback SKILL.md>"
230+
SCRIPT_DIR="$SKILL_DIR/scripts"
231+
if [ ! -f "$SCRIPT_DIR/get-pr-comments" ]; then
232+
echo "ce-resolve-pr-feedback bundled scripts not found under $SCRIPT_DIR; use the fallback gh commands from Step 1." >&2
230233
exit 1
231234
fi
232235

skills/ce-resolve-pr-feedback/references/targeted-mode.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ gh api repos/OWNER/REPO/pulls/comments/COMMENT_ID \
1717

1818
**Step 2** -- Map comment to its thread ID. Use [scripts/get-thread-for-comment](../scripts/get-thread-for-comment):
1919
```bash
20-
if [ -n "${CLAUDE_SKILL_DIR}" ] && [ -f "${CLAUDE_SKILL_DIR}/scripts/get-thread-for-comment" ]; then
21-
SCRIPT_DIR="${CLAUDE_SKILL_DIR}/scripts"
22-
else
23-
echo "ce-resolve-pr-feedback bundled scripts are unavailable in this harness; use Full Mode's fallback gh commands to inspect the PR comments." >&2
20+
# SKILL_DIR = the absolute directory you loaded the ce-resolve-pr-feedback SKILL.md from
21+
# (the Bash tool's CWD is the user's project, not the skill dir; shell state does not
22+
# persist between Bash calls, so always set it before calling a bundled script).
23+
SKILL_DIR="<absolute path of the directory containing the ce-resolve-pr-feedback SKILL.md>"
24+
SCRIPT_DIR="$SKILL_DIR/scripts"
25+
if [ ! -f "$SCRIPT_DIR/get-thread-for-comment" ]; then
26+
echo "ce-resolve-pr-feedback bundled scripts not found under $SCRIPT_DIR; use Full Mode's fallback gh commands to inspect the PR comments." >&2
2427
exit 1
2528
fi
2629

skills/ce-setup/SKILL.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ Before running the script, display:
2828
Compound Engineering -- checking your environment...
2929
```
3030

31-
Run the bundled check script when the skill directory can be resolved:
31+
Run the bundled check script. Set `SKILL_DIR` to the absolute directory you loaded this `ce-setup` SKILL.md from — the Bash tool's CWD is the user's project, not the skill dir, so a bare `scripts/` path will not resolve:
3232

3333
```bash
34-
if [ -n "${CLAUDE_SKILL_DIR}" ] && [ -f "${CLAUDE_SKILL_DIR}/scripts/check-health" ]; then
35-
bash "${CLAUDE_SKILL_DIR}/scripts/check-health" --version VERSION
34+
SKILL_DIR="<absolute path of the directory containing this SKILL.md>"
35+
if [ -f "$SKILL_DIR/scripts/check-health" ]; then
36+
bash "$SKILL_DIR/scripts/check-health" --version VERSION
3637
else
37-
echo "Bundled health script is unavailable on this platform; run the inline checks from ce-setup instead."
38+
echo "Bundled health script not found at $SKILL_DIR/scripts/check-health; run the inline checks from ce-setup instead."
3839
fi
3940
```
4041

tests/skills/ce-resolve-pr-feedback-script-dir.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ describe("ce-resolve-pr-feedback script directory handling", () => {
2323

2424
expect(scriptDirBlocks.length).toBeGreaterThan(0)
2525
for (const block of scriptDirBlocks) {
26-
expect(block).toContain('if [ -n "${CLAUDE_SKILL_DIR}" ]')
27-
expect(block).toContain('SCRIPT_DIR="${CLAUDE_SKILL_DIR}/scripts"')
26+
// Each block must self-resolve the skill dir locally (shell state does not persist
27+
// between Bash calls), via the portable model-filled SKILL_DIR anchor — not the
28+
// Claude-only ${CLAUDE_SKILL_DIR} substitution.
29+
expect(block).toContain('SKILL_DIR="')
30+
expect(block).toContain('SCRIPT_DIR="$SKILL_DIR/scripts"')
31+
expect(block).not.toContain("CLAUDE_SKILL_DIR")
2832
}
2933
})
3034
})

0 commit comments

Comments
 (0)