← Blog/Agents
Hand the routine dev work to an agent
Let an AI agent investigate failing builds, keep dependencies current and take one-off tasks from Claude, and leave your team a branch to review.
Some development work is important but never urgent enough to do first. Looking into why last night's build failed. Reading a new bug report closely enough to know which file it is about. Bumping the dependencies that have drifted three minor versions behind. Each of these takes a developer twenty minutes of context-switching, and together they eat a real part of the week.
They also have something in common: they start from an event or a time, and the first half of the work is reading. That makes them a good fit for an AI agent that runs on its own when the event happens, does the reading, and leaves a developer with a result to review instead of a task to start.
This post walks through three such automations for a Mercur agent: one started by a webhook, one on a schedule, and one you start by asking Claude.
Before you start
You need an agent on a connected computer, with your repositories added and its highest mode set
to Edit, since these automations change code. On the repositories it should fix, turn on
Agents may push branches. Mercur agents only push branches with your prefix (mercur/ by
default), never to the default branch and never with force, so everything they produce arrives
as a branch for someone to review.
If you would rather nothing leaves the machine at all, start the computer with --no-push. The
agent then commits on a branch in its own copy of the repository on that computer, and you pick
it up from there.
1. A failing build starts an investigation
Create a Webhook automation on the agent, call it "Triage failing builds", choose the repository it works in and set Permissions to Edit. The prompt:
A CI build failed. The webhook body contains the branch, the commit and the end of the build log. Find the cause in the repository. If it is a small and clear fix, such as a broken test, a type error or a missing import, fix it on a new branch, run the tests, and push the branch. If it is not, do not change anything: explain the cause, the commit that introduced it and the files involved. Never change the CI configuration.
Mercur shows the automation's URL once when you create it. Add it as a step at the end of your CI pipeline that only runs on failure:
curl -X POST "$TRIAGE_WEBHOOK_URL" \
-H 'Content-Type: application/json' \
-d "{\"branch\": \"$CI_BRANCH\", \"commit\": \"$CI_COMMIT\", \"log\": $(tail -c 20000 build.log | jq -Rs .)}"Keep the URL in your CI secrets: anyone who has it can start runs. Turn on Deduplication with the commit as the key, so a pipeline that retries does not start three investigations of the same failure.
Now a red build produces either a branch named like
mercur/fix-missing-import ready for review, or a short written diagnosis on the agent's
Runs tab. Either way the developer who picks it up starts from an answer, not from the log.
The same pattern works for anything else that can send a webhook: a new issue in your tracker, an error alert from monitoring, a form submission. The webhook body is passed to the run, so the prompt can say what to do with it.
2. A nightly dependency check
Create a Schedule automation, "Dependency updates", with the preset Weekdays at 9:00 or your own cron expression, and your time zone. The prompt:
Check the dependencies of the web repository for patch and minor updates. Apply them on a new branch, run the tests, and push the branch if they pass. List what you updated and anything you skipped and why. Do not apply major versions.
Add npm install and npm test (or your package manager's install and test commands) to the
agent's Allowed commands, so an Edit run may update the packages and run the tests. Each morning there is either a tested branch to merge or nothing to do.
A gentler variant for teams that are not ready to let an agent change code: the same schedule in Read-only, with a prompt that only reports which dependencies are behind and what their changelogs say. Read-only runs are not given the tools to change files.
3. Work you start from Claude
Not every task deserves a standing automation. Connect the agent to Claude through its MCP address and you can hand it one-off work in plain words, from wherever you are already working:
Ask the backend agent to rename the
legacy_planfield toplan_tieracross the API repository tomorrow at 7:00 and push a branch for review.
Create a schedule on the agent: every Monday at 8:00, run the test suite three times and list the tests that did not pass every time.
What did the agent's automations do last night? Did anything fail?
Tasks and schedules created through Claude appear in the console like any other run, so the team sees them, and anyone with Manage access can cancel one from the agent's Queue tab.
Keeping it under control
Automations change code without anyone watching in the moment, so the guardrails matter more than for a chat:
- Review everything that gets merged. The agent pushes branches, not merges. Your usual review rules stay in force.
- Narrow prompts work best. "Fix it if it is small and clear, otherwise explain" gives better results than "fix the build".
- Allow only the commands the job needs. An Edit run is only allowed the commands on the agent's list.
- Read the run history. Every run records what started it, who started it, what it did, the branch it worked on and what it cost.
- Give the agent a dedicated machine or user account. It works with the access of the computer it runs on.
Set it up
- Create the agent and add your repositories: AI agents on your own machine.
- Create the webhook and schedule automations: Agent automations.
- Connect the agent to Claude: Use an agent from Claude (MCP).
Open Agents