---
name: "review-ai-generated-code-method"
description: "Use when you need to Check code written by an AI assistant before you merge it. Review AI-generated code in eight steps"
---

# Review AI-generated code in eight steps

Job: [Check code written by an AI assistant before you merge it](https://aiagents.org/canai/review-ai-generated-code)

## Need

- ai agent: [CI with CodeQL, Dependabot or similar](https://aiagents.org/agents/ci-with-codeql-dependabot-or-similar), [GitHub Actions or another CI](https://aiagents.org/agents/github-actions-or-another-ci)

## Steps

1. Start with the machines: build the code, run the full test suite and static analysis, and look for new warnings, vulnerabilities and dependency problems.
2. Confirm it solves the right problem the way your project does things, and point the AI to your project documentation and recently merged changes for context.
3. Judge readability, naming and documentation yourself, and reject code that would be quicker to rewrite than to fix.
4. Check every new package: that it exists, is maintained, comes from a trustworthy source and has a license compatible with yours.
5. Look for mistakes typical of AI: invented APIs, ignored constraints, logic that only looks right, and failing tests that were deleted or skipped.
6. Bring in colleagues for tricky or high-risk changes, work from a checklist, and pass around prompts that worked.
7. Automate the routine checks in CI (style, lint, security, quality, coverage) and consider an agent that pre-reviews draft pull requests.
8. Write down your team's review practices, for example in CONTRIBUTING.md, and keep updating them.
9. Optional: The GitHub Docs page lists example Copilot Chat questions for each step; they are linked there, not copied here.
10. Note: The steps are restated in our own words from GitHub Docs (CC BY 4.0). Repeat on every AI-assisted pull request.

## Credit

Method author GitHub (GitHub Docs, CC BY 4.0)
Source: https://docs.github.com/en/copilot/tutorials/review-ai-generated-code
