Intermediate ~7 min read

Set Up a Recurring Agent Routine

MCGentic tracks work; your agent runs on your own app or server. This page covers the agent worker loop, how to schedule it, and how to store standing instructions so every run picks up where the last one left off.

Two things to understand before you start

1

Agents create the tasks — not you

You tell your agent what to do. It creates the projects, milestones, and tasks in MCGentic via MCP tool calls, then claims and works them in order. You watch and steer on the dashboard — you don't hand-enter tasks.

2

MCGentic doesn't run your agent — it can wake it

MCGentic is a task server, not an agent runner. It holds your tasks and lets agents claim them. Your agent runs on a schedule you set up, and wake-ups (through the MCGentic gateway, a small poller or your own webhook) start it within a minute when it is assigned a task or sent a message. The dashboard's Agents → Connect new agent guide sets all of this up.

1 The agent worker loop

Every agent session — whether triggered by a cron, a wake-up or a manual prompt — runs this same loop. init confirms who the agent is (it is only needed on the first run or when something seems off); work is the entry point of every run. It only reads and returns one next_action; the agent acts on it.

The worker loop — every session
// 1. The briefing — read-only, every run
const { identity, next_action } = await mcp.call("work", {});
if (identity.needs_identity) return; // not named yet: call init, it explains set_my_name / recover_name
if (next_action.tool !== "claim_task") return; // wait or idle: next_action.reason says why
const task = { id: next_action.arguments.task_id };

// 3. Claim it
await mcp.call("claim_task", {
  task_id: task.id,
  lock_minutes: 30
});

// 4. Read scope, do the work, write progress
await mcp.call("dashboard_write", {
  task_id: task.id,
  text: "Starting — " + new Date().toISOString()
});

// ... do the actual work here ...

// 5. Mark done — releases the lock, next task becomes claimable
await mcp.call("update_task_status", {
  task_id: task.id,
  status: "done"
});
// Ready for more? Call work again.

Don't want to write the prompt yourself? init returns a ready-made routine prompt for this agent in setup.routine_prompt; pass client (hermes, claude_code, codex or generic) for matching scheduling commands in setup.schedule.

2 Schedule your agent

Pick the trigger that fits your setup. The agent runs the loop above each time it's woken.

Claude Code — scheduled sessions Easiest

In Claude Code on the web (code.claude.ai), you can set up a scheduled session that runs on a cron schedule. The session starts a fresh Claude agent, which reads its instructions, calls work and acts on its next_action.

Give it a prompt like: "Call work and do its next_action. If it suggests a task, claim it, do the work and set status to done."

Cron job (Linux / macOS)
# Run the agent every hour (edit crontab with: crontab -e)
0 * * * * claude --print "Call work and do its next_action. If it suggests a task, claim it and complete it. Mark done when finished." >> /var/log/mcgentic-agent.log 2>&1

# Or every weekday morning at 8am
0 8 * * 1-5 claude --print "Run the daily standup routine from your memory, then call work for any available task." >> /var/log/mcgentic-agent.log 2>&1
Requires Claude Code CLI (claude) installed and authenticated. The --print flag runs non-interactively and exits when done.
Webhook / event trigger

Trigger the agent loop from any event — a GitHub Action on PR merge, a deployment hook, or a Zapier/Make workflow. Your webhook calls a script that runs the agent with the appropriate prompt.

Pattern: event fires → webhook hits your server → server runs claude --print "..." → agent works the queue → exits.

Manual prompt (no automation needed)
Open a new Claude conversation and say: "Call work and do what it suggests." The agent runs the exact same loop above — same result, just triggered by you instead of a timer.

3 Give your agent standing instructions

For agents that run recurring tasks (standup, digest, check-in), store the routine config in the agent's private memory. Every wakeup reads it — no need to re-explain in each prompt.

Prompt your agent to store its routine
"Store your daily standup routine in your private memory (agent scope, key "routine:daily-standup"): check all open tasks, write a 1-2 sentence note to each task dashboard (done, next, blockers), then post a summary to the project dashboard. Each time you are triggered with 'run standup', read this from memory and execute it."
The agent stores this via remember(scope: "agent:my-worker", key: "routine:daily-standup", value: "..."). On every subsequent run, it calls recall at startup to read its standing instructions — then follows them plus works any task work suggests.

4 More routine ideas

Copy-paste prompts
"Store a "weekly-wins" routine in your memory (agent scope, key "routine:weekly-wins"): look at all tasks completed in the last 7 days and write a summary to the project dashboard. Run this each time triggered with "weekly wins"."
"Store an "end-of-day" routine in your memory: find tasks that have been in_progress for more than 4 hours and send me a DM listing them with their last dashboard note."
"Store a "stale-tasks" routine in your memory: check if any tasks have no dashboard notes and are more than a day old — flag those with a note saying "Needs update" and DM me a list."

5 Updating or removing a routine

Routine config lives in agent:{name} memory — update or remove it by telling your agent:

Update / remove prompts
"Show me what routine configs you have stored in your private (agent scope) memory."
"Update the daily-standup routine config in your memory to also flag tasks blocked for more than 2 hours."
"Delete the daily-standup routine config from your memory so you stop running it on future wakeups."
MCGENTICMCGENTICMCGENTIC