Skip to content
Back to skills

Secrets Hygiene

ASecurity

Secret hygiene for repos and environments: detection gates (pre-commit, CI, history), rotate-first incident response, secret manager patterns, env var rules, inventory and rotation policy. Use when auditing .env and git history for leaked credentials, planning a rotation, responding to a leak, or standing up scanning.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 27, 2026
ai-agentsawsgit

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned November 27, 2026

npx -y skills add novahiz/novahiz --skill secrets-hygiene --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Secrets Hygiene?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Secrets Hygiene
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/novahiz-secrets-hygiene/badge)](https://www.skillsdirectory.com/skills/novahiz-secrets-hygiene)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: "secrets-hygiene"
description: "Secret hygiene for repos and environments: detection gates (pre-commit, CI, history), rotate-first incident response, secret manager patterns, env var rules, inventory and rotation policy. Use when auditing .env and git history for leaked credentials, planning a rotation, responding to a leak, or standing up scanning."
license: "Apache-2.0"
metadata:
  author: Novahiz
  organization: Novahiz
  version: "1.0.0"
  date: September 2026
---

# secrets-hygiene

Credentials that reach git are compromised. Deletion and force-push clean history; only rotation kills the credential. This skill covers detection, response order, and the steady-state setup that keeps new leaks from shipping.

## Detection gates

| Gate | Where | Tool shape | Limits |
|---|---|---|---|
| Pre-commit | Developer machine | gitleaks / git-secrets hook on the diff | `--no-verify` bypass; hook must be installed |
| CI | PR and default branch | gitleaks detect, TruffleHog, platform secret scanning | Misses secrets only in old history |
| History | Full repo, periodic | `gitleaks git`, TruffleHog history mode | Slow on large repos; needs triage |

Enable all three. Tune false positives weekly until the team stops disabling hooks; a noisy scanner gets switched off.

## When a secret lands in git

Order is fixed. Do not start with history surgery.

1. **Identify** the credential type, scope, and where it is used.
2. **Rotate or revoke** at the provider. The old value must stop working before anything else.
3. **Update** every consumer (deploy env, secret store, local `.env` that is not committed).
4. **Purge history** with `git filter-repo` (or BFG), force-push, coordinate re-clones and fork deletion.
5. **Verify**: full-history scan clean; only the new credential authenticates; provider audit log reviewed for use of the old key.

Public remote or CI logs: assume the scrapers already have it. Rotate first, always.

## Steady state

- Never commit `.env`, key files, or PEM blocks. `.env.example` holds names only.
- Load secrets at runtime from the platform secret manager or injected env; never hardcode in source or tests.
- Short TTL where the provider supports it; prefer workload identity over long-lived static keys.
- Inventory: every credential has type, owner, rotation policy, and where it lives. You cannot rotate what you do not know.
- Metric: time from detect to confirmed rotation (target under a few hours for production).

## Redaction in logs

Log auth events without the secret itself. Truncate tokens in error pages. Scrub request/response bodies in support tooling.

## Checklist

- [ ] Pre-commit scanner installed and required (or CI enforces equivalent).
- [ ] CI scan on every PR and on schedule against default branch.
- [ ] Full-history scan run once at adoption; baseline file for old accepted findings if needed.
- [ ] `.env` gitignored; example file has placeholders.
- [ ] No live credentials in fixtures or snapshots.
- [ ] Rotation runbook names the person and the console for each credential class.
- [ ] Post-incident: revoke confirmed, history purged, scan green.

## Sources

Gitleaks and TruffleHog project docs; AWS git-secrets patterns; OWASP and industry guidance that history rewrite is cleanup while rotation is containment. Original Novahiz synthesis; no upstream skill text.

Files in this skill

  • SKILL.md3.3 KB
  • references/rotation-playbook.md928 B
  • scripts/secret_scan.mjs3.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.