Optional practice after this week’s videos, ungraded. Each exercise takes ten to twenty minutes with your own coding agent, and shows one idea from the videos at work on your own code.
Before you start: use a throwaway repository or a branch of an old one.
Building Your First Hook
- Get notified. Ask your agent to add hooks to your user settings that show a desktop
notification, or play a sound, whenever it pauses or finishes: a
Notificationhook for when it is waiting for your permission or your input, and aStophook for when it has finished its turn. Ask it for something that needs a permission prompt, switch to another window, and wait for the first notification. Approve it and wait for the second one, when the agent is done. Then open/hooksand find the hooks you added. - A dashboard of your agents. Ask your agent to add hooks for
SessionStart,StopandSessionEndthat append one line per event to a log file, and a small program that reads the log and shows which sessions are running right now. Each hook’s input names the session’s transcript file, so the program can also show how many tokens each session has used. Start two or three sessions in different folders and watch the dashboard follow them.
Returning Feedback to the Agent
- Let the checker talk to the agent. In a small Python project, ask your agent for a hook that runs the type checker on each file it edits and returns the errors to it. Then ask for a change that is likely to break a type, such as “return None when the list is empty”, and watch the agent fix the error without being told. Finally, rename the checker so the hook cannot run: what is the agent told now?
Hooks That Say No
- Protect one file. Add a
PreToolUsehook that refuses edits to one file you choose, such as the version line inpyproject.toml, with a reason the agent can act on. Ask the agent to bump the version and read how it reacts. Then ask it to “do it any way you can”, and watch whether it goes around the guard through the shell. - Don’t stop until the tests pass. Add a
Stophook that runs your tests. Break one test, ask for a small unrelated change, and watch the agent get sent back before it can finish. Then make the failure one the agent cannot fix, and check that your hook gives up instead of looping.
CI and GitHub Actions
- A workflow for an old repository. Take one of your old repositories on GitHub and ask your
agent for a CI workflow that runs the same checks you run locally. Open a pull request with a
failing test and read the failing step’s log. Then delete a dependency from the project’s
declared dependencies while it is still installed on your laptop: the tests pass at home and fail
in CI. Finally, turn on a required check for
mainand watch the merge button go grey.
Agentic Code Review
- An adversarial review of an old program. Take a program you wrote some time ago and ask an agent for an adversarial review: find the ways it fails, with a concrete scenario for each. Go through the findings yourself and decide, for each one, whether it is right and whether it is worth fixing. Turn one finding into a failing test before you fix it.
- Review the review. Give the review from the previous exercise to another agent, in a fresh session, together with the program. Ask it which findings are real, which matter, and in what order you should fix them. Compare its ranking with the decisions you made yourself.