<!-- Authored per the the-loop:writing skill. -->
Requirements: prompts in Markdown files, application strings in one JSON catalog
Phase 1 of 4 (requirements → design → testing plan → tasks). Tier 3 (
human-approves-pr).requirements-approvalanddesign-approvalwere skipped at phase-selection, so the pull-request approval is the one human gate — the scope decision below is surfaced there for the reviewer.
Introduction
Issue #540 asks for two things:
- every prompt, or fragment of a prompt, that the-loop sends to an LLM lives in a Markdown file, not in a Python string literal;
- the application's strings come from one JSON file, so the-loop can be internationalised and localised.
What is wrong today. The CLI (cli/the_loop, ~100k lines) builds its prompts from inline literals: webhook/dispatcher.py keeps DEFAULT_PROMPT_TEMPLATE and DEFAULT_SPAWN_TEMPLATE as hand-synced mirrors of skills/the-loop/templates/webhook-*-prompt.md, interaction.py holds the interaction directives, and further prompt text is spread across the standing-session boot prompt, self-diagnosis, critic review and the notices pasted into live sessions. A prompt edit is a code edit, and the mirrors drift. Human-facing message text — refusal reasons, notice phrases, Slack titles and button names — sits in per-module dictionaries, with nowhere a translator could work.
What this changes.
- Prompts become files. Every LLM-bound prompt and fragment the CLI composes is a Markdown file under the package's
prompts/directory, read through one loader. No Python module keeps a copy. - One string catalog.
strings/en.jsonis the single source of human-facing message text, read through one lookup with named placeholders and a locale fallback. - The whole application, in this pull request. Every prompt, every message the-loop posts to people (GitHub, Slack and Jira comments, notices, checklists), every user-facing CLI message (stdout and stderr output,
argparsehelp), and every UI string moves. The owner rejected an earlier split into follow-up items (PR #541 comment). Tests keep new prompts and catalog entries from being written inline again.
Requirements
Requirement 1 — Prompts live in Markdown files
User story: As a maintainer of the-loop, I want every prompt the CLI sends to an agent to be a Markdown file, so that I can read, review and edit prompts as documents rather than as Python string literals.
Acceptance criteria (EARS)
- The system SHALL keep every prompt and prompt fragment that the CLI sends to an agent harness — spawn and event prompts, interaction directives, the standing-session boot prompt, self-diagnosis and critic prompts, and the notices and nudges pasted into a live session, and the MCP server's tool descriptions — as a
.mdfile undercli/the_loop/prompts/. The plugin's stop hook (hooks/the-loop-gate.py), which runs without the package installed, SHALL read its feedback text from a.mdfile shipped beside it. - WHEN the CLI composes a prompt THEN the system SHALL read its text through a single loader module, never from a Python string literal holding the prompt's prose.
- WHEN a prompt has variable parts THEN the system SHALL fill them through named placeholders declared in the Markdown file, with the substitution semantics each call site has today (
string.Template$nameslots for the webhook templates). - The system SHALL produce byte-identical rendered prompts to today's for the same inputs, except where the design names a deliberate wording change.
- The system SHALL ship the
prompts/files inside the installed wheel and sdist, so an installed CLI renders the same prompts as a checkout. - WHERE a prompt is also published as a skill template (
skills/the-loop/templates/webhook-event-prompt.md,webhook-autoexecute-prompt.md) THEN the system SHALL keep exactly one source of its text, and a test SHALL fail if the two copies differ. - IF a prompt file is missing or unreadable at runtime THEN the system SHALL raise an error naming the file, rather than sending an empty or partial prompt.
Requirement 2 — One JSON catalog for application strings
User story: As a translator or operator, I want the-loop's human-facing messages in one JSON file keyed by stable identifiers, so that I can localise the-loop without editing code.
Acceptance criteria (EARS)
- The system SHALL keep one string catalog,
cli/the_loop/strings/en.json, mapping stable dotted keys to message text with named{placeholder}variables. - WHEN code needs a migrated human-facing message THEN the system SHALL obtain it through one lookup function,
strings.t(key, **vars). - WHERE a locale is selected and its catalog (
strings/<locale>.json) lacks a key THEN the system SHALL fall back to theentext for that key. - IF a key is absent from the
encatalog THEN the system SHALL raise an error naming the key — a missing string is a bug, not a blank message. - The system SHALL take from the catalog every human-facing string of the application, rendering the same text as today:
- every comment, reply, notice, checklist and message body the CLI posts to GitHub, Slack or Jira;
- every user-facing CLI message:
printand stderr output,argparsehelp/description/epilog,parser.errortext andSystemExitmessages; - every user-visible string in the UI (
ui/src), which reads the sameen.jsonunderui.*keys.
- A test SHALL verify that every key the code looks up exists in
en.json, that the catalog is valid JSON with string values only, and that each entry's placeholders match the variables its call sites pass. - The system SHALL keep in code, and only in code: machine vocabulary (markers, keywords, labels, event names, JSON field names, regular expressions, URLs),
loggerlines, and messages of exceptions raised for operators and developers. These are diagnostics, not application strings, and they stay greppable.
Requirement 3 — The rule holds for new code
User story: As a reviewer, I want a failing test when someone adds a prompt or a catalog-style message inline again, so that the migration does not erode.
Acceptance criteria (EARS)
- WHEN a Python module under
cli/the_loopdefines a multi-line string literal that the guard recognises as prompt prose THEN the test suite SHALL fail, naming the module and line. - WHEN the UI's catalog lookup is given a key absent from
en.jsonTHEN the UI test suite SHALL fail, and everyui.*key inen.jsonSHALL be used by the UI. - The system SHALL document both conventions — where prompts live and how strings are looked up — in the capability docs and in the contributor guidance read by agents working on this repository.
Non-functional requirements
- No new runtime dependency. Loading uses the standard library (
importlib.resources,json,string.Template); the CLI's dependency list is unchanged. - Cost. Each file is read once per process and cached; a prompt render costs no more disk reads after the first.
- Operator overrides unchanged.
routing.promptTemplateandrouting.spawnTemplatekeep working as today; the built-in default they fall back to becomes the packaged Markdown file.
Security considerations
- Actors & trust: prompt and catalog files are part of the shipped package, written by maintainers — trusted. Untrusted actors are unchanged: webhook payloads, ticket bodies and comments, and Slack/Jira messages that reach the prompt slots (
$payload_excerptand friends). - Trust boundaries & data: the boundary that matters is between untrusted payload text and prompt instructions. Today's templates label the payload excerpt as untrusted and render the interaction directive above it, with no interpolation into the directive. Moving text to files must keep that order and that labelling. No secret, token or personal data is stored in either file type.
- Abuse cases (EARS):
- WHEN an untrusted payload contains
$nameor{name}sequences THEN the system SHALL insert it literally, never expand it as a further placeholder (single-pass substitution, as today). - WHEN an untrusted value is passed to
strings.tTHEN the system SHALL treat it as a value only; catalog lookup keys SHALL come from code, never from input. - WHEN an operator's custom template omits
$interaction_directiveTHEN the system SHALL still append the directive (today'sapply_directivefail-safe holds).
- WHEN an untrusted payload contains
- Fail closed: a missing prompt file or catalog key raises rather than sending a prompt or posting a message with its instructions missing. A locale file that is invalid JSON is ignored with a warning, falling back to
en; theencatalog being invalid is an error at load.
Out of scope
- Translations. This work item ships
enonly. The fallback path is tested with a fixture locale. - The skill and command Markdown (
skills/,commands/) — already Markdown. - Log lines and developer-facing exception messages — kept in English by R2.7. The owner was told and invited to object (PR #541).
- Agent-facing text that is not prose: the Codex conversation marker (a machine token), graph hook messages and CLI JSON envelopes (CLI output an agent reads like a person would, and which carry machine vocabulary), and prompts the caller supplies.
Open questions
None blocking. The exception-message boundary (R2.7) was raised on the PR.
Review comments
Appended by the-loop's
record-feedbackhook when a human gate approves with comments (issue-109).
- 2026-11-18, @MadaraUchiha-314 on PR #541: "no. do it in this PR itself. don't create more backlog unnecessarily", in answer to whether the scope split was acceptable. Applied: R2.5 now covers the whole application, and follow-up #542 was withdrawn.