Run five checks before merging AI-written code
Check secrets, unused code, duplication and dependencies, then put repeatable checks in hooks.
Published · 5 sources · Resume reading
Gitleaks, Knip, jscpd, OSV-Scanner and Lefthook cover different parts of a review. Their documentation describes secret detection, unused-code analysis, duplicate-code detection, dependency scanning and Git hooks respectively [1][2][3][4][5].
Scan the repository for secrets
On macOS with Homebrew, Gitleaks documents this installation. Run the scan from your repository [1].
brew install gitleaks
gitleaks git -vReview each finding before sharing scan output: it can contain the secret that was found [1].
Check unused code and duplication
Follow Knip's setup for your JavaScript or TypeScript project. Review its reported entry points before removing anything it considers unused [2].
For duplication, jscpd documents a one-off scan [3].
npx jscpd .Use the duplicate locations to inspect the code. Similar text can still serve different behavior.
Scan dependency files
Install OSV-Scanner using its documented installation for your system. Its source scan walks supported package files [4]. Replace the example directory with your checkout.
osv-scanner scan source -r /path/to/your/dirKeep the useful checks in hooks
Lefthook runs commands you define in lefthook.yml. After configuring those commands, its README installs them into the Git project with [5]:
lefthook installKeep your application's tests in the review too. These tools report particular problems; a clean scan does not prove the feature works.
Keep this guide
Sources
- Knip: getting startedknip.dev
- jscpd repository: quick startgithub.com
- OSV-Scanner repository: source scanninggithub.com
- Lefthook repository: usagegithub.com
Next in this stack
Keyword AUTHFIX
Check Better Auth Magic Link and OAuth Proxy fixes
Keyword DEPGATE
Check packages before trusting an AI suggestion
Keyword ACTIONGATE
Check GitHub Actions before merging workflows