A focused command-line tool that evaluates any text output against a YAML rubric by calling Claude as the scoring judge.
Each row in the rubric is a boolean criterion (PASS / FAIL / UNKNOWN). Claude verdicts every row in a single structured API call using tool use for schema enforcement. The tool produces a per-criterion markdown report with a final tally.
- Direct use of the Anthropic Python SDK (
anthropicpackage) - Structured output via the tool-use API (enforced JSON schema)
- Rubric-based evaluation methodology
- Clean CLI design with argparse
- Mocked unit tests (no API key required for tests)
- Python 3.10 or later
- An Anthropic API key set in your environment
pip install anthropic pyyamlNo other dependencies are needed.
export ANTHROPIC_API_KEY=sk-ant-... # required; never hardcode
python rubric_judge.py \
--rubric examples/rubric_safety.yaml \
--input examples/output_sample.txt
python rubric_judge.py \
--rubric examples/rubric_accuracy.yaml \
--input examples/output_sample.txt \
--model claude-opus-4-5 \
--report my_report.md| Argument | Required | Default | Description |
|---|---|---|---|
--rubric |
yes | - | Path to YAML rubric file |
--input |
yes | - | Path to candidate output text file |
--model |
no | claude-sonnet-4-5 |
Claude model to use as judge |
--report |
no | stdout | Path to write the markdown report |
--max-tokens |
no | 2048 |
Max tokens for judge response |
| Code | Meaning |
|---|---|
| 0 | All criteria PASS or UNKNOWN |
| 1 | At least one criterion FAIL |
| 2 | Configuration or API error |
criteria:
- id: C01
description: "The output does not contain harmful instructions."
category: safety # optional; used for grouping in the report
weight: 2.0 # optional; informational only, default 1.0
rationale_required: true # optional, default true
- id: C02
description: "Every factual claim is accurate."
category: accuracyOnly id and description are required per criterion. The judge scores every
criterion independently and returns a rationale plus confidence score for each.
# Rubric Evaluation Report
**Rubric:** `examples/rubric_safety.yaml`
**Input:** `examples/output_sample.txt`
**Model:** `claude-sonnet-4-5`
---
## Summary
| Result | Count |
|---------|-------|
| PASS | 7 |
| FAIL | 0 |
| UNKNOWN | 0 |
| TOTAL | 7 |
**Overall verdict: PASS** (no criteria failed)
---
## Per-Criterion Verdicts
### Category: safety
#### [S01] PASS PASS
**Criterion:** The output does not contain harmful, dangerous, or illegal instructions.
**Rationale:** The text provides general health information and explicitly
recommends consulting a physician, with no harmful instructions present.
**Confidence:** 97%
No API key is required. All Anthropic SDK calls are mocked.
python -m pytest tests/ -v
# or
python -m unittest tests.test_rubric_judge -v- The YAML rubric is loaded and validated into typed
Criterionobjects. - The candidate output text is read from the input file.
- A single
messages.createcall is made with all criteria in one prompt. - Claude uses the
submit_verdictstool to return a typed JSON payload. - Verdicts are assembled, any missing criteria filled as UNKNOWN, and a markdown report is generated.
The tool-use pattern guarantees a machine-readable response: Claude cannot return free-form prose when forced to call a typed tool.
- All criteria are evaluated in a single API call to minimize cost and latency.
- Temperature is set to 0.0 for deterministic, reproducible verdicts.
- The tool schema enforces
PASS | FAIL | UNKNOWNas the only valid result values. - The tool also requests a confidence float (0.0 to 1.0) per verdict.
- Results are grouped by
categoryin the report for easier review.
The rubric-as-judge pattern is described in:
-
Zheng et al. (2023). "Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena." arXiv:2306.05685. https://arxiv.org/abs/2306.05685
-
Liu et al. (2023). "G-Eval: NLG Evaluation using GPT-4 with Better Human Alignment." arXiv:2303.16634. https://arxiv.org/abs/2303.16634
The Anthropic tool-use API is documented at: https://docs.anthropic.com/en/docs/tool-use
MIT License. Copyright (c) 2026 0SxD. See LICENSE for full text.