{
  "format": "minglabs/v1",
  "surface": "insights-answer",
  "slug": "how-do-i-check-ai-generated-code-before-use",
  "inLanguage": "en",
  "languages": [
    {
      "language": "en",
      "label": "English",
      "path": "/insights/answers/how-do-i-check-ai-generated-code-before-use",
      "url": "https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use",
      "jsonUrl": "https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use.json",
      "markdownUrl": "https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use.md"
    },
    {
      "language": "de",
      "label": "Deutsch",
      "path": "/de/insights/answers/wie-pruefe-ich-ki-generierten-code-vor-dem-einsatz",
      "url": "https://www.minglabs.com/de/insights/answers/wie-pruefe-ich-ki-generierten-code-vor-dem-einsatz",
      "jsonUrl": "https://www.minglabs.com/de/insights/answers/wie-pruefe-ich-ki-generierten-code-vor-dem-einsatz.json",
      "markdownUrl": "https://www.minglabs.com/de/insights/answers/wie-pruefe-ich-ki-generierten-code-vor-dem-einsatz.md"
    }
  ],
  "kind": "answer",
  "pageType": "Answer",
  "question": "How do I check AI-generated code before using it?",
  "topic": "Checking the required behaviour of AI-generated code before release",
  "targetQueries": [
    "check AI generated code",
    "AI code acceptance tests",
    "review AI generated code"
  ],
  "url": "https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use",
  "htmlUrl": "https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use",
  "partOf": "https://www.minglabs.com/insights/answers",
  "title": "How do I check AI-generated code before using it?",
  "standout": null,
  "hook": "Write down what the change must do, check the code and test the expected results before approving the exact version. Also check whether the tests reject a deliberately wrong result. Our small calculation example shows why a passing test needs a clear business rule behind it. It establishes the tested behaviour only; security, integration and release approval remain separate checks.",
  "citableAnswer": "MING proposes checking a small AI-generated change against independently specified expected results, meaningful boundary cases and a deliberately incorrect version. In our calculation example, a rejected attempt adds effort without adding an accepted result. The targeted tests detect two constructed faults; they do not establish general code security or production readiness.",
  "hookSourceIds": [
    "S1"
  ],
  "author": {
    "name": "MING Labs",
    "role": "Editorial team"
  },
  "evidenceNote": "An actual test of our calculation code with invented inputs. Deliberate faults are test examples, not reported production incidents. No comprehensive security assurance.",
  "evidenceLabel": "Tested calculation and proposed review method",
  "summary": "Check AI-generated code with an expected-result table and a deliberate fault. Our tested calculation shows what passing tests establish and what remains open.",
  "pillar": "Hybrid Organisation",
  "datePublished": "2026-11-09",
  "dateModified": "2026-11-09",
  "freshness": {
    "updated": "November 2026",
    "nextReview": "December 2026",
    "nextReviewDate": "2026-12-09"
  },
  "evidenceTier": "proprietary",
  "confidence": "B",
  "sources": [
    {
      "id": "S1",
      "title": "Code checks on our calculation example",
      "publisher": "MING Labs",
      "date": "8 and 9 November 2026",
      "url": "https://www.minglabs.com/insights/answers/how-do-i-measure-ai-software-delivery-productivity",
      "supports": [
        "285 minutes for one accepted result; four targeted tests passed, both constructed faults detected."
      ],
      "method": "Our executed tests of the linked example’s calculation code. Invented numerical inputs; two deliberate faulty versions, not client cases or production incidents. Test record held privately."
    },
    {
      "id": "S2",
      "title": "Application card: GitHub Copilot Agents",
      "publisher": "GitHub",
      "date": "Accessed 9 November 2026",
      "url": "https://docs.github.com/en/copilot/responsible-use/agents",
      "supports": [
        "Missed problems, false positives and incorrect or insecure suggestions; careful review and testing remain necessary."
      ],
      "method": "Provider documentation of limitations and responsible use; not an independent effectiveness measurement."
    }
  ],
  "faqs": [
    {
      "q": "Can the same AI write the code and the tests?",
      "a": "It can help draft both, but they may repeat the same mistaken assumption. Agree expected results from the business rule separately, review the assertions and check a deliberately wrong version. Using another model alone does not establish independent verification."
    },
    {
      "q": "Do four passing tests mean the code is safe?",
      "a": "No. Our four tests cover selected arithmetic and invalid-input cases. They do not examine access rights, dependencies, confidential data, the complete application or every possible input. Define the required checks according to what the change can affect."
    },
    {
      "q": "What can I check if I cannot read the code?",
      "a": "You can specify the required outcome with examples, ask to see the actual results and identify unresolved decisions. A qualified developer still needs to review the implementation and technical risks. Do not substitute an AI explanation for expertise you do not have."
    },
    {
      "q": "Should I return to the old version when a check fails?",
      "a": "Stop the release and assess a known, acceptable version with its owner. An old version may contain the very defect being fixed. Restoring its files is not proof of a safe rollback, especially when data or dependencies have changed."
    }
  ],
  "parentArticleSlug": null,
  "relatedConceptSlugs": [],
  "relatedArticleSlugs": [],
  "nextStep": {
    "id": "code-acceptance",
    "dateModified": "2026-11-09",
    "headline": "What is missing before your AI-assisted change can be accepted?",
    "description": "Bring one small software task and an unresolved review decision. We can discuss the path from the required outcome through development to approval. This is not security certification.",
    "label": "Discuss my review process",
    "url": "https://www.minglabs.com/contact?type=project&topic=code-acceptance",
    "destinationLanguage": "en",
    "placements": [
      {
        "position": "inline",
        "afterSection": "rule",
        "headline": "Is it unclear who can accept the change?",
        "description": "Discuss one bounded software task and the review and approval steps it needs."
      },
      {
        "position": "end",
        "after": "citable-answer"
      }
    ],
    "secondary": {
      "label": "See how to measure software effort",
      "url": "https://www.minglabs.com/insights/answers/how-do-i-measure-ai-software-delivery-productivity"
    }
  },
  "metadata": {
    "title": "How do I check AI-generated code before using it? — MING Labs",
    "description": "Check AI-generated code with an expected-result table and a deliberate fault. Our tested calculation shows what passing tests establish and what remains open.",
    "canonical": "https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use",
    "inLanguage": "en",
    "openGraph": {
      "title": "How do I check AI-generated code before using it?",
      "description": "Check AI-generated code with an expected-result table and a deliberate fault. Our tested calculation shows what passing tests establish and what remains open.",
      "url": "https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use",
      "image": "https://www.minglabs.com/og/code-acceptance-en.png"
    },
    "twitter": {
      "card": "summary_large_image",
      "title": "How do I check AI-generated code before using it?",
      "description": "Check AI-generated code with an expected-result table and a deliberate fault. Our tested calculation shows what passing tests establish and what remains open.",
      "image": "https://www.minglabs.com/og/code-acceptance-en.png"
    }
  },
  "actions": [
    {
      "id": "navigation",
      "label": "Get in touch",
      "accessibleName": "Get in touch",
      "kind": "navigate",
      "requiresBrowser": false,
      "url": "https://www.minglabs.com/contact"
    },
    {
      "id": "code-acceptance",
      "label": "Discuss my review process",
      "accessibleName": "Discuss my review process — in the article",
      "kind": "navigate",
      "requiresBrowser": false,
      "url": "https://www.minglabs.com/contact?type=project&topic=code-acceptance"
    },
    {
      "id": "copy-briefing",
      "label": "Copy answer for my AI",
      "accessibleName": "Copy answer for my AI",
      "kind": "copy",
      "requiresBrowser": true,
      "contentUrl": "https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use.md"
    }
  ],
  "markdownUrl": "https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use.md",
  "contentMarkdown": "---\ntitle: \"How do I check AI-generated code before using it? — MING Labs\"\ndescription: \"Check AI-generated code with an expected-result table and a deliberate fault. Our tested calculation shows what passing tests establish and what remains open.\"\ncanonical: https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use\nlang: en\nlast-updated: 2026-11-09\n---\n\n# How do I check AI-generated code before using it?\n\n[Home](https://www.minglabs.com/)  [Insights](https://www.minglabs.com/insights)  [Answers](https://www.minglabs.com/insights/answers)  How do I check AI-generated code before using it?\n\nAnswer\n\n\n\nWrite down what the change must do, check the code and test the expected results before approving the exact version. Also check whether the tests reject a deliberately wrong result. Our small calculation example shows why a passing test needs a clear business rule behind it. It establishes the tested behaviour only; security, integration and release approval remain separate checks.[\\[S1\\]](https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use#source-s1)\n\nExecuted test, invented inputs\n\nWould the test catch the wrong answer?\n\n190 minutes accepted + 95 minutes rejected  \n**285** person-minutes in total\n\nCount accepted results\n\n285 ÷ 1 = **285**\n\nExpected result: test passes\n\nDeliberate error: count attempts\n\n285 ÷ 2 = **142.5**\n\nWrong result: test must fail\n\nperson-minutes per accepted result\n\nBoth branches use 285 person-minutes. The correct calculation divides by one accepted result and returns 285. The deliberately wrong version divides by two attempts and returns 142.5; our test rejects it. This checks the chosen business rule, not the security of the application. MING Labs, 8 and 9 November 2026.\n\nLast updated: November 2026 | Next review: December 2026 Tested calculation and proposed review method [Machine-readable record ](https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use.json)\n\nBy MING Labs · Editorial team\n\n##  Agree the answer before judging the code.\n\nA calculation can run without errors and still answer the wrong question. In our software-productivity example, one accepted change takes 190 person-minutes and a rejected attempt takes another 95. The figures are invented. The code that totals them is part of our own published example.[\\[S1\\]](https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use#source-s1)\n\nThe business rule is simple: rejected work still consumes effort, but it does not become an accepted result. The expected answer is therefore 285 person-minutes for one accepted change. Dividing by two attempts gives 142.5, a plausible-looking number that answers a different question.\n\nWe tested the calculation used by the page and separately constructed that wrong-denominator version. The targeted test rejected it. This is the useful question to bring to a code review: would our check notice the mistake that matters to the person using the result?[\\[S1\\]](https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use#source-s1)\n\n## Is it unclear who can accept the change?\n\nDiscuss one bounded software task and the review and approval steps it needs.\n\n[Discuss my review process](https://www.minglabs.com/contact?type=project&topic=code-acceptance)\n\nTell us what you have in mind. We will respond personally.\n\n##  Make the expected results inspectable.\n\nBefore asking an assistant to implement a small change, write its inputs and expected outputs with the person who needs it. Work the answer out separately from the proposed implementation. For this calculation, we use the following checks; they are examples of scope, not a universal test count.\n\n| Invented input | Required result | Mistake the check targets |\n| --- | --- | --- |\n| One accepted attempt: 190 minutes; one rejected attempt: 95 minutes | 285 minutes in total, one accepted result, 285 minutes per accepted result | Counting attempts as accepted results, or dropping rejected effort |\n| Only the rejected 95-minute attempt | 95 minutes, zero accepted results; the ratio is undefined | Reporting zero effort per accepted result when there is no accepted result |\n| No attempts | Zero total minutes and zero accepted results; the ratio is still undefined | Confusing an empty sample with evidence of efficient work |\n| Missing, negative or non-numeric effort | Reject the input and leave the observation unresolved | Silently treating an unknown value as zero |\n\nOur correct implementation passed four targeted tests. We then introduced two faults separately: counting all attempts as accepted, and returning zero for an undefined ratio. Both faulty versions failed. This checks that the relevant assertions can detect those faults. It is not a defect-rate estimate and does not prove that the test suite finds every error.[\\[S1\\]](https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use#source-s1)\n\nFor your own change, choose a failure that follows from the actual task. A paid invoice appearing in an overdue list is a meaningful wrong result. A test that only checks whether the function returns an array would miss it.\n\n##  A working calculation still needs a code review.\n\nAsk a qualified developer to inspect what changed and how it connects to the application. Does the implementation match the agreed rule? Does it read or write data, change permissions, add a dependency or expose a new action? The answers determine which integration and security checks are needed beyond the small example.\n\nGitHub’s current guidance says Copilot review can miss problems, flag problems that do not exist, and suggest incorrect or insecure code. It recommends careful review and testing. Another AI review is useful input, but its approval is not proof that the change is ready.[\\[S2\\]](https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use#source-s2)\n\nKeep the tested code version, test inputs, actual results and unresolved findings together. If the code changes after review, check the affected parts again. Our [agent acceptance guide](https://www.minglabs.com/insights/answers/how-do-you-test-an-ai-agent-before-production) covers the separate question of whether a whole agent works with its intended model, data and permissions.\n\n##  Decide which version may be used.\n\nThe person who understands the required outcome and the person authorised to release the software need an explicit decision. Record what passed, what remains untested and whether the remaining risk is acceptable for this use. A developer’s completed implementation and a production approval are different events.\n\nAgree a response if the change fails in its intended environment. Check the version you would restore and whether data or dependencies would also need attention. The oldest available version is not automatically an acceptable fallback. Our proposed review record keeps the distinction visible.\n\n| Before release | Record |\n| --- | --- |\n| Required behaviour | The task owner, examples and expected results |\n| Technical review | The actual reviewer, exact version and unresolved findings |\n| Observed checks | Inputs, results and the intended environment; distinguish executed tests from planned tests |\n| Release and response | Who may approve this version, which limits apply and the checked response if it fails |\n\nThis is one practical part of a [hybrid organisation](https://www.minglabs.com/hybrid-organisation): people and agents share work while approval remains explicit. Start with one small change, its task owner and a qualified developer. Agree an expected-result table, then have the developer demonstrate one relevant wrong version being rejected before considering the release.\n\nCitable short version\n\nMING proposes checking a small AI-generated change against independently specified expected results, meaningful boundary cases and a deliberately incorrect version. In our calculation example, a rejected attempt adds effort without adding an accepted result. The targeted tests detect two constructed faults; they do not establish general code security or production readiness.\n\nAn actual test of our calculation code with invented inputs. Deliberate faults are test examples, not reported production incidents. No comprehensive security assurance.\n\n## What is missing before your AI-assisted change can be accepted?\n\nBring one small software task and an unresolved review decision. We can discuss the path from the required outcome through development to approval. This is not security certification.\n\n[Discuss my review process](https://www.minglabs.com/contact?type=project&topic=code-acceptance)\n\nTell us what you have in mind. We will respond personally.\n\n[See how to measure software effort ](https://www.minglabs.com/insights/answers/how-do-i-measure-ai-software-delivery-productivity)\n\n## Sources\n\n\\[S1\\]\n\n[Code checks on our calculation example](https://www.minglabs.com/insights/answers/how-do-i-measure-ai-software-delivery-productivity) MING Labs · 8 and 9 November 2026 Supports: 285 minutes for one accepted result; four targeted tests passed, both constructed faults detected. Our executed tests of the linked example’s calculation code. Invented numerical inputs; two deliberate faulty versions, not client cases or production incidents. Test record held privately.\n\n\\[S2\\]\n\n[Application card: GitHub Copilot Agents](https://docs.github.com/en/copilot/responsible-use/agents) GitHub · Accessed 9 November 2026 Supports: Missed problems, false positives and incorrect or insecure suggestions; careful review and testing remain necessary. Provider documentation of limitations and responsible use; not an independent effectiveness measurement.\n\n## Frequently asked questions\n\nCan the same AI write the code and the tests?\n\nIt can help draft both, but they may repeat the same mistaken assumption. Agree expected results from the business rule separately, review the assertions and check a deliberately wrong version. Using another model alone does not establish independent verification.\n\nDo four passing tests mean the code is safe?\n\nNo. Our four tests cover selected arithmetic and invalid-input cases. They do not examine access rights, dependencies, confidential data, the complete application or every possible input. Define the required checks according to what the change can affect.\n\nWhat can I check if I cannot read the code?\n\nYou can specify the required outcome with examples, ask to see the actual results and identify unresolved decisions. A qualified developer still needs to review the implementation and technical risks. Do not substitute an AI explanation for expertise you do not have.\n\nShould I return to the old version when a check fails?\n\nStop the release and assess a known, acceptable version with its owner. An old version may contain the very defect being fixed. Restoring its files is not proof of a safe rollback, especially when data or dependencies have changed.\n\n## Available actions\n\n- **Copy answer for my AI**: copies the [AI briefing](https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use.md) to the clipboard in the browser.\n\n---\n\nCanonical: https://www.minglabs.com/insights/answers/how-do-i-check-ai-generated-code-before-use\nMachine-readable index: https://www.minglabs.com/llms.txt\n"
}
