Part 9 · 1 chapters · ~10 min

A Mock Take-Home

A plausible AI take-home (a natural-language transfer draft with an LLM, tests and an AI-usage note) planned hour by hour, with the core parse-validate-review code, the unhappy paths, a mock mode, a README skeleton, and the rubric a staff reviewer applies.

12

Practise on a plausible challenge

Do this mock end to end once, with a timer, before the real challenge arrives. The point is the habits: spec first, model output treated as untrusted, designed failure states, a mock mode, and an honest write-up. Then follow the real instructions exactly.

code
// the core of it: the model proposes, the schema decides, the user confirms
const Draft = z.object({
  amountMinor: z.number().int().positive(),
  currency: z.enum(['NGN', 'USD']),
  recipient: z.string().min(1),
  date: z.string().date(),
  confidence: z.number().min(0).max(1),
  questions: z.array(z.string()).max(3),         // what the model could not decide
});

export async function parseTransfer(text: string, model: Model): Promise<ParseResult> {
  let raw: unknown;
  try { raw = await withTimeout(model.complete(promptFor(text)), 8_000); }
  catch { return { kind: 'fallback', reason: 'model_unavailable' }; }   // plain form
  const parsed = Draft.safeParse(raw);
  if (!parsed.success) return { kind: 'fallback', reason: 'invalid_output' };
  if (parsed.data.confidence < 0.8 || parsed.data.questions.length) return { kind: 'clarify', draft: parsed.data };
  return { kind: 'review', draft: parsed.data };                         // never 'submit'
}
code
README skeleton
## What it does            one paragraph and a GIF
## Run it                  npm i && npm run dev   (MODEL=mock by default; set OPENAI_API_KEY for real)
## Spec and never-events   the model never submits; amounts are never guessed silently
## How I used AI           spec drafted with Claude and edited by me; scaffold generated; parsing and
                           validation written and reviewed by me; tests generated from the spec, then
                           I added the malformed-output and ambiguity cases; agent PR critique, 2 fixes taken
## What I verified myself  every state by hand; eval set against the real model: 9/10, the miss documented
## Left out on purpose     auth, real payments, persistence: out of scope for the brief
## With more time          streaming the parse, a larger eval set in CI, i18n for amounts
A MOCK TAKE-HOME, AND HOW IT IS MARKED
a plausible AI challenge, a five-hour plan, and the rubric a staff reviewer applies
swipe the figure sideways, or tap expand for full screen
1/6
spec
Hour 0 to 0.5, read and spec: list the requirements, the never-events (the model never submits a transfer; amounts are never guessed silently), ambiguities and the assumptions you will state. Write the spec first; it becomes the README's opening and the agent's brief.