Skip to content

Commit 813aa76

Browse files
authored
Fix ask-codex shell quoting guidance (#39)
1 parent 6f620ce commit 813aa76

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

skills/ask-codex/SKILL.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,30 @@ Send a question or task to Codex and return the response.
1111

1212
## How to Use
1313

14-
Execute the ask-codex script with the user's arguments:
14+
Do not pass free-form user text to the shell unquoted. The question or task may contain spaces or shell metacharacters such as `(`, `)`, `;`, `#`, `*`, or `[`.
15+
16+
If the user only supplied a question or task, execute:
17+
18+
```bash
19+
"${CLAUDE_PLUGIN_ROOT}/scripts/ask-codex.sh" "$ARGUMENTS"
20+
```
21+
22+
If the user supplied flags such as `--codex-model` or `--codex-timeout`, reconstruct the command so those flags remain separate shell arguments and the remaining free-form question is passed as one quoted final argument.
23+
24+
Example:
25+
26+
```bash
27+
"${CLAUDE_PLUGIN_ROOT}/scripts/ask-codex.sh" --codex-model gpt-5.4:high "Review the following round summary (M4)..."
28+
```
29+
30+
Never run this unsafe form:
1531

1632
```bash
1733
"${CLAUDE_PLUGIN_ROOT}/scripts/ask-codex.sh" $ARGUMENTS
1834
```
1935

36+
because the shell will re-parse the question text and can fail before `ask-codex.sh` starts.
37+
2038
## Interpreting Output
2139

2240
- The script outputs Codex's response to **stdout** and status info to **stderr**

tests/test-ask-codex.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
1515
source "$SCRIPT_DIR/test-helpers.sh"
1616

1717
ASK_CODEX_SCRIPT="$SCRIPT_DIR/../scripts/ask-codex.sh"
18+
ASK_CODEX_SKILL="$SCRIPT_DIR/../skills/ask-codex/SKILL.md"
1819

1920
echo "=========================================="
2021
echo "Ask Codex Tests (mock)"
@@ -403,6 +404,35 @@ else
403404
fail "codex-run.cmd records the question"
404405
fi
405406

407+
# ========================================
408+
# Skill Guidance Tests
409+
# ========================================
410+
411+
echo ""
412+
echo "--- Skill Guidance Tests ---"
413+
echo ""
414+
415+
# Test: skill explicitly warns against unsafe bare $ARGUMENTS shell expansion
416+
if grep -Fq 'Never run this unsafe form' "$ASK_CODEX_SKILL" && grep -Fq '"${CLAUDE_PLUGIN_ROOT}/scripts/ask-codex.sh" $ARGUMENTS' "$ASK_CODEX_SKILL"; then
417+
pass "skill warns against bare \$ARGUMENTS shell expansion"
418+
else
419+
fail "skill warns against bare \$ARGUMENTS shell expansion" "explicit unsafe-form warning" "missing"
420+
fi
421+
422+
# Test: skill documents the safe quoted simple invocation
423+
if grep -Fq '"${CLAUDE_PLUGIN_ROOT}/scripts/ask-codex.sh" "$ARGUMENTS"' "$ASK_CODEX_SKILL"; then
424+
pass "skill quotes the question when no flags are present"
425+
else
426+
fail "skill quotes the question when no flags are present" "quoted simple invocation" "missing"
427+
fi
428+
429+
# Test: skill explains that free-form text must be a quoted final argument
430+
if grep -Fq 'one quoted final argument' "$ASK_CODEX_SKILL"; then
431+
pass "skill requires one quoted final argument for free-form text"
432+
else
433+
fail "skill requires one quoted final argument for free-form text" "quoted final argument guidance" "missing"
434+
fi
435+
406436
# ========================================
407437
# Summary
408438
# ========================================

0 commit comments

Comments
 (0)