Skip to main content

What you will have

A roster agent called Monitor Agent that runs every weekday morning, finds that day’s exports in a SharePoint folder, and turns them into one row per merchant in a tracker workbook plus a short summary in #fraud-monitoring. Every number in the output comes from three Python scripts bundled with its skill: they parse the files, compute each merchant’s fraud-to-sales ratios against fixed thresholds, and reconcile the totals before anything is written. The model decides only what a script can’t: which folder is today’s, whether an input is missing, and one sentence on why each new breach matters. Run it twice on the same files and you get the same rows. This guide follows the six steps of Build an agent. It is the worked example for Code or prompt: the whole job is a fixed sequence of parsing, arithmetic and lookups, so it lives in scripts and the agent runs them.

The agent spec

Inputs and output

The processor drops three files into Fraud monitoring/in/<YYYY-MM-DD>/ every morning: The output goes to the Daily table of Fraud monitoring tracker.xlsx, one row per merchant with reports: date, merchant_id, fraud_count, fraud_amount, sales_count, count_ratio, amount_ratio, tier, watchlist, new. A merchant is breach when it has at least 10 reports and $5,000 reported and either ratio reaches 0.90%, watch when either ratio reaches 0.65%, no-volume when it has reports but no sales this month, and ok otherwise. new marks a watch or breach that differs from the merchant’s last tier in the tracker. The thresholds here are illustrative; put your own program’s in assets/thresholds.json.

1. Define the job

Read Define the job first. Decide what is code and what is judgment before you write a word of instructions: here every count, sum, ratio and tier is code, and the agent only orchestrates.
1

Create the roster agent

Go to Agents and click New Agent. On Profile name it Monitor Agent. On Instructions, use this description:
Scores the day’s fraud report against merchant sales volume with fixed scripts, appends the results to the fraud monitoring tracker and posts a summary. Never acts on a merchant.
And these system instructions:
Skip Triggers for now and click Create agent.
2

Point it at a template

Open the agent’s card. Under Default template pick Fraud Monitoring (created in step 3; come back and set it if the template does not exist yet). Leave Coding agent on Claude Code. Click Save profile.

2. Measure success

Read Measure success. A deterministic job has an unusually sharp criterion: the output either equals the scripts’ output or it doesn’t.
1

Add two evaluation categories

On the agent’s Performance tab, add:Set Human cost to $20 and Human time to 45 minutes for both, and a monthly budget of $150.
Session grades tell you whether a run did its job. The scripts have their own tests in the skill’s eval suite, run before you publish a change to them: see Skill evals and session evals.

3. Give it tools

Read Give it tools. One system, scoped to one folder.
1

Create the Fraud Monitoring template

Go to Templates, click New Template, choose Blank environment, name it Fraud Monitoring, keep Basic and click Create Template. Nothing is cloned; the template carries the connection and the skill.
2

Microsoft 365, agent-scoped, one folder

Open Monitor Agent’s sheet and connect Microsoft 365 there, signed in as the risk team’s service account, so the connection belongs to this agent only. Then, in the agent’s Microsoft 365 access settings, paste the SharePoint link of the Fraud monitoring folder (Copy link in SharePoint). The agent can open that folder and everything in it, and nothing else on the site. Put the tracker workbook inside the folder too.

4. Define how it works

Read Define how it works and Code or prompt. The runbook is a skill whose steps are commands, and the scripts are files in that skill.
1

Write the fraud-monitoring skill

Under Settings > Context > Skills, click New skill and create fraud-monitoring with this SKILL.md:
Then add the scripts and the thresholds file. Each script declares its own dependencies in a PEP 723 header, so uv run uses the same openpyxl on every run.scripts/parse_inputs.py reads the three inputs into one JSON file and puts every row it can’t read in exceptions, with its file and row number:
scripts/score.py aggregates reports per merchant, computes both ratios with Decimal, assigns the tier, compares it with the tracker’s last tier for that merchant, and writes rows.json (sorted, most severe first) and summary.md:
scripts/validate.py reconciles the run before anything is written: every input row is either parsed or an exception, the amounts and counts in the rows add up to the parsed reports, and each merchant appears once:
assets/thresholds.json:
Set Requires integrations to microsoft-365 and Required tooling to uv: latest. Then attach the skill to the Fraud Monitoring template.
2

Build the template once

On Templates, open Fraud Monitoring and click Build on the Build tab. Wait for ready. The build installs uv; the first run downloads openpyxl once.
3

Create the schedule, disabled

On Agents, open the Scheduled tab and click New scheduled agent. Name it Fraud monitoring. For the prompt, write:
Run the fraud-monitoring skill for today’s inputs. If an input is missing or a check fails, say which and write nothing.
Set run-as to Agent and pick Monitor Agent, so the agent-scoped Microsoft 365 connection applies and the run is graded. Set the schedule to weekdays at 13:00 UTC, after the processor’s drop. Under Post, pick #fraud-monitoring. Create it, then flip the toggle off until step 5 proves it.

5. Prove it works and iterate

Read Prove it works and iterate and Skill evals and session evals. Test it like software: many skill evals at the bottom (unit tests against fixed files), a few scheduled runs at the top (integration tests against SharePoint).
1

Give the skill its unit tests

Open the skill with Edit and build its eval suite in the editor session. Each case is a folder of input files and the exact rows they must produce, so a ratio that drifts by one digit fails:
Take the inputs from days an analyst already checked, or ask the agent to build them: “Make a day where one merchant crosses from watch to breach, one is on the watchlist, and one has no sales; save the expected rows.” One case per rule: each tier boundary and a value just under it (rounding before comparing would tip it over), the minimum-count floor, a bad row, a missing file, a merchant with no previous tier. same_json.py is the comparison script from Fixtures and expected outcomes. A case in evals.json:
Click Run evals. The suite needs no Microsoft 365 connection and runs in minutes, so run it on every change to a script or a threshold, and publish only when it passes. The fixtures are spreadsheets, which Publish would save as text: after publishing, add each one with runtm-api skills upload-file <skill_id> --file <path> --path <same path> --mode binary.
2

Run three known days

For each day, change the schedule’s prompt to name it (“Run the fraud-monitoring skill for 2026-11-18.”), click Run now, and compare the appended rows with the checked ones. They must match exactly, every ratio and tier. Then run one day with sales_volume.xlsx removed: the run must stop, name the file and append nothing.
3

Fix the script, not the prompt

A mismatch is a script bug or a threshold question, never an instruction to “be more careful”. Turn the failing day into a fixture with its correct rows, add the case, fix the script until the suite passes, publish, and rerun the day. The case now guards every later edit.
4

Restore the prompt

Put the prompt back to today’s inputs before enabling.

6. Add guardrails and approvals

Read Add guardrails and approvals. The proven runs used a handful of commands; allow those and deny the rest of what the helper can do.
1

Command rules

On the template’s Guardrails tab, add allow rules for uv run */skills/fraud-monitoring/scripts/* and for the helper’s search, get, download and append, and deny rules for its write, patch, post, send, reply and chat-send. Set the default policy to ask.
2

Network rules

Add host rules for graph.microsoft.com and login.microsoftonline.com (Microsoft 365), pypi.org and files.pythonhosted.org (the pinned openpyxl), and app.runtm.com and docs.runtm.com.
3

Enable the schedule

Run one known day again with Run now to confirm the rules allow everything the job needs, then flip the schedule on.

What stays human

  • Every action on a merchant. Outreach, holds, limit changes and closures are decided by an analyst reading the tracker. The agent’s connection can only reach one folder, and its rules deny sending.
  • The thresholds. assets/thresholds.json changes through a skill edit, reviewed and tested against the eval suite, never during a run.
  • A failed check. When validate.py fails, a person looks at the inputs; the agent never retries with a workaround.

Gotchas

  • The model doing arithmetic. If a summary ever shows a ratio that isn’t in rows.json, the agent computed it. Tighten the instruction to copy summary.md verbatim and grade daily-run on the numbers.
  • Floats. Ratios and money are Decimal and quantized; a float version of the same script gives different last digits on some inputs and breaks the exact comparison in step 5.
  • Rounding before comparing. Tiers compare the exact ratios and only the tracker gets the rounded ones. Rounding first turns 0.89686% into a 0.90% breach, and the totals still reconcile, so only a just-below-boundary fixture catches it.
  • Unpinned dependencies. Without the PEP 723 header, openpyxl floats to whatever is newest. Pin it, and bump the pin through a skill edit.
  • A header renamed upstream. parse_inputs.py exits naming the missing column instead of guessing. The run stops with nothing written, which is the point.
  • Appending twice. The append is one call with the whole rows.json. A retried run on the same day appends again; check the tracker for the date before appending if your schedule retries.
  • Network rules without PyPI. The first run after a build can’t fetch openpyxl and every script fails. Add pypi.org and files.pythonhosted.org, or install the dependency in the template.

Fraud and risk review agent

A scheduled agent that assembles a review packet for each Radar alert and leaves every block to a human.

Code or prompt

When a step should be a script instead of an instruction.

Build an agent

The six steps this example follows.