nutrition-mcp
CLAUDE.md105 starsChanged 2 months agoMITView on GitHub
Guidance for AI coding agents working in this repository. nutrition-mcp is a remote MCP server for personal nutrition tracking built with Bun + TypeScript, Hono, Supabase, and MCP TypeScript SDK v2 (@modelcontextprotocol/server, @modelcontextprotocol/client, Zod 4). Read only the doc relevant to the subsystem you are modifying:
- Reads credentials
In this repositoryOne other file it gives its agents.
- public/llms.txtllms.txt
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
31 rules. About 0 are common, 22 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈22
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 24
Default to Bun (bun, bun install, bun run, bunx).
- Very specific: line 25
Prefer Bun.serve(), Bun.file, Bun.$\...\
, and bun:test (import { test, expect } from "bun:test"). - Very specific: line 29
Frozen
outputSchemas: Never add/remove/narrow fields on an already-deployed tool's outputSchema (src/output-schemas.frozen.json pins … - Very specific: line 34
Version bumps: Update package.json, src/mcp.ts, and server.json together (v* tag triggers .github/workflows/publish-mcp.yml).
- Distinctive: line 39
Read only the doc relevant to the subsystem you are modifying:
- Distinctive: line 53
Keep responses and edits concise.
- Very specific: line 54
Run bun run format:check && bun run typecheck && bun test before finishing.
- Distinctive: line 62
Default to parallel execution and web-verified information.
- Distinctive: line 75
Only after their completion, dispatch the next wave of now-unblocked subtasks
- Distinctive: line 78
Rule: If two tasks do not share an input/output dependency, they MUST run in parallel.
- Distinctive: line 82
Prefer batching tool calls in a single response turn rather than sequential turns:
- Very specific: line 97
When using the Task tool to spawn sub-agents:
- Distinctive: line 103
After all agents complete, explicitly synthesize their outputs — do not present raw agent outputs as the final answer
- Very specific: line 107
When managing complex tasks with TodoWrite:
- Very specific: line 111
Never mark a parent task completed until all parallel children resolve
- Distinctive: line 131
Always perform a web search before proceeding: when the task involves any of the following:
- Distinctive: line 146
Search before assuming: Do not rely on training knowledge for anything that changes over time.
- Distinctive: line 148
Prefer official sources: When web results conflict, prioritize: official docs > GitHub releases > well-known technical blogs > forums.
- Distinctive: line 150
Deduplicate within session: If you have already searched for a query in this session and the result was unambiguous, do not re-search the …
- Distinctive: line 152
Surface what you found: When you use web search to inform a decision, briefly state the source and key fact.
- Distinctive: line 154
Parallelize searches: When multiple independent facts need to be looked up, dispatch all web searches simultaneously, not sequentially.
- Distinctive: line 160
If web search returns guidance that contradicts patterns already established in the repo:
- Distinctive: line 164
Do not silently override existing code with web-sourced patterns without user confirmation
- Very specific: line 182
No unverified version pinning: Never write a dependency version (package.json, pyproject.toml, Cargo.toml, etc.) without confirming via web …
- Distinctive: line 183
No silent failures in parallel batches: If one parallel subtask fails, halt dependent tasks immediately and report the failure before …
- Distinctive: line 184
Conflict resolution in parallel file edits: If two parallel sub-agents are asked to modify the same file, serialize those specific edits.
- Distinctive: line 185
Do not hallucinate tool flags or API parameters: If unsure whether a CLI flag exists, search first.
- Distinctive: line 191
When executing a parallel batch, briefly state what is running in parallel and why
- Distinctive: line 192
When web search informs a decision, cite source and date if available
- Distinctive: line 193
When sequential execution is chosen over parallel, briefly state the dependency that forced it
- Distinctive: line 194
Keep explanations concise — action over narration
≈ “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.
Files
CLAUDE.md
Guidance for AI coding agents working in this repository.
Project Overview
nutrition-mcp is a remote MCP server for personal nutrition tracking built with Bun + TypeScript, Hono, Supabase, and MCP TypeScript SDK v2 (@modelcontextprotocol/server, @modelcontextprotocol/client, Zod 4).
- Entry point:
src/index.ts; MCP server factory:src/mcp.ts(tool registrations live insrc/mcp/tools/*.ts, shared helpers insrc/mcp/*.ts); 53 tools; Supabase data access:src/db/*.tsbehind thesrc/supabase.tsbarrel (keep importing./supabase.jssomock.moduleintercepts it). - Merging to
mainauto-deploys to production (https://nutrition-mcp.com/mcp) and updates a listed server in Anthropic's connectors directory (claude.ai/directory/nutrition-mcp).
Commands
bun run src/index.ts— run the server (bun --watch src/index.tsfor watch mode)bun test— run all tests (bun test src/path/to/file.test.tsfor a single file)bun run format/bun run format:check— Prettier (4-space indentation; CI-gated)bun run typecheck— typechecksrc/viascripts/typecheck.ts(CI-gated)bun run gen:all— regeneratepublic/*.htmlandpublic/sitemap.xml(CI runs this before tests)bun run harness— local MCP Apps widget host simulator (scripts/widget-harness.ts)bun run dashboard:preview— local web dashboard preview (scripts/dashboard-preview.ts)
Bun Runtime Conventions
- Default to Bun (
bun,bun install,bun run,bunx). Do not use Node equivalents ordotenv(Bun auto-loads.env). - Prefer
Bun.serve(),Bun.file,Bun.$\...`, andbun:test(import { test, expect } from "bun:test"`).
Critical Invariants (Always Check Before Editing)
- Frozen
outputSchemas: Never add/remove/narrow fields on an already-deployed tool'soutputSchema(src/output-schemas.frozen.jsonpins them). Put new widget-only data in_metaunder anutrition-mcp.com/*key (src/widgets.ts). - Registered tool set (53 tools): Adding, renaming, or removing a
server.registerTool()call (insrc/mcp/tools/*.ts) requires updatingTOOLS+ English prose insrc/copy/tools.ts,src/copy/index.ts,README.md,public/llms.txt,src/mcp.test.tsandsrc/mcp/suites/*.ts, and the directory listing, then runningbun run gen:all. - Claude directory rules: Model-facing text (
description,title, tool results,SERVER_INSTRUCTIONS) must describe, never direct; keep all 5 tool annotations accurate (src/mcp/suites/protocol.tspinsdestructiveHintandopenWorldHint). - Apply DB migrations before deploying code:
deleteAllUserDataand readers query new tables/columns immediately on boot. - Privacy-clean runtime logs:
console.*lines must never log user IDs, emails, tokens, codes, or per-user paths (src/log-privacy.test.ts). UseToolError(src/errors.ts) for caller-facing errors. - Version bumps: Update
package.json,src/mcp.ts, andserver.jsontogether (v*tag triggers.github/workflows/publish-mcp.yml). - Master English copy + keyed translations: English copy and types live in
src/copy/<name>.ts; non-English translations live insrc/copy/translations/<locale>.jsonas partial overlays merged onto English by key (src/copy/merge.ts), so English-only edits never breaktypecheck.
Architecture Reference Docs
Read only the doc relevant to the subsystem you are modifying:
| Subsystem | Doc |
| MCP v2 endpoint, 53 tools, schemas, USDA, saved meals, active calories, reads/errors | docs/architecture/mcp-and-tools.md |
In-chat MCP Apps widgets (public/widgets/src/), @include/@inlinets/@i18n, bridge & CSP | docs/architecture/widgets.md |
| Bulk meal import, idempotency, data export & ZIP invariants | docs/architecture/import-export.md |
OAuth 2.0, PKCE, session binding, token hashing, cleanup, security.txt, HSTS | docs/architecture/oauth-and-security.md |
| Apple Health sync & Apple Health activity sync | docs/architecture/health-sync.md |
Web dashboard, public site generators, i18n copy & depersonalize.ts | docs/architecture/web-dashboard-and-site.md |
Working Practices
- Batch independent file reads and searches in parallel rather than running sequential round-trips.
- Keep responses and edits concise; preserve existing comments and docstrings unrelated to your change.
- Run
bun run format:check && bun run typecheck && bun testbefore finishing.
Claude Code Operating Instructions
Core Philosophy
Default to parallel execution and web-verified information. Sequential execution and offline assumptions are fallback modes, not defaults. When in doubt: parallelize, then search.
1. Parallelization Protocol
Default Behavior: Parallel-First
Before starting any multi-step task:
- Decompose the full task into atomic subtasks
- Build a dependency graph — identify which subtasks have no prerequisite outputs
- Dispatch ALL dependency-free subtasks simultaneously using parallel tool calls
- Only after their completion, dispatch the next wave of now-unblocked subtasks
- Repeat until task is complete
Rule: If two tasks do not share an input/output dependency, they MUST run in parallel. Sequential execution of independent tasks is a performance violation.
Parallel Tool Call Patterns
Prefer batching tool calls in a single response turn rather than sequential turns:
# CORRECT — dispatch independent reads simultaneously
- Read file A
- Read file B
- Search web for library version
(all in one turn)
# WRONG — needless sequencing
- Read file A → wait → Read file B → wait → Search webSub-Agent Parallelization (Task Tool)
When using the Task tool to spawn sub-agents:
- Spawn all independent sub-agents in a single dispatch batch
- Maximum 5 concurrent sub-agents at any time to avoid context exhaustion
- Each sub-agent must have a clearly scoped, non-overlapping responsibility
- Define explicit output contracts for each agent before spawning
- After all agents complete, explicitly synthesize their outputs — do not present raw agent outputs as the final answer
TodoWrite Protocol
When managing complex tasks with TodoWrite:
- Mark tasks as
in_progressbefore starting a parallel batch - Track each parallel thread separately
- Never mark a parent task
completeduntil all parallel children resolve - Flag dependency chains explicitly in todo descriptions
When Sequential Execution Is Permitted
Sequential execution is only justified when:
- Task B requires Task A's output as direct input
- Tasks write to the same file or resource (race condition risk)
- A previous parallel batch returned an error that changes downstream logic
- User explicitly requests step-by-step confirmation
In all other cases: parallelize.
2. Web Search Mandate
Search-First Triggers
Always perform a web search before proceeding when the task involves any of the following:
| Category | Examples |
| Library / framework versions | "What's the latest stable version of X?" |
| API behavior and signatures | Any external SDK, REST API, or CLI tool |
| Security advisories | CVEs, deprecated patterns, breaking changes |
| Best practices | Architecture patterns, language idioms updated post-2024 |
| Configuration options | Tool flags, environment variables, cloud service settings |
| Error messages | Unfamiliar stack traces, runtime errors |
| Compatibility questions | Node/Python/Rust version support, browser APIs |
| Pricing or limits | Cloud service quotas, rate limits, SLA details |
Search Behavior Rules
- Search before assuming. Do not rely on training knowledge for anything that changes over time. External information has a shelf life; always verify.
- Prefer official sources. When web results conflict, prioritize: official docs > GitHub releases > well-known technical blogs > forums.
- Deduplicate within session. If you have already searched for a query in this session and the result was unambiguous, do not re-search the same query. Cache the result mentally and reference it.
- Surface what you found. When you use web search to inform a decision, briefly state the source and key fact. Do not silently use search results without attribution.
- Parallelize searches. When multiple independent facts need to be looked up, dispatch all web searches simultaneously, not sequentially.
- Do not search for: Internal project details, proprietary architecture, code that exists in the repository (read the file instead), or subjective style decisions.
When Web Search Results Conflict with the Codebase
If web search returns guidance that contradicts patterns already established in the repo:
- Note the conflict explicitly
- Present both the current repo pattern and the web-sourced alternative
- Do not silently override existing code with web-sourced patterns without user confirmation
3. Session Start Checklist
At the beginning of every new task or session, run the following in parallel:
- Read
CLAUDE.md(this file) to confirm operating rules are loaded - Identify the task's scope and decompose into subtasks
- Flag any subtasks that require web verification
- Check for existing relevant files in the repo before searching externally
- Dispatch first parallel batch
4. Quality and Safety Rules
- No unverified version pinning. Never write a dependency version (
package.json,pyproject.toml,Cargo.toml, etc.) without confirming via web search that it is current and non-deprecated. - No silent failures in parallel batches. If one parallel subtask fails, halt dependent tasks immediately and report the failure before proceeding.
- Conflict resolution in parallel file edits. If two parallel sub-agents are asked to modify the same file, serialize those specific edits. All other work continues in parallel.
- Do not hallucinate tool flags or API parameters. If unsure whether a CLI flag exists, search first.
5. Communication Standards
- When executing a parallel batch, briefly state what is running in parallel and why
- When web search informs a decision, cite source and date if available
- When sequential execution is chosen over parallel, briefly state the dependency that forced it
- Keep explanations concise — action over narration
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
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.

