Skip to main content
skill CX Codex

write-code-eval — Claude Code skill: code evaluators for evals

Write a code evaluator for a known failure mode: one check per rule, like a unit test that asserts what should hold for each trace.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add ai-evals-course/evals-skills --skill write-code-eval -a claude-code
Open on GitHub

What write-code-eval does

The skill starts from a failure mode you found during error analysis and turns it into a single check. You state the rule, then identify the trace fields or reference data the check needs. If the rule calls for interpretation, the skill points you to write-judge-prompt instead.

Implementation happens in your project's language and eval framework, and the check returns a result plus a reason in the format that framework expects. A table of common cases covers invalid output structure, missing or forbidden text, citations that are not in the retrieved documents, bad tool calls, and wrong values. Pick the check from the failure rule, not from what is easiest to write.

Then test known passes and failures, borderline cases included. Run the check over available traces and look at where it gets things wrong. If your rule stands in for human judgement, compare its results against human labels. That comparison is where proxy checks usually break: they look fine on the sample you wrote them against and drift on real traces.

What it helps with

  • write a check for a failure mode found in error analysis
  • compare cited IDs against retrieved document IDs
  • validate tool call arguments against the tool schema
  • catch invalid output structure and missing fields
  • compare output against a reference value

Example prompts for the agent

  • Write a code evaluator for this failure mode: the output drops a required field
  • Add a check that every citation appears in the retrieved documents
  • Validate the tool call arguments against the schema in a safe test environment

How to install write-code-eval

1Skills CLI (Vercel)

npx skills add ai-evals-course/evals-skills --skill write-code-eval -a claude-code

2Manually: put the files in place

~/.claude/skills/write-code-eval/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/write-code-eval/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about write-code-eval

How do I install write-code-eval in Claude?

Run npx skills add ai-evals-course/evals-skills --skill write-code-eval -a claude-code. The skill lands in ~/.claude/skills/write-code-eval/SKILL.md.

What does write-code-eval do?

It helps you write a code check for a known failure mode with an objective rule, returning a result and a reason in your eval framework's format.

When should I use write-judge-prompt instead?

When the rule needs interpretation rather than code. For a failure with both objective and interpretive parts, check the objective part with code and hand the rest to a judge.

Source text

SKILL.md · Apache-2.0
---
name: write-code-eval
description: >
  Write code evaluators for known failure modes with objective rules. Use when
  code can check the rule from a trace, with or without a reference answer.
  Use `write-judge-prompt` when the rule requires interpretation.
---

# Write a code evaluator

Start with a failure mode found through error analysis. Write one check for that failure mode, much like a unit test that asserts what should hold for each trace.

1. State the rule and identify the trace fields or reference data the check needs. If the rule requires interpretation, use `write-judge-prompt`.
2. Implement the check in the project's language and eval framework. Return a result and a reason in the format that framework expects.
3. Test known passes and failures, including borderline cases. Run the check on available traces and inspect mistakes. If the rule uses a proxy for human judgment, compare its results with human labels.

## Examples

| Failure mode | Possible check |
|---|---|
| Invalid output structure | Parse the output and check required fields |
| Missing or forbidden text | Match a string or pattern |
| Citation not in retrieved documents | Compare cited IDs with retrieved IDs |
| Bad tool call | Check arguments against the tool schema or run the call in a safe test environment |
| Wrong value | Compare the output with a reference value |

Choose the check from the failure rule. For a failure with both objective and interpretive parts, check the objective part with code and use a judge for the rest.

© ai-evals-course · Apache-2.0 · ai-evals-course/evals-skills

Similar skills

Everything for AI and ML →

From the same set9

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor