agentleFS
MicrosoftKnown publishermicrosoft/data-formulator/.cursor/rules/language-injection-conventions.mdc

data-formulator / rules

Cursor rule18k starsChanged 7 months agoMITView on GitHub

Language injection conventions for LLM Agent prompts

Trending

Steady talk.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 1 mentionMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 2 mentionsJun 2026: 0 mentionsJul 2026: 1 mentionAug 2026: 1 mentionSep 2026: 0 mentionsOct 2026: 2 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the microsoft/data-formulator repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about microsoft/data-formulator

The biggest 5 of 31 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 31

Talked about on Bluesky, GitHub and Hacker News (31 times).

On Bluesky · 22

17 more on Bluesky

On GitHub · 7

2 more on GitHub

The file

We split this language-injection-conventions.mdc into the rules it gives an agent

6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    User-facing LLM output: MUST inject language via get_language_instruction(mode=...) in the route handler.

    line 13
  2. Very specific:

    Do NOT: use env vars, global interceptors, or hardcoded language strings (e.g.

    line 18
  3. Very specific:

    New language?: Add to LANGUAGE_DISPLAY_NAMES in agents/agent_language.py and add locale files in src/i18n/locales/<lang>/.

    line 19
  4. Distinctive:

    Keep the English string as the default value.

    line 25
  5. Very specific:

    Add a message_code (or content_code, error_code, summary_code) field with a key like "agent.someKey".

    line 26
  6. Very specific:

    Add the translation key to src/i18n/locales/{en,zh}/messages.json under the agent section.

    line 29

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
language-injection-conventions.mdc
---
description: Language injection conventions for LLM Agent prompts
globs: py-src/data_formulator/agents/**/*.py,py-src/data_formulator/routes/agents.py
alwaysApply: false
---

# Language Injection Conventions

Language flows per-request: `Frontend i18n → Accept-Language header → get_language_instruction() → system prompt`.

## LLM Prompt Language Injection

1. **User-facing LLM output** MUST inject language via `get_language_instruction(mode=...)` in the route handler.
2. **Mode selection:** `"full"` for text-heavy agents, `"compact"` for code-generation agents and short-text endpoints.
3. **Inject into system prompt only** — use `inject_language_instruction()` from `agent_language.py`. Never inject into user messages.
4. **Do NOT inject** for non-user-facing calls (health checks, internal tool calls).
5. **Do NOT duplicate** — if upstream messages already contain language instruction, skip.
6. **Do NOT** use env vars, global interceptors, or hardcoded language strings (e.g. `"回答请使用中文"`) — route handlers should use `get_language_instruction(mode=...)`.
7. **New language?** Add to `LANGUAGE_DISPLAY_NAMES` in `agents/agent_language.py` and add locale files in `src/i18n/locales/<lang>/`.

## Python-Side User-Visible Messages (message_code pattern)

For **fixed strings in Python** that are shown in the UI (error messages, clarify options, completion summaries), do NOT translate in Python. Instead:

1. Keep the English string as the default value.
2. Add a `message_code` (or `content_code`, `error_code`, `summary_code`) field with a key like `"agent.someKey"`.
3. Optionally add `message_params` for interpolation.
4. The frontend translates using `translateBackend(fallback, code, params)` from `src/app/utils.tsx`.
5. Add the translation key to `src/i18n/locales/{en,zh}/messages.json` under the `agent` section.

```python
# ✅ GOOD — backend returns code, frontend translates
yield {
    "type": "error",
    "message": "Output DataFrame is empty (0 rows).",
    "message_code": "agent.emptyDataframe",
}

# ❌ BAD — backend-side translation dict
yield {"message": translate_in_python("empty_df", lang)}
```

For detailed architecture and anti-pattern explanations, see `docs/dev-guides/6-i18n-language-injection.md`.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.