Skip to content

28 eval-informed mental models and critical-thinking skills for Claude Code, GitHub Copilot, Codex, Cursor, and other Agent Skills-compatible tools

feat: add scientific-method routing-boundary eval

Travis Boudreauxf529a43c95a3
diff --git a/evals/datasets/scientific-method-routing-boundary.json b/evals/datasets/scientific-method-routing-boundary.json
new file mode 100644
index 0000000..f5a1ccd
--- /dev/null
+++ b/evals/datasets/scientific-method-routing-boundary.json
@@ -0,0 +1,45 @@
+{
+ "schema_version": 1,
+ "cases": [
+ {
+ "id": "live-p99-causes",
+ "expected": "thinking-scientific-method",
+ "prompt": "Our API p99 latency tripled last Tuesday. Several deploy, database, and gateway causes are still plausible, and I have traces and diffs available now. Help me localize the faulty component before changing anything."
+ },
+ {
+ "id": "live-export-corruption",
+ "expected": "thinking-scientific-method",
+ "prompt": "There are five competing theories for why large exports are corrupted. We can inspect code, logs, and fixtures now, and I need to determine which file or invariant is actually responsible."
+ },
+ {
+ "id": "live-metric-drop",
+ "expected": "thinking-scientific-method",
+ "prompt": "Daily active users suddenly dropped 15%. Marketing, product, and data engineering each have a different causal theory. The change is still unlocalized and we can query the pipelines now."
+ },
+ {
+ "id": "live-duplicate-charge",
+ "expected": "thinking-scientific-method",
+ "prompt": "Duplicate card charges began after an SDK bump, retry change, and idempotency-key change. Before any rollback, use the evidence we already have to localize which implementation path is at fault."
+ },
+ {
+ "id": "postmortem-bad-config",
+ "expected": "thinking-five-whys-plus",
+ "prompt": "Yesterday's outage is already localized to a bad config accepted by the deploy pipeline. I need the post-incident analysis to explain why our review and validation controls allowed it and how to prevent recurrence."
+ },
+ {
+ "id": "postmortem-leak",
+ "expected": "thinking-five-whys-plus",
+ "prompt": "We found the production memory leak in worker/cache.py and shipped the fix. Now help me trace the organizational and technical conditions that let it escape tests and monitoring."
+ },
+ {
+ "id": "postmortem-permission",
+ "expected": "thinking-five-whys-plus",
+ "prompt": "The faulty permission check has been identified and patched. The remaining question is why multiple safeguards failed and what systemic prevention belongs in the incident report."
+ },
+ {
+ "id": "postmortem-schema",
+ "expected": "thinking-five-whys-plus",
+ "prompt": "The incident was conclusively localized to a schema migration ordering bug. I am not asking where the bug is; I need to understand why the process produced and missed it so we can prevent a repeat."
+ }
+ ]
+}
diff --git a/evals/lib/routing-boundary.js b/evals/lib/routing-boundary.js
new file mode 100644
index 0000000..47e08f1
--- /dev/null
+++ b/evals/lib/routing-boundary.js
@@ -0,0 +1,47 @@
+'use strict';
+
+function applyDescriptionOverride(catalog, skillName, description) {
+ let found = false;
+ const updated = (catalog || []).map((skill) => {
+ if (skill.name !== skillName) return { ...skill };
+ found = true;
+ return { ...skill, description };
+ });
+ if (!found) throw new Error(`catalog skill not found: ${skillName}`);
+ return updated;
+}
+
+function scoreRoutingBoundary(results) {
+ const rows = (results || []).filter((row) => row && row.arm_id && row.expected);
+ const armIds = [...new Set(rows.map((row) => row.arm_id))];
+ const byArm = {};
+ for (const armId of armIds) {
+ const armRows = rows.filter((row) => row.arm_id === armId);
+ const scientific = armRows.filter((row) => row.expected === 'thinking-scientific-method');
+ const fiveWhys = armRows.filter((row) => row.expected === 'thinking-five-whys-plus');
+ const correct = (subset) => subset.filter((row) => row.chosen === row.expected).length;
+ byArm[armId] = {
+ n: armRows.length,
+ strict_accuracy: armRows.length ? correct(armRows) / armRows.length : null,
+ scientific_method_accuracy: scientific.length ? correct(scientific) / scientific.length : null,
+ five_whys_accuracy: fiveWhys.length ? correct(fiveWhys) / fiveWhys.length : null,
+ };
+ }
+ const current = byArm.current;
+ const boundary = byArm.boundary;
+ const boundaryPass = Boolean(
+ current
+ && boundary
+ && boundary.strict_accuracy > current.strict_accuracy
+ && boundary.five_whys_accuracy >= current.five_whys_accuracy,
+ );
+ return {
+ by_arm: byArm,
+ boundary_pass: boundaryPass,
+ };
+}
+
+module.exports = {
+ applyDescriptionOverride,
+ scoreRoutingBoundary,
+};
diff --git a/evals/run-routing-boundary.js b/evals/run-routing-boundary.js
new file mode 100644
index 0000000..c9bc2da
--- /dev/null
+++ b/evals/run-routing-boundary.js
@@ -0,0 +1,121 @@
+#!/usr/bin/env node
+'use strict';
+
+const fs = require('fs');
+const path = require('path');
+const { loadAllSkills } = require('./lib/skills');
+const {
+ droidJsonAsync,
+ maxEffortFor,
+ usageSummary,
+ aggregateUsage,
+} = require('./lib/droid');
+const { mapPool, writeJsonAtomic } = require('./lib/io');
+const { deterministicArmOrder } = require('./lib/objective');
+const { sha256 } = require('./lib/result');
+const {
+ applyDescriptionOverride,
+ scoreRoutingBoundary,
+} = require('./lib/routing-boundary');
+
+const MODEL = process.env.ROUTER_MODEL || 'claude-sonnet-4-6';
+const CONCURRENCY = Math.max(1, Number(process.env.CONC || 4));
+const DATASET = path.join(__dirname, 'datasets', 'scientific-method-routing-boundary.json');
+const OUT = process.env.OUT
+ ? path.resolve(process.env.OUT)
+ : path.join(__dirname, 'results', 'local', 'scientific-method-routing-boundary.json');
+const BOUNDARY_DESCRIPTION = 'When several observable causes could explain a live symptom, localize the faulty file/function/config now with falsifying checks; after localization, use five-whys-plus for systemic prevention.';
+
+function catalogText(skills) {
+ return skills.map((skill) => `- ${skill.name}: ${skill.description}`).join('\n');
+}
+
+function routingPrompt(catalog, userPrompt) {
+ return `You are the skill-router inside an AI coding agent. Pick the SINGLE optional thinking skill whose description best matches the user's actual need, or "none" when no skill strongly fits.\n\n=== SKILL CATALOG ===\n${catalog}\n\n=== USER MESSAGE ===\n${userPrompt}\n\nReturn ONLY JSON: {"skill":"thinking-... or none","confidence":0.0,"rationale":"one sentence"}`;
+}
+
+async function main() {
+ if (BOUNDARY_DESCRIPTION.length > 200) throw new Error('boundary description exceeds 200 characters');
+ const dataset = JSON.parse(fs.readFileSync(DATASET, 'utf8'));
+ const currentCatalog = loadAllSkills();
+ const boundaryCatalog = applyDescriptionOverride(
+ currentCatalog,
+ 'thinking-scientific-method',
+ BOUNDARY_DESCRIPTION,
+ );
+ const catalogs = {
+ current: catalogText(currentCatalog),
+ boundary: catalogText(boundaryCatalog),
+ };
+ const rows = await mapPool(dataset.cases, CONCURRENCY, async (testCase) => {
+ const armIds = deterministicArmOrder(['current', 'boundary'], {
+ seed: 'scientific-method-routing-boundary-v1',
+ itemId: testCase.id,
+ trial: 1,
+ });
+ const caseRows = [];
+ for (const armId of armIds) {
+ const result = await droidJsonAsync({
+ model: MODEL,
+ effort: maxEffortFor(MODEL),
+ prompt: routingPrompt(catalogs[armId], testCase.prompt),
+ timeoutMs: Number(process.env.DROID_TIMEOUT_MS || 180000),
+ });
+ const chosen = result.ok && result.json && result.json.skill
+ ? String(result.json.skill).trim()
+ : null;
+ caseRows.push({
+ case_id: testCase.id,
+ arm_id: armId,
+ expected: testCase.expected,
+ chosen,
+ correct: chosen === testCase.expected,
+ confidence: result.ok && result.json ? result.json.confidence : null,
+ rationale: result.ok && result.json ? result.json.rationale : null,
+ response_sha256: result.raw ? sha256(result.raw) : null,
+ usage: usageSummary(result.usage, MODEL),
+ attempts: result.attempts,
+ failure: result.failure && typeof result.failure.toJSON === 'function'
+ ? result.failure.toJSON()
+ : result.failure || null,
+ });
+ }
+ return caseRows;
+ });
+ const results = rows.flat();
+ const score = scoreRoutingBoundary(results);
+ const health = {
+ attempted: results.length,
+ completed: results.filter((row) => !row.failure).length,
+ failures: results.filter((row) => row.failure).length,
+ };
+ health.decision_eligible = health.completed === health.attempted;
+ if (!health.decision_eligible) score.boundary_pass = false;
+ const artifact = {
+ schema_version: 1,
+ study_id: 'scientific-method-routing-boundary-v1',
+ created_at: new Date().toISOString(),
+ model: MODEL,
+ effort: maxEffortFor(MODEL),
+ dataset: {
+ path: path.relative(path.join(__dirname, '..'), DATASET),
+ sha256: sha256(fs.readFileSync(DATASET)),
+ n: dataset.cases.length,
+ },
+ descriptions: {
+ current: currentCatalog.find((skill) => skill.name === 'thinking-scientific-method').description,
+ boundary: BOUNDARY_DESCRIPTION,
+ },
+ health,
+ usage: aggregateUsage(results.map((row) => row.usage)),
+ score,
+ results,
+ };
+ writeJsonAtomic(OUT, artifact);
+ process.stdout.write(`${JSON.stringify({ out: OUT, health, usage: artifact.usage, score }, null, 2)}\n`);
+}
+
+main().catch((error) => {
+ process.stderr.write(`${error && error.stack ? error.stack : error}\n`);
+ process.exitCode = 1;
+});
diff --git a/evals/tests/routing-boundary.test.js b/evals/tests/routing-boundary.test.js
new file mode 100644
index 0000000..e2b0af3
--- /dev/null
+++ b/evals/tests/routing-boundary.test.js
@@ -0,0 +1,37 @@
+'use strict';
+
+const test = require('node:test');
+const assert = require('node:assert/strict');
+const {
+ applyDescriptionOverride,
+ scoreRoutingBoundary,
+} = require('../lib/routing-boundary');
+
+test('applyDescriptionOverride changes only the targeted catalog entry', () => {
+ const catalog = [
+ { name: 'thinking-scientific-method', description: 'old' },
+ { name: 'thinking-five-whys-plus', description: 'keep' },
+ ];
+ assert.deepEqual(
+ applyDescriptionOverride(catalog, 'thinking-scientific-method', 'new'),
+ [
+ { name: 'thinking-scientific-method', description: 'new' },
+ { name: 'thinking-five-whys-plus', description: 'keep' },
+ ],
+ );
+ assert.equal(catalog[0].description, 'old');
+});
+
+test('scoreRoutingBoundary reports strict accuracy and five-whys preservation', () => {
+ const results = [
+ { case_id: 's1', arm_id: 'current', expected: 'thinking-scientific-method', chosen: 'thinking-five-whys-plus' },
+ { case_id: 'f1', arm_id: 'current', expected: 'thinking-five-whys-plus', chosen: 'thinking-five-whys-plus' },
+ { case_id: 's1', arm_id: 'boundary', expected: 'thinking-scientific-method', chosen: 'thinking-scientific-method' },
+ { case_id: 'f1', arm_id: 'boundary', expected: 'thinking-five-whys-plus', chosen: 'thinking-five-whys-plus' },
+ ];
+ const score = scoreRoutingBoundary(results);
+ assert.equal(score.by_arm.current.strict_accuracy, 0.5);
+ assert.equal(score.by_arm.boundary.strict_accuracy, 1);
+ assert.equal(score.by_arm.boundary.five_whys_accuracy, 1);
+ assert.equal(score.boundary_pass, true);
+});