Skip to content

feat: add claude-native prompt format support with frontmatter stripping#134

Merged
l50 merged 2 commits into
mainfrom
claude-native-prompt-format
Jul 2, 2026
Merged

feat: add claude-native prompt format support with frontmatter stripping#134
l50 merged 2 commits into
mainfrom
claude-native-prompt-format

Conversation

@l50

@l50 l50 commented Jul 2, 2026

Copy link
Copy Markdown
Member

Key Changes:

  • Introduced stripPromptFrontmatter to detect and remove YAML frontmatter from Claude-native prompt files, preventing template rendering for those agents
  • When a frontmatter block is detected, all prompt files (system, wrapper, task) bypass Go template processing so literal {{...}} syntax survives verbatim
  • Replaced curl|sh golangci-lint installation with go install in CI workflows for checksum-verified, reproducible builds

Added:

  • Frontmatter stripping logic - stripPromptFrontmatter in agent/bundle.go handles both LF and CRLF line endings, returns the body after the closing --- fence and a boolean indicating detection; unterminated or mid-document fences fall back gracefully
  • Claude-native mode bypass in loadAndProcessPrompts - when frontmatter is detected on the entrypoint, all three prompt files are returned raw without template execution, allowing prompt files to be shared verbatim with Claude Code
  • Comprehensive test coverage in agent/frontmatter_test.go covering frontmatter stripping edge cases (CRLF, unterminated, mid-document horizontal rules), Claude-native mode end-to-end, and legacy template rendering regression

Changed:

  • golangci-lint installation in .github/workflows/pre-commit.yaml and .github/workflows/renovate.yaml - replaced curl | sh script with go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.4 so the Go module checksum database verifies the binary instead of trusting a remote shell script

…tection

**Added:**

- `stripPromptFrontmatter` function that detects and strips YAML frontmatter from prompt files, enabling support for Claude Code's native dual-host prompt file format - `agent/bundle.go`
- Early-return path in `loadAndProcessPrompts` that bypasses all Go template rendering when a frontmatter block is detected, preserving literal `{{...}}` syntax (e.g. Taskfile examples) verbatim in system, wrapper, and task prompts
- Comprehensive test suite in `agent/frontmatter_test.go` covering frontmatter stripping edge cases (CRLF fences, unterminated blocks, mid-document horizontal rules), Claude-native mode (no template rendering, frontmatter dropped), and legacy template mode (Go template rendering still works as before)

**Changed:**

- Expanded doc comment on `loadAndProcessPrompts` to explain the Claude-native exception: frontmatter-marked entrypoints skip template rendering entirely, with mode still delivered via the `Mode:` header in `buildSystemMessage` - `agent/bundle.go`
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

**Changed:**

- Switched `golangci-lint` installation from `curl | sh` to `go install` in both `pre-commit.yaml` and `renovate.yaml` workflows - `go install` verifies the binary via the Go module checksum database, eliminating the risk of transient checksum mismatches from the shell installer
@github-actions github-actions Bot added the area/github Changes made to GitHub Actions workflows label Jul 2, 2026
@l50 l50 changed the title feat: add claude-native prompt format support via yaml frontmatter detection feat: add claude-native prompt format support with frontmatter stripping Jul 2, 2026
@l50 l50 merged commit 7367f87 into main Jul 2, 2026
5 checks passed
@l50 l50 deleted the claude-native-prompt-format branch July 2, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/github Changes made to GitHub Actions workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant