[2026-01-10] Prompt Engineering Uplift
Task Metadata
Date: 2026-01-10
Status: Completed
Objective
Goal: Refine the AI system prompt to improve data quality for specific nutrients, simplify the interface by removing unreliable deep links, and provide dummy-proof instructions for the manual copy-paste workflow.
- Uplift 1: Added Sugars Logic: When "sugar" is tracked, the AI must distinguish between natural sugars (e.g., in fruit) and "Added Sugars."
- Uplift 2: Copy-Paste Priority (with Legacy Link): Deep links (
chatkcal.app/track?...) work well in ChatGPT but fail elsewhere. We will keep the link as a secondary "Magic Link" option but prioritize a robust, dummy-proof copy-paste instruction set as the primary call to action.- Uplift 3: Dummy-Proof UX: Provide clear visual cues (copy icon symbols) and specific instructions for returning to the app and clicking "Paste Meal JSON," including iPhone-specific double-paste guidance.
Technical Strategy
We will modify the prompt generator in promptUtils.ts to implement these conditional instructions.
- Strict JSON Compliance: Remove all comments (
//) from the JSON structure example to prevent models from copying them into the output, ensuring validJSON.parse(). - Conditional Magic Link: The "Magic Link" request will be completely removed from the
BASE_INTROunless specifically requested (for ChatGPT). This prevents hallucinated links in other models. - Refined Sugar Logic: Update the Added Sugar instruction to handle the nuance of milk chocolate (lactose vs sucrose) for higher precision.
- Copy-Paste Priority: The output format will strictly enforce a "Copy-Paste First" workflow with clear, numbered steps.
Testing Strategy
- Unit Test: Update
promptUtils.test.tsto verify the "Added Sugars" note appears when sugar is active and disappears when it is not. - Snapshot Test: Verify the final generated prompt text matches the new "Pure Copy-Paste" structure.
Risk Analysis
- UX Friction: Removing links might feel like a regression for some ChatGPT users, but it creates a consistent, reliable experience for all users regardless of model.
- Files to Modify:
frontend/src/utils/promptUtils.ts(Core logic change)frontend/src/utils/__tests__/promptUtils.test.ts(Verification)
Execution Plan
- Step 1: Refactor promptUtils.ts
- Refine
BASE_OUTROto prioritize copy-paste instructions. - Add "Added Sugars" conditional note logic.
- Add iPhone-specific guidance and emojis.
- Refine
- Step 2: Update Tests
- Verify sugar conditional logic.
- Verify clean instruction set.
- Step 3: Verification
- Manual verification of the generated prompt in the UI.
Execution Notes
- 2026-01-10: Implemented "Added Sugars" logic in
promptUtils.tswith specific examples (banana vs chocolate). - 2026-01-10: Refined
BASE_OUTROto include icon-based instructions, web search encouragement, and iPhone-specific guidance. - 2026-01-10: Implemented conditional "Magic Link" logic to only show it for ChatGPT users.
- 2026-01-10: Enforced strict JSON compliance by removing comments from the prompt example.
- 2026-01-10: Verified changes with unit tests covering conditional logic and output formatting.
User Approval & Key Learnings
Key Learnings
- Prompt Precision: LLMs are sensitive to comments in JSON examples; removing them improves
JSON.parse()reliability. - Contextual Output: Tailoring the prompt output (Magic Link vs Copy-Only) based on the user's entry point (ChatGPT button vs generic copy) significantly reduces confusion.
- Added Sugar Nuance: Explicit examples (Banana = 0g, Chocolate = All) are more effective than abstract definitions for guiding AI behavior.
Final Approval: Prompt uplift complete and verified.