Agent tags
Tags in a /// doc comment add what the code can't say. All of them are optional.
<!---
Adds a task and saves the list.
@llm Append a task and save; returns the new list.
@prefer @add_task($tasks, title: 'x') over $tasks->push(), which doesn't save.
@avoid Calling it in a loop: it saves each time. Build the list, then call @save_tasks once.
@pitfall title is trimmed, and an empty title throws Validation.
@example @add_task($tasks, title: 'Buy milk')
-->
<fn name="add_task" params="tasks: list, title: string">
<!-- … -->
</fn>
<!---
Only for the tests.
@agent hide
-->
<fn name="reset_store">
<!-- … -->
</fn>/// Adds a task and saves the list.
/// @llm Append a task and save; returns the new list.
/// @prefer @add_task($tasks, title: 'x') over $tasks->push(), which doesn't save.
/// @avoid Calling it in a loop: it saves each time. Build the list, then call @save_tasks once.
/// @pitfall title is trimmed, and an empty title throws Validation.
/// @example @add_task($tasks, title: 'Buy milk')
fn add_task(tasks: list, title: string) {
// …
}
/// Only for the tests.
/// @agent hide
fn reset_store() {
// …
}| Tag | What it does |
|---|---|
@llm |
The line agents read instead of the summary. Without it they get the summary's first sentence. Both are cut to 120 characters. |
@prefer |
The way to write something that agents should choose. |
@avoid |
A way of using it that agents should not choose. |
@pitfall |
A mistake that is easy to make. |
@example |
Shown when it fits on one line of up to 100 characters. |
@agent hide |
Leaves the symbol out of the agent docs. |
The editor shows @prefer, @avoid and @pitfall in hover too, so they help people as well. In XML, write the same tags in the <!--- ... --> comment before the element.