ai-exam-tool-architecture
Skill16 starsChanged 7 months agoMITView on GitHub
Design or review the OUCHN AI exam answer-tool architecture. Use when planning provider tool calling, tool-envelope fallback, DOM answer execution tools, error feedback, or refactoring AIResponse-driven answer filling into browser-safe tool execution.
In this repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- anthropic-providerSkill
- code-review-expertSkill
- frontend-designSkill
- product-designerSkill
- plan-taskSkill
- software-design-philosophySkill
- vercel-react-best-practicesSkill
- zustandSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 12 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill when working on the OUCHN AI automatic exam-answering architecture, especially when converting provider output into …
- Very specific: line 18
Do not port Node.js APIs, React/TUI rendering, MCP, filesystem state caches, permission dialogs, or heavy telemetry.
- Distinctive: line 24
Default DOM-writing tools to non-concurrency-safe.
- Distinctive: line 28
Avoid shallow tools. A tool should own meaningful validation, execution, and result mapping.
- Distinctive: line 29
Keep provider inference concurrency separate from DOM execution concurrency.
- Distinctive: line 33
Use a compact local interface.
- Very specific: line 51
Add a buildExamTool helper with defaults:
- Distinctive: line 59
Start with the smallest tool set that creates a real boundary:
- Very specific: line 67
If these would only delegate without owning validation, prefer one deeper answer_question tool first and split later.
- Distinctive: line 71
Use typed error codes that can drive stats, retry, and debugging:
- Distinctive: line 89
Do the migration incrementally:
- Distinctive: line 91
Keep existing JSON answer prompts working.
- Distinctive: line 93
Add JSON tool-envelope fallback for models without native tool calling:
- Distinctive: line 103
Add native OpenAI/Claude tool mapping only after the internal executor contract is stable.
- Distinctive: line 108
Before changing behavior, inspect and preserve these modules:
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AI Exam Tool Architecture Skill
Use this skill when working on the OUCHN AI automatic exam-answering architecture, especially when converting provider output into controlled tools that execute DOM writes in a Tampermonkey userscript.
Core Rule
Adopt the reference project's tool lifecycle, not its runtime stack. The browser userscript should have a small, deep tool layer:
provider tool intent -> registry lookup -> input validation -> semantic validation -> serial DOM execution -> typed result/error -> stats and feedbackDo not port Node.js APIs, React/TUI rendering, MCP, filesystem state caches, permission dialogs, or heavy telemetry. The target runtime is browser + Tampermonkey IIFE.
Design Principles
- Tools must hide DOM and OUCHN compatibility details from providers.
- Tool names are stable provider-visible contracts.
- Default DOM-writing tools to non-concurrency-safe.
- Validate model input shape before semantic/page validation.
- Return typed results and typed errors; do not collapse failures into generic
false. - Preserve current business behavior by wrapping existing fill/match/write logic first.
- Avoid shallow tools. A tool should own meaningful validation, execution, and result mapping.
- Keep provider inference concurrency separate from DOM execution concurrency.
Browser-Safe Tool Shape
Use a compact local interface. Avoid adding a schema library unless the implementation task explicitly accepts the dependency.
type ExamToolResult =
| { ok: true; tool: string; questionIndex: number; filledCount?: number; detail?: string }
| { ok: false; tool: string; questionIndex?: number; code: ExamToolErrorCode; message: string; retryable: boolean };
type ExamTool<Input> = {
name: string;
description: string;
inputSchema: (input: unknown) => input is Input;
validateInput?: (input: Input, context: ExamToolContext) => ExamToolResult | null;
isConcurrencySafe?: (input: Input) => boolean;
isReadOnly?: (input: Input) => boolean;
execute: (input: Input, context: ExamToolContext) => Promise<ExamToolResult>;
};Add a buildExamTool helper with defaults:
isConcurrencySafe:falseisReadOnly:falsevalidateInput: no extra semantic error
Recommended Tools
Start with the smallest tool set that creates a real boundary:
answer_choice: single selection and true/false.answer_multiple_choice: multiple selection.answer_blank: fill-in-blank.answer_essay: short answer and unknown fallback.answer_matching: matching/pairing questions.
If these would only delegate without owning validation, prefer one deeper answer_question tool first and split later.
Error Codes
Use typed error codes that can drive stats, retry, and debugging:
unknown_toolinvalid_tool_inputquestion_not_foundinvalid_answer_shapeunknown_option_labelblank_count_mismatchmatching_pair_unresolveddom_write_failedunsupported_question_typeprovider_parse_failedtool_execution_cancelled
Each failure should include retryable. Provider-correctable input errors are retryable. Missing DOM/page-state failures usually are not retryable without re-extraction.
Provider Migration
Do the migration incrementally:
- Keep existing JSON answer prompts working.
- Convert parsed
AIResponseinto internalExamToolUse[]before DOM writing. - Add JSON tool-envelope fallback for models without native tool calling:
{
"toolUses": [
{ "tool": "answer_choice", "input": { "questionIndex": 1, "answer": "C" } }
]
}- Add native OpenAI/Claude tool mapping only after the internal executor contract is stable.
- Preserve per-question provider concurrency; execute DOM-writing tools serially.
Existing Code To Preserve
Before changing behavior, inspect and preserve these modules:
src/modules/exam/ai-provider.ts: per-question provider calls, vision handling, internal-index trust.src/modules/exam/answer-fill.ts: answer filling, choice fallbacks, blank/editor logic, essay fallback sync.src/modules/exam/answer-match.ts: matching answer parsing and multi-stage DOM/Angular fallbacks.src/modules/exam/answer-write.ts: editor write and verification behavior.src/modules/exam/question-extract.ts: authoritativeQuestionmetadata and DOM lookup.src/types/exam.ts:Question,AnswerValue,AIResponse,ExamStats, integer sub-question index rules.
Review Checklist
- Does the design reduce provider-to-DOM format leakage?
- Are DOM-writing tools serial by default?
- Are existing matching, blank, image, sub-question, and editor-sync protections preserved?
- Are tool errors specific enough for stats and retry?
- Is native tool calling optional, with JSON-envelope fallback?
- Does the implementation avoid Node.js-only APIs and new runtime dependencies unless explicitly accepted?
- Are tool abstractions deep enough to justify their module boundaries?
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

