--- name: undercover description: >- UNDERCOVER — Universal AI Contribution Watermark Neutralization & Stealth Audit Skill for Claude Code, Antigravity, Codex, Cursor, Gemini CLI, OpenCode, and Aider. Use when contributing commits, PRs, issues, or code without AI attribution watermarks (Co-Authored-By, Generated with Claude Code, Made-with: Cursor, Assisted-by, bot emails), auditing repositories for AI traces or invisible Unicode watermarks, hardening local AI tool configs, installing Git/PreToolUse guard hooks, or safely scrubbing unpushed commit history. (한국어 트리거: 언더커버 모드, AI 기여 워터마크 제거/무효화, 클로드 코드 Co-Authored-By 제거, 커밋/PR 흔적 제거, 비가시 유니코드 워터마크 정리.) --- # UNDERCOVER — AI Contribution Watermark Neutralization > **Zero Attribution Drift**: Universal stealth protocol and zero-dependency audit/guard/scrub CLI for **Claude Code**, **Antigravity**, **Codex**, **Cursor**, **Gemini CLI**, **OpenCode**, and **Aider**. ## 1. Undercover Operating Protocol (Always Active While Loaded) When operating under this skill in any repository, maintain strict attribution-free contribution hygiene: 1. **Git Commits**: - NEVER append `Co-Authored-By`, `Assisted-by`, `Generated-by`, `Made-with`, or `AI-Assisted-By` trailers referencing any AI tool, model, or vendor (`Claude`, `noreply@anthropic.com`, `Cursor`, `Copilot`, `Codex`, `Aider`, `Gemini`, `Antigravity`, `OpenCode`, `Devin`, etc.). - NEVER include `🤖 Generated with ...` or `Generated by ...` lines in commit bodies. - NEVER set or preserve AI author/committer identities (e.g., `(aider)` suffix or bot emails). - Write crisp, factual commit messages matching the repository's existing human style (`git log -n 10 --oneline`). 2. **Pull Requests, Issues & Review Comments**: - NEVER add AI generator footers (`Generated with [Claude Code](...)`, `Powered by ...`, HTML attribution comments) or self-referential AI phrases (`As an AI`, model versions, private internal links, or confidential project codenames). - Before submitting any PR body via `gh pr create` / `gh pr edit`, pipe the draft through `sanitize-text --kind pr` if unsure. 3. **Source Code & Diffs**: - NEVER write attribution headers/comments (`// Generated by Claude`, `# Auto-generated by Cursor`, `// TODO(ai): ...`). - NEVER introduce invisible Unicode watermarks (Unicode Tags `U+E0000–U+E007F`, stray zero-width characters `U+200B/200C/200D/2060/FEFF`, bidi overrides, or exotic narrow spaces like `U+202F`). 4. **Agent Trace Files**: - NEVER stage or commit `.claude/`, `CLAUDE.local.md`, `.cursor/`, `.cursorrules`, `.aider*`, `.windsurf*`, `.roorules`, `.clinerules`, or local `.agents/` state unless the repository explicitly tracks shared agent docs. - Prefer `.git/info/exclude` (private local exclude) over editing `.gitignore` so even the ignore rules do not reveal local AI tooling. ## 2. Dependencies - **Runtime**: Python 3.9+ standard library only (`python3` or `uv run` — zero third-party packages). - **Platform Tools**: Standard `git` CLI. - **Network**: None (100% offline / air-gap safe). ## 3. Quick Start (`scripts/undercover.py`) Every subcommand supports `--output ` (writing structured JSON and printing a one-line status summary to stdout). All mutating subcommands default to **safe dry-run** and require `--apply` to write changes. ### Step 1: Audit a Repository & Local Tool Configs ```bash python3 ./scripts/undercover.py audit /path/to/repo \ --max-commits 200 \ --output /tmp/undercover_audit.json ``` Inspect findings concisely: ```bash python3 -c "import json; d=json.load(open('/tmp/undercover_audit.json')); print(d['stealth_grade'], d['severity_counts']); [print(f['severity'], f['pillar'], f['message']) for f in d['all_findings']]" ``` ### Step 2: Configure Auto-Scope Policy (Optional Internal Allowlist & Blocked Terms) By default, stealth policy is **fail-closed (always active)**. To automatically stand down on private/internal remotes while enforcing stealth on all external/public repos (and block custom confidential terms): ```bash python3 ./scripts/undercover.py init-policy \ --mode auto \ --internal-remotes "github.com/my-private-org/*,git.corp.local/*" \ --blocked-terms "ConfidentialCodename,internal-wiki.local" \ --apply # Inspect whether stealth policy is active for a repo python3 ./scripts/undercover.py repo-status /path/to/repo ``` Set `UNDERCOVER_FORCE=1` to force stealth mode on even inside allowlisted internal repos. ### Step 3: Harden Local AI Tool Configs (Attribution + SessionStart & PreToolUse Hooks) Preview first (dry-run), then apply with automatic timestamped backups: ```bash python3 ./scripts/undercover.py harden-configs --claude --with-claude-hook --antigravity-hook --project /path/to/repo python3 ./scripts/undercover.py harden-configs --claude --with-claude-hook --antigravity-hook --project /path/to/repo --apply ``` - Sets `"attribution": { "commit": "", "pr": "" }` in `~/.claude/settings.json` (official schema; supersedes deprecated `includeCoAuthoredBy`). - Registers **both** dual-protocol hooks for Claude Code (`--with-claude-hook`) and Antigravity (`--antigravity-hook`): - `SessionStart` (`session-start`): Automatically injects clean-contribution policy into every session on external/public repos (stands down quietly on allowlisted internal repos). - `PreToolUse` (`pre-tool-guard`): Blocks watermarked `git commit`, `gh pr create/edit`, `gh issue`, and `git add .claude/` commands before execution. - Optionally disables Aider attribution (`--aider`), VS Code/Cursor `git.addAICoAuthor` (`--editors`), and populates private `.git/info/exclude` (`--project`). ### Step 4: Install Zero-Leak Git Hooks (`commit-msg`, `pre-commit`, `pre-push`) Per-repository (chains existing hooks safely via `--chain`): ```bash python3 ./scripts/undercover.py install-hooks --repo /path/to/repo --mode scrub --chain --apply ``` Or globally across all repositories via `~/.config/undercover/hooks` + `core.hooksPath` (automatically chains each repo's local `.git/hooks/*`): ```bash python3 ./scripts/undercover.py install-hooks --global --mode scrub --apply ``` - `commit-msg`: Auto-scrubs AI trailers, generator footers, and invisible Unicode on every commit (use `--mode block` to reject instead of auto-scrubbing), and blocks AI bot author/committer identities. - `pre-commit`: Blocks staging of AI agent trace files, AI attribution comments, and invisible Unicode watermarks in staged diffs. - `pre-push`: Final gate inspecting all outgoing commits before they leave the machine. ### Step 5: Clean Working-Tree Comments & Invisible Unicode ```bash python3 ./scripts/undercover.py clean-unicode /path/to/repo --output /tmp/unicode.json python3 ./scripts/undercover.py clean-unicode /path/to/repo --apply python3 ./scripts/undercover.py clean-comments /path/to/repo --output /tmp/comments.json python3 ./scripts/undercover.py clean-comments /path/to/repo --apply ``` ### Step 6: Sanitize PR Bodies or Commit Drafts Before Posting ```bash cat pr_draft.md | python3 ./scripts/undercover.py sanitize-text --kind pr ``` ### Step 7: Safely Scrub Unpushed Local Commit History Dry-run first (refuses dirty working tree and refuses already-pushed commits unless `--allow-pushed` is explicitly passed; always writes a rollback ref `refs/undercover-backup/...`): ```bash python3 ./scripts/undercover.py scrub /path/to/repo python3 ./scripts/undercover.py scrub /path/to/repo --apply ``` If the branch has no upstream yet, pass `--base ` or `--all-local`. ## 4. Verification Protocol for Agents When asked to enable undercover mode, remove AI watermarks, or verify a repository before pushing/PR: 1. **Audit first**: Run `audit` with `--output /tmp/undercover_audit.json` and check `stealth_grade` (`A`–`F`) and `all_findings` in severity order (`CRITICAL` → `HIGH` → `MEDIUM` → `INFO`). 2. **Harden before committing**: Recommend or apply `harden-configs` and `install-hooks` (always preview dry-run and confirm with the user before modifying global `~/.claude/settings.json`, `~/.config/undercover/hooks`, or global `git config`). 3. **Scrub local history safely**: Only rewrite unpushed commits unless the user explicitly approves rewriting pushed history and force-pushing; always report the created `backup_ref` and `rollback_command`. 4. **Re-audit to confirm `stealth_grade: A`**: Never claim clean stealth status without running `audit` again after remediation. ## 5. Reference Manuals Load on demand when deeper details or manual recipes are needed: - [AI Attribution & Watermark Catalog](./references/attribution_catalog.md) — complete inventory of AI trailers, bot emails, PR badges, trace files, and invisible Unicode codepoints. - [Tool Configuration Hardening Recipes](./references/tool_hardening.md) — per-tool setup for Claude Code (`settings.json` + `PreToolUse`), Antigravity (`hooks.json`), Aider, VS Code/Copilot, Cursor, Codex CLI, Gemini CLI, OpenCode, and `.git/info/exclude`. - [Git Hooks & Safe History Scrubbing Guide](./references/hook_and_scrub_guide.md) — hook chaining, `.undercoverignore`, rollback recovery, and force-push safety rules.