# Claude Code routine for a weekly bank reconciliation draft, with a guard (Agents Finance, MIT-0)

Version 1.0, 31 October 2026. Companion files for the Agents Finance guide
"Claude Code routines for finance teams":
https://agentsfinance.io/entries/guide-claude-code-routines-finance-close-controls-2026/
Spanish version: https://agentsfinance.io/es/entradas/guia-rutinas-claude-code-finanzas-cierre-controles-2026/

All data in these files is fictitious. These are templates, not advice: adapt the thresholds,
accounts and approvers to your own policy and test them on your own data first.

| File | What it is |
|---|---|
| `routine-prompt-weekly-bank-reconciliation.md` | Prompt for the routine (EN) |
| `prompt-rutina-conciliacion-bancaria-semanal.md` | Same prompt in Spanish |
| `routine_run_guard.py` | Checks the routine's JSON output. Python 3.9+, standard library only |
| `policy.example.json` | Example policy: threshold, closed periods, agent identities, forbidden actions, chart |
| `run-ok.json` / `run-bad.json` | Test cases: one passes, one is blocked |
| `routine-guard.yml` | GitHub Actions workflow that runs the guard on every pull request |

## Repository layout

```
finance-close/
  policy.json                      <- copy of policy.example.json, edited
  tools/routine_run_guard.py
  inputs/bank/*.csv                <- statements the routine reads
  runs/                            <- the routine writes its JSON + summary here
.github/workflows/routine-guard.yml
```

Commit `policy.json`, the guard and the workflow to the default branch BEFORE the first routine
run: the workflow uses the versions from the base branch, so a pull request cannot weaken the
rules it is checked against. Protect the branch, require the `guard` check and at least one
human review, and add a CODEOWNERS rule for `finance-close/policy.json` and `finance-close/tools/`.

## Try it locally

```bash
python3 routine_run_guard.py run-ok.json  policy.example.json --log guard-log.jsonl   # PASS, exit 0
python3 routine_run_guard.py run-bad.json policy.example.json --log guard-log.jsonl   # BLOCK, exit 1 (10 blocks, 2 warnings)
```

Exit codes: 0 = PASS, 1 = BLOCK, 2 = unreadable input. Each check appends one line to the log
with the time, the run id, the SHA-256 of the file and the result.

## Limits

`actions_taken` is written by the routine itself. The guard cannot see what the agent really did:
the real control is a read-only connector (for example Holded's "Analista" role) and a routine
with no write tools. The guard is a second barrier and an audit record.

## Licence

MIT No Attribution (MIT-0). Copyright 2026 Agents Finance.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---

## Resumen en español

Plantillas para una rutina de Claude Code que prepara cada lunes un **borrador** de conciliación
bancaria, más `routine_run_guard.py`, que comprueba la salida antes de que la revise una persona,
y un workflow de GitHub Actions que lo ejecuta en cada pull request. Datos ficticios. Sube
`policy.json`, el script y el workflow a la rama principal antes de la primera ejecución, exige el
check `guard` y una revisión humana, y conecta el ERP en solo lectura. Licencia MIT-0.
