|
| 1 | +# Evals Framework for Claude Code Skills |
| 2 | + |
| 3 | +A Python framework for systematically evaluating Claude Code skills using a two-stage grading approach. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +```bash |
| 8 | +# Run a single test |
| 9 | +python run_eval.py --plugin power-pages --skill create-site --test test-01 |
| 10 | + |
| 11 | +# Run all tests for a skill |
| 12 | +python run_eval.py --plugin power-pages --skill create-site --all |
| 13 | + |
| 14 | +# Run with model-assisted grading |
| 15 | +python run_eval.py --plugin power-pages --skill create-site --all --grade |
| 16 | + |
| 17 | +# Run all skills in a plugin |
| 18 | +python run_eval.py --plugin power-pages --all |
| 19 | +``` |
| 20 | + |
| 21 | +## Folder Structure |
| 22 | + |
| 23 | +``` |
| 24 | +evals/ |
| 25 | +├── README.md # This file |
| 26 | +├── run_eval.py # Main eval runner CLI |
| 27 | +├── grade_eval.py # Standalone grading CLI |
| 28 | +├── __init__.py |
| 29 | +├── shared/ # Shared utilities |
| 30 | +│ ├── __init__.py |
| 31 | +│ ├── helpers.py # Data classes and helper functions |
| 32 | +│ ├── runner.py # EvalRunner class |
| 33 | +│ ├── grader.py # Grader class |
| 34 | +│ └── rubrics/ # Grading rubric schemas |
| 35 | +│ ├── skill-trigger.schema.json |
| 36 | +│ ├── code-quality.schema.json |
| 37 | +│ └── process.schema.json |
| 38 | +├── power-pages/ # Plugin-specific evals |
| 39 | +│ ├── __init__.py |
| 40 | +│ ├── create-site/ |
| 41 | +│ │ └── prompts.csv |
| 42 | +│ ├── setup-webapi/ |
| 43 | +│ │ └── prompts.csv |
| 44 | +│ ├── setup-dataverse/ |
| 45 | +│ │ └── prompts.csv |
| 46 | +│ ├── setup-auth/ |
| 47 | +│ │ └── prompts.csv |
| 48 | +│ ├── integrate-webapi/ |
| 49 | +│ │ └── prompts.csv |
| 50 | +│ ├── add-seo/ |
| 51 | +│ │ └── prompts.csv |
| 52 | +│ ├── add-tests/ |
| 53 | +│ │ └── prompts.csv |
| 54 | +│ └── add-sample-data/ |
| 55 | +│ └── prompts.csv |
| 56 | +├── artifacts/ # Test outputs (gitignored) |
| 57 | +└── reports/ # Aggregate reports (gitignored) |
| 58 | +``` |
| 59 | + |
| 60 | +## Prompt CSV Format |
| 61 | + |
| 62 | +Each skill has a `prompts.csv` file defining test cases: |
| 63 | + |
| 64 | +```csv |
| 65 | +id,should_trigger,prompt,expected_skill,notes |
| 66 | +test-01,true,"Create a demo app using /create-site",create-site,Explicit skill invocation |
| 67 | +test-02,true,"Build a React Power Pages site",create-site,Implicit invocation |
| 68 | +test-03,false,"Add Tailwind to my existing app",create-site,Negative control |
| 69 | +``` |
| 70 | + |
| 71 | +**Fields:** |
| 72 | +- `id`: Unique test identifier |
| 73 | +- `should_trigger`: Whether the skill should be invoked (true/false) |
| 74 | +- `prompt`: The user prompt to test |
| 75 | +- `expected_skill`: The skill expected to trigger (for positive cases) |
| 76 | +- `notes`: Description of what the test validates |
| 77 | + |
| 78 | +## Two-Stage Grading |
| 79 | + |
| 80 | +### Stage 1: Deterministic Checks (Fast) |
| 81 | + |
| 82 | +Automated checks parsed from the execution trace: |
| 83 | +- Execution success (no errors) |
| 84 | +- Response generated |
| 85 | +- Reasonable token usage (< 50k) |
| 86 | +- Reasonable turn count (< 20) |
| 87 | + |
| 88 | +### Stage 2: Model-Assisted Rubric (Qualitative) |
| 89 | + |
| 90 | +Claude evaluates against rubric criteria: |
| 91 | +- **skill_invocation**: Correct skill invoked/not invoked |
| 92 | +- **response_quality**: Helpful, clear, appropriate response |
| 93 | +- **tool_usage**: Tools used efficiently |
| 94 | +- **plan_mode**: Plan mode used when appropriate |
| 95 | + |
| 96 | +## CLI Reference |
| 97 | + |
| 98 | +### run_eval.py |
| 99 | + |
| 100 | +``` |
| 101 | +python run_eval.py --plugin PLUGIN --skill SKILL --test TEST_ID |
| 102 | +python run_eval.py --plugin PLUGIN --skill SKILL --all [--grade] |
| 103 | +python run_eval.py --plugin PLUGIN --all [--grade] |
| 104 | +
|
| 105 | +Arguments: |
| 106 | + --plugin Plugin name (required, e.g., power-pages) |
| 107 | + --skill Skill name (optional, e.g., create-site) |
| 108 | + --test Specific test ID (e.g., test-01) |
| 109 | + --all Run all tests |
| 110 | + --grade Enable model-assisted grading |
| 111 | + --timeout Timeout per test in seconds (default: 300) |
| 112 | +``` |
| 113 | + |
| 114 | +### grade_eval.py |
| 115 | + |
| 116 | +``` |
| 117 | +python grade_eval.py --plugin PLUGIN --skill SKILL --test TEST_ID |
| 118 | +python grade_eval.py --artifacts-path PATH |
| 119 | +
|
| 120 | +Arguments: |
| 121 | + --plugin Plugin name |
| 122 | + --skill Skill name |
| 123 | + --test Test ID to grade |
| 124 | + --artifacts-path Direct path to artifacts (alternative) |
| 125 | +``` |
| 126 | + |
| 127 | +## How It Works |
| 128 | + |
| 129 | +1. **Load prompts**: Read test cases from `prompts.csv` |
| 130 | +2. **Execute Claude**: Run `claude -p --output-format=json "<prompt>"` |
| 131 | +3. **Parse output**: Extract result, metrics, and tool usage |
| 132 | +4. **Check trigger**: Determine if skill was invoked |
| 133 | +5. **Grade (optional)**: Run two-stage grading |
| 134 | +6. **Save artifacts**: Store results in `artifacts/` directory |
| 135 | + |
| 136 | +## Output Format |
| 137 | + |
| 138 | +Claude outputs JSON in this format: |
| 139 | + |
| 140 | +```json |
| 141 | +{ |
| 142 | + "type": "result", |
| 143 | + "subtype": "success", |
| 144 | + "is_error": false, |
| 145 | + "result": "Response text...", |
| 146 | + "session_id": "...", |
| 147 | + "duration_ms": 4437, |
| 148 | + "num_turns": 1, |
| 149 | + "total_cost_usd": 0.19, |
| 150 | + "usage": { |
| 151 | + "input_tokens": 2, |
| 152 | + "output_tokens": 12, |
| 153 | + "cache_creation_input_tokens": 30452 |
| 154 | + } |
| 155 | +} |
| 156 | +``` |
| 157 | + |
| 158 | +## Adding New Evals |
| 159 | + |
| 160 | +1. Create a new skill folder under the plugin directory |
| 161 | +2. Add `prompts.csv` with test cases |
| 162 | +3. Run with `python run_eval.py --plugin <plugin> --skill <skill> --all` |
| 163 | + |
| 164 | +## Interpreting Results |
| 165 | + |
| 166 | +### Pass Criteria |
| 167 | + |
| 168 | +- **Skill Trigger**: Correct skill invoked (or not invoked for negative cases) |
| 169 | +- **Process**: Execution completed successfully without errors |
| 170 | +- **Quality**: Response is helpful and appropriate (model-assisted) |
| 171 | + |
| 172 | +### Score Ranges |
| 173 | + |
| 174 | +- **90-100**: Excellent - All checks pass |
| 175 | +- **70-89**: Good - Minor issues |
| 176 | +- **50-69**: Fair - Some checks fail |
| 177 | +- **0-49**: Poor - Major issues |
| 178 | + |
| 179 | +## Requirements |
| 180 | + |
| 181 | +- Python 3.10+ |
| 182 | +- Claude CLI installed and configured |
| 183 | +- No additional Python dependencies (uses stdlib only) |
0 commit comments