Skip to content

feat(mentat): improve skill generation prompt#22

Closed
bketelsen wants to merge 1 commit intomainfrom
mentat/writing-skills-prompt
Closed

feat(mentat): improve skill generation prompt#22
bketelsen wants to merge 1 commit intomainfrom
mentat/writing-skills-prompt

Conversation

@bketelsen
Copy link
Copy Markdown
Contributor

Summary

Rewrites buildPrompt() in the mentat generator based on Anthropic's skill authoring best practices, and simplifies normaliseContent().

Changes

buildPrompt() — ~50% shorter, example-driven

  • Before: verbose, listed 5 section names explicitly, gave lengthy instructions the model ignores
  • After: concise task description + one concrete one-shot example (queue domain); trusts the model to choose structure
  • Domain context condensed to a single dense header line
  • Frontmatter requirement stated clearly with the domain name pre-filled
  • Explicit instruction: only include what the agent can't infer from reading the code

normaliseContent() — simplified

  • Removed the fragile \n---\n heuristic that could silently truncate mid-document content (e.g. when a horizontal rule appears in the body)
  • Retained: code-fence stripping, trailing stats-line stripping, single-newline normalisation
  • Frontmatter injection still handled by generateWith (unchanged)

New tests: generator_internal_test.go

14 unit tests covering:

  • All prompt properties (domain fields, frontmatter template, example, no rigid section headers, file sample inclusion, empty-sample guard, multi-language formatting)
  • All normaliser edge cases (code fences, stats lines, mid-document HR regression, empty input, trailing newline invariant)

Verification

just test   # all packages pass
just build-mentat  # exit 0

… practices

- Rewrite buildPrompt(): ~50% shorter, example-driven, no prescriptive section
  headers. One-shot 'queue' domain example shows the target quality. Domain
  context condensed to a single header line.
- Simplify normaliseContent(): remove fragile \n---\n mid-content heuristic;
  keep code-fence stripping and trailing stats-line stripping.
- Add generator_internal_test.go: 14 new unit tests covering all prompt
  properties (domain context, frontmatter, example presence, no rigid sections,
  empty-sample guard) and all normaliser edge cases (fences, stats, mid-HR,
  empty input, trailing newline).

Exec plan: docs/exec-plans/completed/mentat-writing-skills-prompt.md
@bketelsen bketelsen closed this Apr 30, 2026
@bketelsen bketelsen deleted the mentat/writing-skills-prompt branch April 30, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant