How to write video instructions for an AI agent (AGENTS.md)
Article by Pedro Henrique Lahr
Good video instructions for an AI agent are short and describe a loop, not a list of prohibitions. Kodecz's AGENTS.md fits on one page: write the video, look at a frame, check everything, fix it, and only then render. The rest is a few rules that keep every frame identical from one render to the next, and a list of what to look at before calling the video done.
What is AGENTS.md?
It is a text file at the root of a project that coding agents read before they work. Claude Code, Codex, Cursor and Gemini CLI, among others, look for instructions like these. In Kodecz, it explains how any agent makes a video using only files and terminal commands, without depending on one vendor.
Why doesn't a bigger manual help?
Because the agent does not fail for lack of rules. When we looked at the 27 defects that showed up in our own videos before delivery, 6 repeated a lesson that was already written in the agent's instructions. The rule «no text over the face» was there. The agent simply had no way to see that its video broke it.
And 21 of the 27 were relations between two things: text over a face, a zoom out of step with the speech, a cut in the middle of a word. None of that shows up from reading the code. A longer manual only adds to what the agent has to remember, without giving it eyes.
That is why Kodecz's AGENTS.md spends more lines on «how to see» than on «what not to do».
Which loop do the instructions ask for?
- Write the video as a folder:
index.htmlwith a block that declares the size, the frames per second and the length in frames, and the rest in ordinary HTML, CSS and JavaScript. - Look at a frame instead of guessing:
kodecz preview folder id --frame 90writes the picture in one to two seconds. Several at once:--frame 0,45,120. Then look at it. - Check before rendering:
kodecz check folder idlooks at every frame and answers in one JSON line, with a picture of each problem. Exit code 4 means a rule was broken. Fix and check again. - Render:
kodecz render folder id out.mp4.
Notice that step 3 comes before step 4. The agent fixes the page, where it is cheap, before producing the final file.
Which rules stay in the file?
Only the ones the agent would not discover alone and that break the video silently:
- Animate with CSS
@keyframesorelement.animate(). Time is in frames: with:root { --fps: 30 }, the delay iscalc(frame * 1s / var(--fps)). - Canvas, WebGL and text changed by script go in a
window.kodecz_frame(n, ms)function that depends only on the frame number. - Never
requestAnimationFrame,setTimeout,setInterval,Date.now()orperformance.now()to animate. They follow the clock, not the frame, and the same frame would come out different in two renders. - Media with
<video>and<audio>, and timing in attributes: first frame, length in frames, volume, speed. Files inside the folder. - Editing techniques come from the blocks: read the index first and open only the block you will use.
What should be checked before calling it done?
The last section of AGENTS.md matters most, and it has three lines:
- Look at the key frames yourself: start and end of every scene, every zoom, every caption change.
kodecz checkwith no errors.- Watch the MP4, or at least the frames around every cut.
That is what separates «the code ran» from «the video is right».
How do you write your own, for another project?
If you maintain video instructions for an agent, what we learned comes down to this:
| Instead of | Do |
|---|---|
| a long list of prohibitions | a short loop with a «look» step |
| «check the video» | the exact command that checks and what each exit means |
| a vague rule of taste | a rule with a number (margin, lines, seconds) a machine can measure |
| everything in one huge file | an index and one file per technique, read only when used |
Does this apply to Konecz videos?
It does. The videos on the Konecz profiles are made by agents following this same loop, and the checks exist because the written rule was not enough. On 11/19/2026 the portfolio held 108 videos, such as «A ia achou tanto furo que o conserto derrubou tudo.» (the AI found so many holes the fix broke everything) on the Lahrs profile, and «Lavar o frango deixa sua cozinha mais suja» (washing chicken makes your kitchen dirtier) on Gatronomia.
Frequently asked questions
Does AGENTS.md work with any agent? It works with any agent that writes files and runs commands. Nothing in it depends on one vendor.
Do the rules have to be in English? No. The agent reads any language. Kodecz's is in English because the project is public; the blocks are still in Portuguese.
What if the agent ignores the instructions? The automatic checks catch the mistake anyway and return the frame, the element and the reason. Instructions guide; the checks make sure.
A summary of the paper on agents' mistakes is in AI agents making video. To get videos made this way on your profile, talk to Konecz.