Skip to content

Custom Prompts

yaku ships with a tuned system prompt for translation. If you need full control over the LLM instructions, you can replace the built-in prompt entirely.

Terminal window
yaku --to en --prompt my-prompt.txt "Bonjour le monde"

The file content is sent as the system prompt. yaku reads the file as-is — no template variables or merging.

Terminal window
yaku config set prompt /path/to/my-prompt.txt

This applies to every translation until you remove it:

Terminal window
yaku config set prompt ""

A --prompt flag on the command line takes priority over the config value.

Your prompt replaces yaku’s entire system prompt. You are responsible for all instructions. At minimum, include:

  1. An instruction to output only the translated text (no explanations or commentary)
  2. An instruction to preserve paragraph structure and line breaks
  3. The target language (yaku still passes the text as the user message)
You are a professional translator specializing in software documentation.
Translate the user's input to the target language.
Rules:
- Output ONLY the translated text. No explanations, no wrapping quotes.
- Preserve paragraph structure and line breaks exactly.
- Keep code identifiers (variables, functions, file paths) in English.
- Keep brand names (GitHub, Docker, Kubernetes) unchanged.
- Use formal, precise language appropriate for technical documentation.

Save as my-prompt.txt and use:

Terminal window
yaku --to en --prompt my-prompt.txt -f docs.fr.md

When using --prompt, the following built-in behaviors are disabled:

  • Built-in translation rules — the 8-rule base prompt is not included.
  • Polish mode prompt--mode polish has no effect because the custom prompt replaces everything.
  • Format-specific rules — Markdown preservation rules are not appended (but JSON/YAML extraction still works — see below).
  • Context injection--context has no effect.

These features still work with a custom prompt:

  • Glossary keep-original enforcement — terms marked with ~ (keep original) are verified in the output after translation. However, glossary translation entries (term → translation) are not injected into a custom prompt.
  • JSON/YAML extraction — structured format handling is pre-processing, not prompt-based.
  • Output sanitization — LLM artifact cleanup runs on all output.
  • Domain-specific tone — tailor the prompt for legal, medical, or marketing content.
  • Strict output format — enforce specific formatting rules the default prompt does not cover.
  • Experimentation — test different prompt strategies to find what works best for your content.
  • Start from the built-in prompt. Read yaku’s source code (internal/prompt/system.go) to see the default rules, then modify from there.
  • Test with short text first. Verify your prompt produces clean output before running it on large files.
  • Keep the “output only” rule. Without it, the LLM tends to add explanations that pollute the output (though yaku’s sanitizer catches common patterns).