agentleFS
scaliavenscaliaven/menu-translate/CLAUDE.md

menu-translate

CLAUDE.md1 starsChanged 4 months agoMITView on GitHub

Guidance for Claude Code when working in this repository. menu-translate is a Claude Code Agent Skill (not an application). It reads restaurant menus and produces a structured bilingual (English + 中文) menu. It follows the "script + references" skill pattern (the same shape as the amber-chemist skill): SKILL.md is a routing contract, scripts/*.py do the deterministic work, and references/*.md hold the deep operating docs. Claude reads and translates; the scripts only validate and render. - Menu images and PDFs are…

  • In this repositoryOne other file it gives its agents.

The file

We split this CLAUDE.md into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 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.

  • 2

    Very specific

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

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

    If you are tempted to add OCR, a translation API, or an HTTP client to the scripts, stop — that work belongs to Claude at the SKILL.md …

    line 28
  2. Very specific:

    If you change any of these in _menu.py, update references/output-schema.md (and the docs/ example) to match.

    line 72
  3. Distinctive:

    When you edit installation or usage instructions, update both this file and README.md — they describe the same thing for different readers …

    line 159

≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md 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
CLAUDE.md

CLAUDE.md

Guidance for Claude Code when working in this repository.

What this repo is

menu-translate is a Claude Code Agent Skill (not an application). It reads restaurant menus and produces a structured bilingual (English + 中文) menu. It follows the "script + references" skill pattern (the same shape as the amber-chemist skill): SKILL.md is a routing contract, scripts/*.py do the deterministic work, and references/*.md hold the deep operating docs.

The one principle that shapes everything

Claude reads and translates; the scripts only validate and render.

  • Menu images and PDFs are read natively by Claude's Read tool — there is no OCR library and there must never be one.
  • Translation is done by Claude, not by code.
  • Discovery (name/address → menu) uses Claude's built-in WebSearch / WebFetch tools — no Google API key, no scraping code. Browser automation is a documented fallback only — claude-in-chrome locally, headless Chromium/Playwright in a cloud sandbox (claude-in-chrome needs the user's own Chrome, so it does not exist there).
  • The Python helpers do exactly two deterministic jobs: validate the structured menu record and render it as a bilingual markdown table.

If you are tempted to add OCR, a translation API, or an HTTP client to the scripts, stop — that work belongs to Claude at the SKILL.md level, not the code.

File map

SKILL.md                  # routing contract — read this first to see the flow
references/
  README.md               # index of the docs below
  output-schema.md        # the menu JSON schema (THE data contract) + example
  translation-guide.md    # romanization, tagging, currency rules
  photo-workflow.md       # image/PDF entry point
  discovery-workflow.md   # name/address entry point
  failure-modes.md        # blurry photos, no menu online, unknown currency…
  network-setup.md        # sandboxed/cloud env: access levels + domain allowlist
scripts/
  _menu.py                # shared lib: schema constants, validate, convert, render
  render_menu.py          # CLI: menu JSON -> bilingual markdown table
  check_env.py            # env probe (Python, Pillow, poppler, network)
  preprocess_image.py     # optional (Pillow): clean up a low-quality photo
examples/sample_menu.json # renderer fixture
tests/repo_checks.py      # repo self-checks (also run by CI)
docs/                     # self-contained public website (GitHub Pages: index + examples)

Source of truth for the data contract

scripts/_menu.py owns the schema, and references/output-schema.md documents it. They must stay in sync. The canonical constants live in _menu.py:

  • REQUIRED_TOP — required top-level fields (source_language, currency, sections).
  • REQUIRED_ITEM — required item fields (name_original, name_en, name_zh, confidence).
  • CONFIDENCE_VALUES — high / medium / low.
  • TAG_VOCAB — the controlled tag vocabulary (spice / diet / contains-* / prep-other). Tags outside it are a warning, not an error.
  • FALLBACK_RATES — approximate USD-per-unit rates, used only when no live --rate / --rates-file is supplied (the renderer then prints an "approximate" note).
  • WARNING_PREFIX — the marker validate() puts on warning-level findings; render_menu.py parses it back. Reference this constant, never the literal string, in both places.

If you change any of these in _menu.py, update references/output-schema.md (and the docs/ example) to match.

Running & testing (stdlib-only, no install step)

python3 tests/repo_checks.py                                   # ALL checks below, at once
python3 scripts/check_env.py                                   # env probe
python3 scripts/render_menu.py examples/sample_menu.json       # render fixture
python3 scripts/render_menu.py examples/sample_menu.json --convert-to USD --rate 0.14
python3 scripts/render_menu.py examples/sample_menu.json --convert-to USD   # fallback note
python3 -m py_compile scripts/*.py                             # syntax check

tests/repo_checks.py is what CI runs (.github/workflows/checks.yml, on Python 3.9 and 3.13). Run it before pushing — it is stdlib-only and needs no install step. Beyond the commands above it also verifies the SKILL.md frontmatter gotcha below, that relative doc links resolve, that no script imports an HTTP client, and that check_env.py stays self-consistent (see "Regression guards").

Regression guards

Two checks exist because the bug they describe actually reached main, so treat a failure as a real defect rather than a stale assertion:

  • probe: no retired PDF claim — check_env.py once asserted PDFs needed no dependency two lines above reporting poppler missing. The poppler probe and the network probe came from different branches; both were correct alone, and a textual merge kept both claims verbatim.
  • probe: [SUMMARY] reports gaps — every capability gap the probe reports in its body must also reach [SUMMARY], because the docstring invites grepping that line alone. A missing poppler once did not, so [SUMMARY] read "ready" where every PDF menu would fail.

The renderer prints the validation report to stderr ([OK] / [PROBLEM] / [WARN]) and the table to stdout. Validation problems never abort the render; it exits non-zero only when the file can't be read or parsed.

Conventions (match these)

  • Stdlib only. No requirements.txt. The only third-party dependency is Pillow, and it is optional and runtime-detected (used only by preprocess_image.py; never a hard top-level import).
  • Python 3.8+. No str.removeprefix and similar 3.9+ niceties.
  • Scripts carry a #!/usr/bin/env python3 shebang and a "When to use / When NOT to use" docstring.
  • Tagged output lines: [OK] / [MISSING] (an expected prerequisite is absent) / [INFO] / [SUMMARY] in the probes; [ERROR] for an operation that failed for a reason other than a missing prerequisite. Keep [MISSING] meaning "absent", not "generic failure".

SKILL.md frontmatter gotcha

The frontmatter is YAML. The description is a long unquoted plain scalar, so it must not contain a ": " (colon-space) sequence — YAML would read it as a nested mapping and fail to load the skill. Reword instead (e.g. "menu with dish names", not "menu: dish names"). Verify after editing:

python3 -c "import yaml; yaml.safe_load(open('SKILL.md').read().split('---',2)[1]); print('ok')"

Install / where the skill has to live

The skill auto-triggers once Claude Code can see it; there is no command to run. Where it must live differs by surface, and this trips people up:

  • Local (terminal / desktop / IDE) — personal skill:

    ln -s "$PWD" ~/.claude/skills/menu-translate

    A symlink rather than a copy means edits here propagate immediately.

  • Cloud sessions (claude.ai/code) — ~/.claude/skills/ is not available there; it lives on the user's machine, not in the repo. Either the skill is enabled on claude.ai (those load into cloud sessions automatically), or it is committed to the target repo under .claude/skills/menu-translate/, which is part of the clone.

Note this repo keeps SKILL.md at its root, not in .claude/skills/ — it is the skill, rather than a project that bundles one. That is why the local install symlinks the repo directory itself, and why vendoring into another repo means copying it to that repo's .claude/skills/menu-translate/.

When you edit installation or usage instructions, update both this file and README.md — they describe the same thing for different readers and have drifted before.

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.