How to mark 30 assignments in one step with Code Mode
Marking 30 programming submissions by hand takes an evening. Claude Code’s Code Mode did it on an awx computer in 37 seconds, with every score right and one formatting slip to catch.
What we set up
On an awx computer we made a folder ~/marking with an invented lab assignment: three small Python functions, is_prime, fizzbuzz and grade, marked by 10 test cases, 1 mark each. Then 30 invented submissions, S001.py to S030.py, with the mistakes students really make: wrong answers for 1 or 2, an off-by-one loop, > instead of >=, printing instead of returning, a missing colon, a missing function, an import of a module that does not exist, and two loops that never end.
We knew the right score for every one, so we could check Claude’s marks afterwards. No real student’s work was used.
Claude Code ran in the computer’s Terminal tab, version 2.1.327 with Code Mode on, signed in with a Claude Max account. How to set that up: Use Claude Code’s Code Mode on your awx computer.
The request
In ~/marking there is a lab assignment (ASSIGNMENT.md), its 10 test cases (tests.json) and 30 student submissions (submissions/S001.py to S030.py). Mark every submission: run each test case against it, giving each test at most 3 seconds because some submissions crash or loop forever, and never let one submission's problem stop the others. Write ~/marking/marks.csv with the columns student, score (out of 10) and a one-line comment saying what went wrong. Then tell me the class average, how many got full marks, and the three most common mistakes.
Two parts of it matter most: a time limit for each test, because a loop that never ends would otherwise stop the marking, and “never let one submission’s problem stop the others”.
What Code Mode did
It took 37 seconds. Claude Code first read the assignment, the tests and one submission. Then one step of the session read:
Making 1 scratchpad edit, reading 1 file, running 303 shell commands…
That is Code Mode at work. Instead of 300 separate tool calls, each read before the next, one piece of JavaScript started a small helper script, ran every submission against every test, side by side, and kept only the results. In all, 4 pieces of code made 312 tool calls. Each test ran in its own Python process, stopped after 3 seconds, so a crash or an endless loop only cost that one test.
The code it wrote
Press Ctrl+O in Claude Code to see the code behind the tool calls. This is the heart of it, as Claude wrote it, only spaced out for reading:
async function runOne(id, t) {
const r = await $`cd ${sp} && timeout -s KILL 3 python3 -I ${sp}/runner.py ${home}/marking/submissions/${id}.py ${t.fn} ${JSON.stringify(t.args)}`.nothrow().quiet();
const m = r.stdout.match(/@@RES@@(.*)/);
if (!m) return {pass: false, why: r.exitCode === 137 || r.exitCode === 124 || r.exitCode === null ? 'timeout' : 'crash'};
const j = JSON.parse(m[1]);
if (!j.ok) return {pass: false, why: j.err};
const pass = JSON.stringify(j.r) === JSON.stringify(t.expect);
return {pass, why: pass ? '' : `${t.fn}(${t.args}) gave ${JSON.stringify(j.r)} expected ${JSON.stringify(t.expect)}`.slice(0, 120)};
}
const res = {};
await Promise.all(ids.map(async id => { res[id] = []; for (const t of tests) res[id].push(await runOne(id, t)); }));
runOne runs one test with timeout -s KILL 3 and turns the outcome into pass, wrong answer, crash or timeout. Promise.all runs the 30 submissions at the same time. Then a last piece of code wrote marks.csv and worked out the average.
The result, checked
We compared every line of marks.csv with our answer key: all 30 scores were right. The class average was 7.63 out of 10, and 12 got full marks. The two endless loops scored 8, because only the two tests that loop timed out, which is the fair result. Some lines of the file:
| Student | Score | Comment |
|---|---|---|
| S001 to S012 | 10 | All tests passed |
| S013 | 9 | is_prime(1) returns True |
| S015 | 9 | is_prime(2) returns False |
| S017 | 8 | fizzbuzz stops at n-1 (range(1,n) excludes n) |
| S020 | 8 | grade uses > instead of >= so boundaries 80 and 65 are wrong |
| S023 | 0 | SyntaxError (missing colon) so nothing runs |
| S025 | 8 | is_prime loops forever (loop counter never incremented); timed out |
| S027 | 0 | prints answers instead of returning them |
| S029 | 8 | fizzbuzz function missing |
| S030 | 0 | import numpyy (a module that does not exist) so the file fails to import |
The one thing to fix
One comment broke the file. For S019 Claude wrote multiples of 15 give "Fizz" inside a quoted CSV field without doubling the quote marks, so a spreadsheet would split that line in the wrong place. One more message fixes it: “Check that marks.csv opens correctly as a CSV and fix any quoting.”
The lesson is the usual one with an agent: the marks were right, and the file still needed a look before it went anywhere.
Try it yourself
- Set up Claude Code with Code Mode on your
awxcomputer: the steps. - Upload the assignment, the tests and the submissions on the Files tab, or with a file app.
- Ask with the same parts as ours: where the files are, a time limit per test, what to write, and what to tell you.
- Ask for one-line feedback for each student next, if you want it.
Common questions
Can Claude Code mark programming assignments?
In our run it marked 30 invented Python submissions against 10 test cases in 37 seconds, and every score matched our answer key. Check the marks file before you use it: one comment in ours broke the CSV format.
What does Code Mode change?
Claude Code writes JavaScript that makes many tool calls at once instead of one at a time. In our run, 4 pieces of code made 312 tool calls, including 300 test runs side by side.
Is it safe to run students' code?
Students' code can crash, loop forever or do something unexpected, so run it somewhere that is not your own laptop. An awx computer is sealed off from the server and your home network.
Do I need my own Claude account?
Yes. Code Mode is a feature of Claude Code and needs a Claude subscription or Console account. The awx Chat agent is a different agent.
Cautions
- Students’ work and AI services. Before you give real submissions to any AI service, check your university’s rules. Our run used invented work only.
- Run students’ code away from your own laptop. Their code can crash, loop or do something unexpected. An
awxcomputer is sealed off from the server and from your home network. - Code Mode is experimental, and needs your own Claude account.
- Check before you publish marks. Read the file, and spot-check a few students by hand.
Keep reading
- Use Claude Code’s Code Mode on your awx computer
- How to let Claude Code use awx from your terminal
- Clean and analyse a survey CSV with Python
- How to run a genetic algorithm in GNU Octave, two ways
Getting started
Sign in with your Google account and ask to join. Once you are approved, make a computer, open its Terminal tab and follow the Code Mode steps.
Awi, signing off.