Files
last30days-skill/docs/plans/2026-03-03-fix-skill-md-argument-flag-forwarding-plan.md
Matt Van Horn 1d18bee1a2 fix(skill): forward CLI flags through $ARGUMENTS to Python script
Remove double quotes around $ARGUMENTS in SKILL.md so bash word-splits
the expansion, and change argparse topic from nargs="?" to nargs="*"
so multi-word topics still work. Also document --store, --include-web,
--diagnose, and --timeout flags in the Options section.

Closes #36

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 13:52:08 -08:00

3.6 KiB

title, type, status, date
title type status date
Fix SKILL.md Argument Flag Forwarding fix completed 2026-03-03

Fix SKILL.md Argument Flag Forwarding

Overview

"$ARGUMENTS" in SKILL.md wraps the entire user input in double quotes, making argparse treat flags like --store as part of the topic string instead of CLI flags.

Problem

SKILL.md line 168:

python3 "${SKILL_ROOT}/scripts/last30days.py" "$ARGUMENTS" --emit=compact --no-native-web

$ARGUMENTS is a Claude Code template variable replaced via string substitution before bash runs. The double quotes cause word-joining:

  • User types: /last30days AI video tools --store
  • Claude Code expands to: python3 script.py "AI video tools --store" --emit=compact
  • argparse sees: topic="AI video tools --store", --store never parsed

Proposed Solution

Two coordinated changes:

1. Remove quotes around $ARGUMENTS in SKILL.md

File: SKILL.md:168

# Before:
python3 "${SKILL_ROOT}/scripts/last30days.py" "$ARGUMENTS" --emit=compact --no-native-web

# After:
python3 "${SKILL_ROOT}/scripts/last30days.py" $ARGUMENTS --emit=compact --no-native-web

Now bash word-splits the expansion: python3 script.py AI video tools --store --emit=compact

2. Change argparse topic from nargs="?" to nargs="*"

File: scripts/last30days.py:1040

# Before:
parser.add_argument("topic", nargs="?", help="Topic to research")
# args.topic = "AI video tools" (single string) or None

# After:
parser.add_argument("topic", nargs="*", help="Topic to research")
# args.topic = ["AI", "video", "tools"] (list) or []

Then immediately after parser.parse_args() (line 1124), join the list back to a string:

args = parser.parse_args()
args.topic = " ".join(args.topic) if args.topic else None

Why this works for both invocation styles:

Invocation argparse receives topic result
script.py AI video tools --store (Claude Code) ["AI", "video", "tools"] + --store "AI video tools"
script.py "AI video tools" --store (direct CLI) ["AI video tools"] + --store "AI video tools"
script.py --store (no topic) [] + --store None

3. Document missing flags in SKILL.md Options section

File: SKILL.md:223-227

Add after the existing --deep line:

- `--store` -> Persist findings to SQLite database for later querying
- `--search=SOURCES` -> Comma-separated source filter (e.g., `--search=reddit,hn`)
- `--include-web` -> Include general web search alongside primary sources
- `--diagnose` -> Show source availability diagnostics and exit
- `--timeout=SECS` -> Global timeout in seconds (default: 180, quick: 90, deep: 300)

Note: --sort-x was listed in the issue but does not exist in the Python argparse. Skip it.

Acceptance Criteria

  • /last30days AI video tools --store correctly passes --store to Python script
  • /last30days AI video tools still works (multi-word topic without flags)
  • Direct CLI: python3 last30days.py "AI video tools" --store still works
  • --diagnose, --search=reddit,hn, --timeout=120 all forward correctly
  • All 5 missing flags documented in SKILL.md Options section
  • Existing tests pass (python3 -m pytest tests/)

Files Changed

File Change
SKILL.md:168 Remove quotes around $ARGUMENTS
scripts/last30days.py:1040 nargs="?" -> nargs="*"
scripts/last30days.py:1124 Add args.topic = " ".join(args.topic) if args.topic else None
SKILL.md:223-227 Add 5 missing flags to Options section

Sources