
Anomaly / Outlier Scan
Scan a dataset for anomalies and outliers and report what is genuinely unusual versus expected noise. Defines the detection criteria and thresholds FIRST (statistical and rule-based, with an explicit definition of 'anomalous') so findings are reproducible, then runs the scan to flag and rank suspect records, then writes a prioritized report a human can triage. Use this for outlier detection, anomaly scanning, finding bad records, fraud/error spotting, or surfacing data points that don't fit.
Steps
Entry step: criteria. Each step names the specialist role it wants; the full working prompt is expandable.
- Define detection criteriadata-analystentry
lock what counts as anomalous and the thresholds
Show working prompt
Define exactly what 'anomalous' means before scanning, so results are reproducible. Step 1: choose which columns/metrics to scan and the expected normal behavior of each. Step 2: pick detection methods per column — statistical (z-score > 3, IQR fence at 1.5x, percentile cutoffs) for numerics; rule-based (impossible/contradictory values, future dates, out-of-domain categories, broken referential integrity) where rules apply. Step 3: set concrete thresholds and a severity scale (e.g. high = impossible value or z > 4; medium = z 3-4). Step 4: decide how to rank flagged records. Step 5: write an acceptance-criteria checklist ('every method has a stated threshold', 'each flag records the rule it tripped and a severity', 'findings are ranked', 'false-positive rate is considered'). Call write_task_note and write the methods + thresholds + checklist to notes/criteria.md. No scanning yet. - Run the scandeveloper
apply the criteria and emit ranked flagged records
Show working prompt
Apply the detection criteria to the full dataset deterministically. Step 1: compute the per-column statistics the thresholds need (mean/stdev, quartiles, value-domain sets). Step 2: evaluate every record against each method and collect the flags it trips, with the measured value and the threshold it breached. Step 3: assign each flagged record a severity and a reason string. Step 4: rank flagged records by severity then magnitude. Step 5: emit data/anomalies.json — a ranked list of { record id/row, column, value, rule, threshold, severity } plus a summary count by severity. Do not flag records that don't breach a stated threshold. Call write_task_note with the counts by severity and the top findings. - Report the findingscopywriter
write a prioritized, triage-ready anomaly report
Show working prompt
Turn the flagged records into a report a human can triage — use only what the scan found. Step 1: open with a summary: how many records scanned, how many flagged, and the breakdown by severity. Step 2: list the top findings highest-severity first, each with the record, the value, what's wrong, and why it tripped (the rule + threshold). Step 3: group repeated patterns ('14 rows have a negative price') rather than listing each identically. Step 4: separate likely-real anomalies from probable noise/false-positives and say which deserve action. Step 5: end with recommended next steps. Write the report to report.md and call write_task_note with the path. On a loop-back, fix only the named gaps. - Evaluatereviewer
Grade the deliverable against every acceptance criterion. All pass → finish; any fail → loop back and fix the gap.
Show working prompt
Read report.md and cross-check it against notes/criteria.md and data/anomalies.json. Verify: every detection method named a concrete threshold; each reported flag records the rule it tripped, the value, and a severity; findings are ranked highest-severity first; repeated patterns are grouped, not duplicated; and likely false-positives are separated from real anomalies. Re-derive two flagged records from the criteria to confirm they genuinely breach a threshold (no spurious flags). Write PASS/FAIL per criterion; any FAIL loops back to report. Then route — this is the whole point of the loop: - **Every criterion PASSES →** call `advance_task_step({ ref, stepId: "evaluate", next: "finish" })`. - **Any criterion FAILS →** write the specific gaps to notes, then call `advance_task_step({ ref, stepId: "evaluate", next: "report" })` to loop back. The builder fixes exactly those gaps. Never route to `finish` while any criterion is unmet. The build phase's completion gate already blocked a grossly-incomplete deliverable; your job is the judgment an automated check cannot make (does it actually work, read well, look right). After ~3 unproductive loops, stop and report DONE_WITH_CONCERNS so the user can step in. - Finishdeveloper
All acceptance criteria met. Stamp a short summary and report DONE.
Show working prompt
Every acceptance criterion passed. Write a one-paragraph DONE summary to task notes via `write_task_note`: what was built, the deliverable path(s), and a one-line confirmation that each criterion is met. Then report DONE.
Triggers
Phrases that suggest this craftbook to a crew.
- find anomalies
- detect outliers
- scan for bad records
- spot unusual data
- outlier detection
Source
View this craftbook on GitHub · MIT license