The AI agent is twig's core feature. This page covers how to interact with it effectively, review its work, and get the best results.
Type your request in the chat input at the bottom of the agent panel. Be specific about what you want to accomplish:
add input validation to the email field in the signup form.
reject invalid email formats and show an error message.
Press enter or click send. The agent will begin working on your request.
When you send a message, the agent:
You'll see each step in the conversation as it happens.
Before any code changes are applied, the agent shows you what it proposes:
You can:
Before sending requests, it helps to know what the agent can do:
See agent tools for detailed capabilities and limitations.
how you ask makes a big difference. compare vague vs specific requests:
ā vague: "make the form better" ā specific: "add client-side validation to the email field. reject invalid formats and show an error message below the input."
ā vague: "fix the bug" ā specific: "the signup API returns 500 when email is missing. add input validation to check required fields before the API call."
ā vague: "optimize this" ā specific: "this function runs on every keystroke and causes lag. debounce it to only run 300ms after the user stops typing."
ā vague: "update the styles" ā specific: "change the button color to match our design system. use the primary-blue variable and add a hover state."
help the agent understand your codebase:
we use tailwind for styling throughout this project.
add a loading spinner to the submit button using tailwind classes.
Tell the agent about requirements:
add error handling to this function.
use our existing errorLogger utility instead of console.log.
keep the function under 50 lines.
For large tasks, work incrementally:
let's add user authentication to this app.
first, explain the current auth-related code so i understand the starting point.
Then:
now add a login endpoint that validates credentials against the database.
Keep the same conversation when:
The agent remembers your conversation history and can reference earlier decisions.
Start a new conversation when:
Fresh starts help the agent focus without distraction from unrelated history.
If a conversation feels cluttered:
let's start fresh on this. ignore previous context.
the goal is: [clear description of what you want now]
Understanding when to use which approach saves time.
Neither is better - choose based on efficiency for the specific task.
If the agent does something different from what you wanted:
that's not quite right. i meant the email validation should happen
on form submit, not on every keystroke. please update the approach.
If the agent seems confused or loops:
let's start fresh. forget the previous approach.
the goal is: [clear statement of what you want]
If code doesn't work:
this gives an error: [paste the error].
please fix the issue.