> For the complete documentation index, see [llms.txt](https://docs.snyk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snyk.io/developer-tools/snyk-cli/scan-and-maintain-projects-using-the-cli/snyk-cli-for-secrets.md).

# Snyk CLI for Snyk Secrets

How to use the Snyk CLI to scan your source code for hardcoded secrets

The [Snyk Command Line Interface](/developer-tools/snyk-cli/overview.md) (CLI) enables you to bring the functionality of [Snyk Secrets](https://docs.snyk.io/scan-fix-and-prevent/scan-with-snyk/snyk-secrets) into your development workflow. Using the Snyk CLI, you can scan your source code locally, in a pre-commit hook, or in your CI/CD pipeline to find hardcoded secrets such as API keys, passwords, and tokens.

## Prerequisites for using the Snyk CLI with Snyk Secrets

Before using the Snyk CLI to scan for secrets, verify you have the following prerequisites:

* A Snyk account.
* The Secrets feature enabled for your Snyk Organization. If you receive a `SNYK-CLI-0016` error, contact your Snyk account manager.
* The Snyk CLI installed and authenticated.
  * For instructions, visit [Install or update the Snyk CLI](/developer-tools/snyk-cli/install-the-snyk-cli.md) and [Authenticate the Snyk CLI](/developer-tools/snyk-cli/authenticate-to-use-the-cli.md).
  * Snyk recommends using the latest version of the CLI.

## Using the Snyk CLI for secrets scans

To scan your code for hardcoded secrets using the Snyk CLI, use the [`snyk secrets test`](/developer-tools/snyk-cli/commands/secrets-test.md) command.\
For more information, see [Secrets scanning in the Snyk CLI](/developer-tools/snyk-cli/scan-and-maintain-projects-using-the-cli/snyk-cli-for-secrets/secrets-scanning-in-the-snyk-cli.md).

That page also explains how to do the following:

* [Ignore findings](/developer-tools/snyk-cli/scan-and-maintain-projects-using-the-cli/snyk-cli-for-secrets/secrets-scanning-in-the-snyk-cli.md#ignore-findings) that are placeholders, revoked keys, or won't fix scenarios.
* [Review ignored secrets](/developer-tools/snyk-cli/scan-and-maintain-projects-using-the-cli/snyk-cli-for-secrets/secrets-scanning-in-the-snyk-cli.md#review-ignored-secrets) to audit your codebase.
* [Exclude files and directories from a scan](/developer-tools/snyk-cli/scan-and-maintain-projects-using-the-cli/snyk-cli-for-secrets/secrets-scanning-in-the-snyk-cli.md#exclude-files-and-directories-from-a-scan) using the `.snyk` file or the `--exclude` option.
* [Scan with a pre-commit hook](/developer-tools/snyk-cli/scan-and-maintain-projects-using-the-cli/snyk-cli-for-secrets/secrets-scanning-in-the-snyk-cli.md#scan-with-a-pre-commit-hook) to catch secrets before they reach a commit.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.snyk.io/developer-tools/snyk-cli/scan-and-maintain-projects-using-the-cli/snyk-cli-for-secrets.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
