---
name: secret-redact-before-ai
description: >
  Redact secrets and PII before sending text to an AI or committing. Use when pasting
  logs, env files, traces, or screenshots text, or Chinese "脱敏", "密钥", "token",
  "别把密码给 AI", "redact". Practical privacy guard for AI coding sessions.
---

# Secret Redact Before AI

## Overview

Scan user-provided or workspace text for credentials and PII; produce a **redacted copy** safe to paste into models. Prefer block over partial if unsure.

## Patterns to flag (non-exhaustive)

- API keys, tokens, `Bearer …`, JWT-shaped strings  
- Private keys (`BEGIN … PRIVATE KEY`)  
- Passwords, connection strings with credentials  
- Cloud keys (AKIA…, etc.), webhook secrets  
- Emails/phones if user asked for PII scrub  
- Internal hostnames/IPs if policy says so  

## Steps

1. Identify corpus (paste, file paths, `git diff`, log snippet).  
2. Scan; list findings with **type** and **location** (not full secret values).  
3. Produce redacted text (`***REDACTED_TYPE***` placeholders).  
4. Say what still must not be committed (`.env`, key files).  
5. Optional: suggest `.gitignore` / gitleaks rules.  

## Exit criteria

- [ ] Corpus identified  
- [ ] Findings listed without echoing full secrets  
- [ ] Redacted version provided  
- [ ] Commit/chat safety advice given  

## Anti-patterns

- Printing full secrets “for confirmation”  
- Claiming “no secrets” without scanning  

## Output template

```markdown
## Redaction report
### Findings
| type | where | action |
|------|-------|--------|
### Safe-to-paste text
...
### Do not commit
- ...
```
