From e51570b8049b6590eeeeab2494b021c00e631a21 Mon Sep 17 00:00:00 2001 From: PeninsulaInd Date: Thu, 9 Apr 2026 11:06:34 -0500 Subject: [PATCH] Strip YAML frontmatter from skill files before passing to claude -p The leading --- in YAML frontmatter was being interpreted as a CLI option by `claude -p`, causing "unknown option" errors. Co-Authored-By: Claude Opus 4.6 (1M context) --- clickup_runner/claude_runner.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/clickup_runner/claude_runner.py b/clickup_runner/claude_runner.py index 8fef05c..9bb9fe5 100644 --- a/clickup_runner/claude_runner.py +++ b/clickup_runner/claude_runner.py @@ -1,5 +1,5 @@ """Claude Code subprocess runner. - +NEW WORKING CODE Builds prompts from skill files + task context, runs `claude -p`, collects output files, and returns structured results. """ @@ -286,9 +286,22 @@ def notify( log.warning("Failed to send ntfy notification: %s", e) +def _strip_frontmatter(text: str) -> str: + """Remove YAML frontmatter (--- ... ---) from a markdown file.""" + if not text.startswith("---"): + return text + end = text.find("---", 3) + if end == -1: + return text + return text[end + 3:].lstrip("\r\n") + + def read_skill_file(route: SkillRoute, skills_dir: Path) -> str: """Read a skill .md file and return its content. + Strips YAML frontmatter (skill registry metadata) since it's not + useful as prompt content and the leading --- breaks `claude -p`. + Raises FileNotFoundError if the skill file doesn't exist. """ skill_path = skills_dir / route.skill_file @@ -296,4 +309,5 @@ def read_skill_file(route: SkillRoute, skills_dir: Path) -> str: raise FileNotFoundError( "Skill file not found: %s" % skill_path ) - return skill_path.read_text(encoding="utf-8") + raw = skill_path.read_text(encoding="utf-8") + return _strip_frontmatter(raw)