grade

A grading command for handwritten or scanned answer PDFs. It reads the pages with an optical character recognition engine, which turns writing or images into text, then compares the strategy and mathematics with a reference solution.

In plain words
What is it for?
Use it to check scanned homework or exam answers, identify errors by problem pattern, and review the final mathematical form.
Why use it?
It removes the need to type a paper solution before getting feedback. It also helps process difficult scans using different recognition tools.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/optimeta/paideia/grade
Clone the repo
git clone --depth 1 https://github.com/OPTIMETA/PAIDEIA
Per session 48 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 7,616 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00048 $0.07616
Opus 5 $0.00024 $0.03808
Sonnet 5 $0.00010 $0.01523
Haiku 4.5 $0.00005 $0.00762

Measured 2d ago against content hash 29dc911b8a77, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

grade scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

Clean up: `rm -rf "$TMPDIR"`.
plugins/paideia/commands/grade.md · 422 lines

How it starts

The opening of the file, as written. The whole thing — 422 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Output language

Read INTERFACE_LANG from .course-meta (default en). All user-facing prose — chat output, grade-table commentary, the OCR quality escape-hatch menu — must be in that language. Keep in English regardless: file paths, slash command names (/paideia:grade, /paideia:blind, …), pattern IDs (P1, P2…), YAML keys, LaTeX, OCR engine names (claude, ollama, tesseract), and the grade table's column headers (P#, Pattern, Vars, SymPy, End form, Overall). vision_ocr.py reads INTERFACE_LANG from .course-meta on its own to set the VLM's prose-language rule and the tesseract lang= code, so the bash invocations below don't need to pass it explicitly.

Load skills/vision-ocr/SKILL.md, skills/pdf/SKILL.md, and skills/answer-processing/SKILL.md.

Arguments: $ARGUMENTS

If $ARGUMENTS contains --ocr=<engine>, that overrides the default for this call. Otherwise read OCR_ENGINE from .course-meta in CWD (one line of the form OCR_ENGINE: <engine>). If .course-meta is absent or the key is missing, default to claude.

Target answer file: the non-flag positional in $ARGUMENTS. If no positional, find the most recently modified file in answers/ (not answers/converted/).

Follow the answer-processing skill pipeline:

  1. Identify. Is target a .pdf or .md?

    • .pdf → proceed to step 2
    • .md → skip step 2, go to 3
  2. Convert PDF → MD. Dispatch on the selected OCR engine:

    2a. claude (default) — native Claude vision, no external model

    STEM=$(basename "answers/<stem>.pdf" .pdf)
    TMPDIR="answers/converted/.tmp-${STEM}"
    mkdir -p "$TMPDIR"
    pdftoppm -r 200 -png "answers/${STEM}.pdf" "$TMPDIR/page"
    
    # Downsize to max 1800px width to keep Read-tool image payloads small.
    # Without this, 200-DPI letter-size pages are ~1700–2200px wide and each page
    # eats ~0.5–1.0 MB of image tokens — fine for 1–2 pages, brutal for 10+.
    # Mirrors the resize step used by /paideia:ingest for lecture/homework scans.
    python3 - "$TMPDIR" <<'PY'
    import sys, pathlib
    from PIL import Image
    MAX_W = 1800
    for p in sorted(pathlib.Path(sys.argv[1]).glob("page-*.png")):
        img = Image.open(p)
        if img.width > MAX_W:
            ratio = MAX_W / img.width
            img.resize((MAX_W, int(img.height * ratio))).save(p, optimize=True)
    PY
    

    This produces $TMPDIR/page-1.png, $TMPDIR/page-2.png, ... (each ≤1800px wide). Now use the Read tool on each PNG in order and synthesize clean markdown yourself, following the transcription prompt contract from skills/vision-ocr/SKILL.md:

    • Prose stays in its original language (English, Korean, etc.) — do not translate.
    • Math as $...$ / $$...$$.
    • Preserve problem numbering (P1, (1), (a), ...).
    • Do NOT interpret or grade — pure transcription.
    • [?] for ambiguous glyphs.
    • Skip crossed-out work.
    • Markdown only.

    Write the synthesized result to answers/converted/<stem>.md with header:

    # Vision-OCR transcription
    
    <!-- SOURCE: <stem>.pdf, claude-vision (native), N pages -->
    
    ## Page 1
    
    <transcription>
    
    ## Page 2
    
    <transcription>
    

    Clean up: rm -rf "$TMPDIR".

    2b. ollama — local Qwen3-VL 8B

    python3 "${CLAUDE_PLUGIN_ROOT}/scripts/vision_ocr.py" --engine=ollama \
      "answers/<stem>.pdf" "answers/converted/<stem>.md"
    

    Uses qwen3-vl:8b via ollama. The script reads INTERFACE_LANG from .course-meta in CWD so the prose-language rule in the VLM prompt matches the course's language. Auto-falls back to tesseract on any exception (timeout / ollama down / model missing). Tier is recorded in the file header. See skills/vision-ocr/SKILL.md for details.

    2c. tesseract — explicit, skip ollama

    python3 "${CLAUDE_PLUGIN_ROOT}/scripts/vision_ocr.py" --engine=tesseract \
      "answers/<stem>.pdf" "answers/converted/<stem>.md"
    

    Pure pytesseract (eng if the course's INTERFACE_LANG=en, eng+kor if ko — also read from .course-meta). Fastest, lowest fidelity on handwriting.

Read the full file on GitHub · 422 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 422 lines · 48 tokens per session scan C 29dc911b8a77

Subscribe to this mod's changes

grade is a command published in the GitHub repository OPTIMETA/PAIDEIA (91 stars, last pushed 1mo ago), licensed MIT. It adds 48 tokens to every session and 7,616 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.