Scan source code with Snyk Code using the CLI

Snyk Code enables you to test the source code of your repositories using the Snyk CLI.

When testing your repository code via the CLI, you can:

When you test a folder, all its sub-folders and files are also tested.

To exclude certain directories or files from the Snyk Code CLI test, you can use the following means:

Testing a repository from its root folder

To test the current repository folder, in the terminal, enter the following:

snyk code test

No additional options are required for using the snyk code test command to test a repository from its root folder.

Snyk Code tests the current folder and displays the test results in the terminal.

For example, to test the snyk-goof repository from its root folder, first change the directory to the root folder of the repository. Then enter:

snyk code test

Snyk Code tests the snyk-goof repository, and displays the vulnerability issues that were discovered:

Testing a repository from a different location

To test a repository from another folder, in the terminal, enter the following:

snyk code test <path/to/folder>

The path/to/folder is the full path of the repository you want to test using Snyk Code via the CLI.

For example, to test the snyk-goof repository from another directory, enter:

snyk code test /Users/username/Documents/Repositories/snyk-goof

Last updated

More information

Snyk privacy policy

© 2023 Snyk Limited | All product and company names and logos are trademarks of their respective owners.