{"id":"vibe-dev-review-ai-function-requirements","audience":"developers","category":"coding","track":"coding","technique":"verification","title":"Check an AI-written function against its requirements","free":false,"task":"A coding assistant wrote an average function and says it meets all 4 requirements. Check it by reading the code: write exactly 4 numbered lines, one per requirement in order, each labeled Met or Not met, then the line number and a reason in under 15 words. Don't rewrite the code and use no code blocks. Under 110 words.","materialLabel":"The requirements, the code and the assistant's note (attached to your prompt automatically)","material":"REQUIREMENTS for average(scores)\nR1. Returns 0 for an empty array.\nR2. Rounds the result to 2 decimal places.\nR3. Does not change (mutate) the array passed in.\nR4. Ignores null values.\n\nCODE (written by the coding assistant)\n1  function average(scores) {\n2    scores.sort((a, b) => a - b);\n3    const valid = scores.filter((s) => s !== null);\n4    const sum = valid.reduce((a, b) => a + b, 0);\n5    return Math.round((sum / valid.length) * 100) / 100;\n6  }\n\nASSISTANT'S NOTE\n\"Done! average() handles empty arrays, rounds to 2 decimals, ignores nulls, and leaves the input untouched. I also sorted the scores for consistency.\"\n","rules":[{"type":"numberedItems","count":4},{"type":"codeBlocks","count":0},{"type":"maxProseWords","max":110}],"mistakes":[{"title":"Trusting the assistant's note","why":"The note says everything is handled, and the AI agrees.","fix":"Add: \"Judge only the code, not the note.\"","checks":["r0","r1"]},{"title":"Missing the in-place sort","why":"sort() looks harmless, but it changes the caller's array.","fix":"Add: \"Check whether any line changes the input array.\"","checks":["r1"]},{"title":"No line evidence","why":"The AI says 'fails R1' without pointing to where.","fix":"Add: \"Cite the line number for each verdict.\"","checks":["r2"]},{"title":"Rewriting instead of reviewing","why":"The AI jumps to a fixed version in a code block.","fix":"Add: \"Don't rewrite the code. No code blocks.\"","checks":["codeBlocks","maxProseWords","numberedItems"]}],"promptHints":[{"label":"Ignores the note","patterns":["only the code","not the note","ignore the note","by reading"]},{"label":"Uses exact labels","patterns":["met","not met"]},{"label":"Asks for line numbers","patterns":["line number","cite"]},{"label":"Bans rewrites","patterns":["don.t rewrite","no code block","no rewrite"]},{"label":"Caps the length","patterns":["\\d+\\s*words"]}],"hint":"AI assistants often claim more than their code does. Ask for a verdict per requirement with the line that proves it, and ignore the note.","rubricLabels":["R1 is Not met: an empty array makes line 5 divide 0 by 0, giving NaN instead of 0","R3 is Not met: line 2 sorts the input array in place, which changes it","R2 (line 5) and R4 (line 3) are Met, and each of the 4 lines cites a line number"]}