CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

trysac/secrets-precommit

Scan files for leaked secrets (cloud, GitHub, Slack, Stripe, Google, AI keys, private keys, high-entropy assignments) with output that never prints the secret. Use when the user asks to check staged files or a repo for secrets before committing.

Quality

95%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Medium

Suggest reviewing before use

Overview
Quality
Evals
Security
Files

SKILL.md

name:
secrets-precommit
description:
Scan files for leaked secrets (cloud, GitHub, Slack, Stripe, Google, AI keys, private keys, high-entropy assignments) with output that never prints the secret. Use when the user asks to check staged files or a repo for secrets before committing.

secrets-precommit

Detects ten kinds of secrets in text files and reports where they are without ever printing the full value (at most four leading characters plus ****). Python 3.10+, nothing to install or compile, no network.

When to use

  • Before a commit or push: "check my staged files for secrets".
  • Reviewing a repository or a diff for leaked keys, tokens or private keys.
  • Setting up team-specific secret patterns and allowlists.

It scans the files you give it. It does not read git history and cannot validate whether a match is a live credential.

Workflow

  1. Choose the files. For staged changes, list them yourself and pass them as arguments:

    git diff --cached --name-only --diff-filter=ACM
    python3 scripts/scan_secrets.py path/one.py path/two.env
  2. Read each line path:line:column: rule-id: redacted. Open the file at that position and decide if it is a real secret.

  3. If it is real: remove it from the code and load it at run time from the user's secret store; treat the value as exposed and tell the user to rotate it (anything that reached a shared remote or log is compromised).

  4. If it is a placeholder or test value, either change it so it no longer looks like a credential, or add the marker secrets-precommit:allow in a comment on the same line, or list the path or value pattern in the config allowlist.

  5. Re-run the same command until it exits 0.

Never copy a secret into your reply, a commit message or a report; quote the rule id, file and line only.

Exit codes

CodeMeaning
0Nothing found
1At least one potential secret
2Usage, configuration or read error (and nothing found)

Options

python3 scripts/scan_secrets.py [--config FILE] [--format text|json] [--no-defaults] [--verbose] FILE...
  • --config FILE: team rules and allowlists in JSON (see references/config.md).
  • --format json: findings as a JSON array with ruleId, path, line, column, redacted.
  • --no-defaults: only the team rules from the config.
  • --verbose: list skipped files (binary, over 1 MiB, symlink, directory, allowlisted) on stderr.

Built-in rules

aws-access-key-id, github-token, github-fine-grained-pat, slack-token, stripe-live-key, google-api-key, anthropic-api-key, openai-api-key, private-key-block, generic-assignment. Patterns and entropy threshold: references/rules.md. Running it automatically on each commit with the user's own hook: references/hook.md.

Limits

Secrets in history, encoded (base64, hex) or split across lines are not found; a match can be a false positive; anyone who can edit the allowlist or add the allow marker can suppress findings.

SKILL.md

tile.json