<!-- Authored per the the-loop:writing skill. -->
Capability: prompts and strings
Every prompt the CLI sends to an agent is a Markdown file. Every catalogued human-facing message comes from one JSON file. Prose is edited as data, and the-loop can be localised without touching code.
What it is
Two small stdlib modules and two data directories inside the the_loop package:
| Piece | Path | Read with |
|---|---|---|
| prompt files | cli/the_loop/prompts/<area>/<name>.md | prompts.load(name), prompts.render(name, **slots) |
| string catalog | cli/the_loop/strings/en.json (+ <locale>.json) | strings.t(key, **vars), strings.section(prefix) |
Python call sites keep the logic: which fragment, in which order, under which condition. The words live in the files.
Current behaviour
Prompts
- The CLI SHALL keep every prompt and prompt fragment it sends to an agent harness as a
.mdfile undercli/the_loop/prompts/, read throughthe_loop.prompts. prompts.load(name)SHALL return the file verbatim.inline=Truedrops its one trailing newline, for a fragment joined into a line.- A prompt name SHALL be lowercase slash-separated segments (
graph-context/header). Any other name,..included, SHALL raiseValueError. - IF a prompt file is missing THEN the CLI SHALL raise
FileNotFoundErrornamingprompts/<name>.md. A blank prompt is never sent. - The webhook templates (
webhook/event.md,webhook/autoexecute.md) SHALL usestring.Template$slots, the syntax an operator'srouting.promptTemplateuses. Every other prompt SHALL usestr.format{slots}. Both are single-pass: a$xor{x}inside an untrusted value is inserted literally. skills/the-loop/templates/webhook-event-prompt.mdandwebhook-autoexecute-prompt.mdSHALL be byte-identical to the packaged webhook prompts. They are what operators read and copy, and a test pins them.- Prompt files are excluded from markdownlint. A prompt is a byte-for-byte contract, and a lint fix would change what the agent reads.
- A test (
cli/tests/test_prompts_guard.py) SHALL fail when a module defines a multi-line string constant whose name says it is a prompt (*PROMPT*,*DIRECTIVE*,*TEMPLATE*,*NOTICE*,*NUDGE*).
Areas today: webhook/, interaction/, graph-context/, assignment/, prnotice/, cimonitor/, attachments/, sessions/, standing/, selfdiagnosis/, mcp/, modelprobe/, codex/.
- MCP tool descriptions SHALL be
prompts/mcp/tools/<tool>.md, passed explicitly to the MCP SDK'sadd_tool. - The plugin's stop hook (
hooks/the-loop-gate.py) SHALL read its own text fromhooks/prompts/, beside the script, because it runs without the package:gate-feedback.md(the fallback's feedback),gate-attempt.md(the attempt count it adds under the service's refusal, issue-551) andgate-give-up.md. The refusal itself is the service's, fromcli/the_loop/prompts/stopcheck/.
Left in code, on purpose:
codex_support.conversation_marker. A machine token, matched back against Codex rollouts.- Graph hook messages and CLI envelopes. The agent reads them as CLI output, and they carry machine vocabulary.
- Prompts the caller supplies: critic prompts, standing-session briefs, API
promptfields.
Strings
cli/the_loop/strings/en.jsonSHALL be one flat JSON object of dotted keys (slack.title.decision-pending) to message text with named{fields}.strings.t(key, **vars)SHALL return the active locale's text forkey, falling back toen, formatted withvars. IFkeyis absent fromenTHEN it SHALL raiseKeyErrornaming the key.- The active locale SHALL be the one passed to
strings.set_locale, elseTHE_LOOP_LOCALE, elseen. A locale name SHALL match^[a-z]{2,3}([_-][A-Za-z0-9]{2,8})*$. - IF a locale's file is missing THEN lookups SHALL fall back to
ensilently. IF it is malformed THEN the CLI SHALL log one warning and fall back toen. Anen.jsonthat fails to parse SHALL raise. strings.section(prefix)SHALL return{suffix: text}for every key under the prefix. The migrated per-module dictionaries keep theirDict[str, str]shape this way. A module captures the locale active when it is imported.- Tests SHALL verify that every key the code looks up exists in
en.json, that every catalog entry is used, and that eachtcall passes exactly the fields its text uses.
What is catalogued: every human-facing string of the application:
- every comment, reply, notice, checklist and message body the-loop posts to GitHub, Slack or Jira;
- every user-facing CLI message (
printand stderr output,argparsehelp/description/epilog,parser.errorandSystemExittext); - every UI string (
ui.*keys, read byui/src/i18n.tsfrom the same file at build time).
What stays in code: machine vocabulary (markers, keywords, labels, event names, JSON field names, regexes, URLs), logger lines, and messages of exceptions raised for operators and developers. These are diagnostics, and they stay greppable.
- The UI's
t(key, vars)SHALL behave likestrings.t: single-pass{name}substitution, and a missing key throws.ui/src/i18n.test.tsSHALL verify that every key the UI uses exists and that everyui.*key is used.
Adding things
- A prompt: write
cli/the_loop/prompts/<area>/<name>.md, then callprompts.load("<area>/<name>")orprompts.render(...)where the text is used. - A message: add
"<module>.<what>.<code>": "…"toen.json, then callstrings.t("<module>.<what>.<code>", …). - A locale: add
cli/the_loop/strings/<locale>.jsonwith the keys you translate. Run withTHE_LOOP_LOCALE=<locale>.
Design
docs/specs/issue-540/design.md: the loader, the lookup, the inventory, and the security design (single-pass substitution, keys from code only).
History
| Work item | What changed | Links |
|---|---|---|
| issue-540 | Created: every prompt moved to Markdown files; every human-facing string of the CLI and the UI moved to the one string catalog | spec · #541 |