Skip to content
Automation
Command

/legal-loop

Iterate a worker-evaluator cycle against a Goal Record until the success condition is met or a stop limit is reached. The evaluator (a different agent than the worker) judges each iteration using MCP verification tools. Produces an auditable verdict trail and a final MET / NOT

From plugin
bettercallclaude
3526 skills21 agents26 commands
Install
$ npx -y skills add fedec65/bettercallclaude --agent claude-code

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/legal-loop

Context preview

What this command does when you run it.

Iterate a worker-evaluator cycle against a Goal Record until the success condition is met or a stop limit is reached. The evaluator (a different agent than the worker) judges each iteration using MCP verification tools. Produces an auditable verdict trail and a final MET / NOT

Command definition

legal-loop.md
description: "Iterate a worker-evaluator cycle against a Goal Record until the success condition is met or a stop limit is reached. The evaluator (a different agent than the worker) judges each iteration using MCP verification tools. Produces an auditable verdict trail and a final MET / NOT MET status."
tools:
  - Read
  - Grep
  - Glob
  - Bash
  - WebSearch
  - WebFetch
  - mcp__plugin_bettercallclaude_bge-search__search_bge
  - mcp__plugin_bettercallclaude_bge-search__get_bge_decision
  - mcp__plugin_bettercallclaude_entscheidsuche__search_decisions
  - mcp__plugin_bettercallclaude_fedlex-sparql__search_legislation
  - mcp__plugin_bettercallclaude_fedlex-sparql__get_article
  - mcp__plugin_bettercallclaude_fedlex-sparql__lookup_statute
  - mcp__plugin_bettercallclaude_legal-citations__validate_citation
  - mcp__plugin_bettercallclaude_legal-citations__standardize_document_citations
  - mcp__plugin_bettercallclaude_legal-citations__extract_citations
  - mcp__plugin_bettercallclaude_onlinekommentar__search_commentaries
  - mcp__plugin_bettercallclaude_swiss-caselaw__get_decision
  - mcp__plugin_bettercallclaude_swiss-caselaw__get_erwaegung
  - mcp__plugin_bettercallclaude_swiss-caselaw__get_regeste
  - mcp__plugin_bettercallclaude_swiss-caselaw__find_citations
  - mcp__plugin_bettercallclaude_swiss-caselaw__find_relevant_erwaegung
  - mcp__plugin_bettercallclaude_swiss-caselaw__check_claim_support
  - mcp__plugin_bettercallclaude_swiss-caselaw__attest_response
  - mcp__plugin_bettercallclaude_swiss-caselaw__get_commentary
  - mcp__plugin_bettercallclaude_swiss-caselaw__cite
  - mcp__plugin_bettercallclaude_ollama__ollama_check_status
  - mcp__plugin_bettercallclaude_ollama__ollama_classify_privacy

/legal-loop — Worker-Evaluator Iteration Cycle

You are invoked via `/bettercallclaude:legal-loop`. You run the worker-evaluator cycle against a confirmed Goal Record until the success condition is met, max iterations are reached, or a stop condition triggers.

**Output convention**: Write iteration verdicts to `bcc-output/loops/<goal-id>/iteration-<n>.md`, summary to `summary.md`, final artifact to `final/`. In chat, give the convergence summary and final MET/NOT MET status. See `skills/shared/SKILL.md`.

Parameters

  • First positional argument: a Goal Record id or path (e.g., `goal-1782651000-citations-clean`).
  • `--max-iterations=N`: override the Goal Record's max iterations.
  • `--dry-run`: execute one work step + one verdict, then stop (no looping). Useful for testing.
  • `--resume`: resume a previously stopped loop from the last iteration.
  • `--verbose`: show full verdict details in chat after each iteration (default: show only score + finding count).

**Natural language equivalents**:

  • "esegui il loop" or "run the loop" → start the loop
  • "prova secca" or "dry run" → `--dry-run`
  • "riprendi" or "resume" → `--resume`
  • "massimo 3 giri" or "max 3 rounds" → `--max-iterations=3`

Pre-Flight Checks

Before starting the loop, verify:

1. **Goal Record exists and is confirmed.** If not found or status is not `confirmed`, refuse:

   ERROR: Goal Record <id> not found or not confirmed.
   Run /legal-goal to define and confirm a goal first.

2. **Worker-evaluator separation.** The evaluator agent/role MUST differ from the worker. If they resolve to the same agent:

   REFUSED: worker and evaluator resolve to the same agent/role (<name>).
   The loop cannot proceed. Use /legal-goal to assign a distinct evaluator.

3. **Target artifact or context exists.** The inputs specified in the Goal Record must be accessible.

Iteration Cycle

Step 1: Privacy Pre-Check

Run the local Ollama privacy classifier on any content that would be sent to cloud MCP tools in this iteration.

  • If `privacy_mode = strict` and privileged content is detected: **HALT immediately**.
  HALTED: Privacy violation detected. Privileged content (Anwaltsgeheimnis)
  would cross a boundary disallowed by strict mode. Loop stopped.
  Manual review required before proceeding.
  • If `privacy_mode = balanced`: route privileged content through local tools only; cloud tools receive sanitised content.
  • If `privacy_mode = cloud`: proceed (user has explicitly accepted cloud processing).

The privacy check runs EVERY iteration, not just the first.

Step 2: Work Step

Invoke the worker agent/command to produce or revise the artifact.

  • **First iteration**: worker produces the initial artifact from the Goal Record inputs.
  • **Subsequent iterations**: worker receives the previous iteration's FAIL findings as instructions. The worker is told precisely what is still wrong and must fix exactly those issues. The worker does NOT see the score or pass/fail status — only the findings list.

The worker operates under all existing BetterCallClaude rules:

  • R1 (no self-constructed citation strings) is enforced
  • R2 (no quotation without verbatim source) is enforced
  • Privacy routing applies
  • Output conventions apply

Step 3: Verdict Step

Invoke the evaluator (the `legal-evaluator` skill) which: 1. Runs the substantive citation gate (`citation-content-verify` stage): every citation in the artifact is checked against the live source for existence AND content support. Any `UNVERIFIED`/`MISMATCH` citation means the verdict cannot be `pass: true` — the blocked citations are fed to the worker as FAIL findings. 2. Runs the authoritative MCP checks specified in the Goal Record 3. Applies R1/R2 enforcement on all citations/quotations 4. Returns a structured Verdict: `pass`, `score`, `findings`

The evaluator is a DIFFERENT agent/role than the worker — this is the fundamental guarantee.

Step 4: Decision

| Condition | Action | |-----------|--------| | `pass: true` | Record success. Stop. Emit final artifact + verdict trail. Status: **MET**. | | `pass: false` AND iterations remain AND no stop condition triggered | Feed findings to worker. Go to Step 1 for next iteration. | | Max iterations re

Read more
Ships withbettercallclaude

A powerful plugin for Claude Cowork Desktop, designed specifically for Swiss legal professionals. 20 agents, 14 skills, and 9 MCP servers — automate research, draft documents, and navigate complex legal landscapes with AI-powered precision.

Get the whole plugin, auto-invoked
Stats
35
Stars
0
Views
8
Forks
Active
Maintenance
JavaScript
Language
AGPL-3.0
License
3d ago
Last commit
6mo ago
Created

Repo: fedec65/bettercallclaude