Adding Comments to Prompts in LangSmith

Hi everyone!

I’m working with LangSmith and wondering if there’s a way to include comments directly within my prompts. I’ve been trying to use the Mustache format for comments like this:

{{# This is my main prompt section}}
You are a helpful assistant. Please analyze the following data:
{{/}}
{{! This comment explains the next part}}
Provide your response in JSON format

My main question is whether I need to render these prompts before sending them to the language model, or if LangSmith handles this automatically. Also, does anyone know of alternative platforms that support prompt commenting features? I want to document my prompts better for team collaboration but I’m not sure about the best approach. Any suggestions would be really helpful!

Mustache comments are a pain honestly. Hit this exact issue last year when our team was standardizing prompt docs.

Built a simple preprocessing pipeline that strips comment blocks before the LLM API call. Used regex to catch anything between custom delimiters like <!-- comment --> instead of Mustache syntax. Way easier to parse and you dodge the template rendering mess.

For team work, I went hybrid. Keep a master prompt file with inline comments for dev, then have your deployment script auto-generate the clean version. Developers see context while working, production stays lightweight.

Key lesson: pick a commenting format your entire pipeline handles consistently. Don’t overthink it - simple beats complex with multiple team members.

This tutorial covers solid patterns for managing prompts in production:

One more thing - if you’re iterating prompts a lot, use LangSmith’s dataset features to track which commented versions perform best. Saves tons of time rolling back changes.

hey noah, yeah, langsmith doesn’t handle mustache comments by itself, so you gotta process em b4 sending. i usually stick to regular # comments at the top - super ez to strip off programmatically. def way less hassel than mustache stuff!

You’re right - LangSmith doesn’t handle Mustache comments automatically. I’ve been using it for a year and always render them myself before sending prompts to the model. I switched to Python’s triple-quoted strings with regular comments, then strip them out with regex before hitting the API. Way cleaner approach. For team stuff, I use LangSmith’s prompt versioning plus detailed metadata descriptions instead. Keeps docs separate from the actual prompt and avoids parsing headaches. The version history beats inline comments that get stripped anyway - much easier to track changes and see why we made them.

Been there! You need to preprocess those Mustache comments before they hit the model. I use a simple commenting system in the template - wrap dev notes in specific delimiters you can strip out easily. Honestly, I ditched inline comments entirely after hitting the same parsing headaches. Now I keep a separate doc file that maps to each prompt version with detailed breakdowns of what each section does. Keeps the actual prompt clean but still gives the team good documentation. Plus you can be as wordy as you want without worrying about tokens or processing costs.