Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

feat(claude-plugin): add /repowise:security slash command (#1107)

Felix-Ayushef38d6128d9f
diff --git a/plugins/claude-code/README.md b/plugins/claude-code/README.md
index c91d5e492..eab9c5c4f 100644
--- a/plugins/claude-code/README.md
+++ b/plugins/claude-code/README.md
@@ -55,6 +55,7 @@ defect-validated score from deterministic markers).
| `/repowise:coverage` | Ingest or inspect coverage reports (lights up untested hotspots + per-test map) |
| `/repowise:impacted-tests` | Tests whose coverage intersects a change (commit / range / staged) |
| `/repowise:risk` | Defect-risk score for a change (commit or `base..head` range) |
+| `/repowise:security` | Full-history secret scan (`repowise security scan --history`) |
| `/repowise:dead-code` | Unreachable files, unused exports, zombie packages by confidence |
| `/repowise:decision` | List, inspect, add, or confirm architectural decisions |
| `/repowise:doctor` | Diagnose (and optionally repair) the setup, keys, and index drift |
diff --git a/plugins/claude-code/commands/security.md b/plugins/claude-code/commands/security.md
new file mode 100644
index 000000000..7280c7c4c
--- /dev/null
+++ b/plugins/claude-code/commands/security.md
@@ -0,0 +1,52 @@
+---
+description: Scan for security signals — working-tree scanning already runs during init/update; use --history to walk full git history for leaked secrets.
+allowed-tools: Bash, Read
+---
+
+# Repowise Security
+
+Scan for security signals with the same local pattern registry used during
+`repowise init` / `repowise update`. Working-tree scanning already happens on
+those commands. This slash command is for walking **full git history** to find
+leaked secrets (and optionally risky patterns) that were later removed.
+
+No LLM — pure local scan. Findings persist to `security_findings` and show up
+in the local server security API / UI. Re-runs are idempotent.
+
+## Steps
+
+1. If `.repowise/` doesn't exist: "This repo isn't indexed yet. Run `/repowise:init` first." Stop.
+2. Decide the mode from `$ARGUMENTS` (see below), run the command, and present
+ a short summary (files scanned, findings stored, by severity / kind). Do not
+ print raw secret values if any appear in output — summarize kinds and paths.
+
+## Modes
+
+Default / no useful args — remind the user that working-tree scanning already
+ran during init/update, then offer history mode:
+```
+repowise security scan
+```
+(Without `--history` this prints a hint and exits — it does **not** re-run the
+working-tree scan.)
+
+Handle `$ARGUMENTS`:
+- "history" / "full" / "scan history" → `repowise security scan --history`
+- "json" with history → `repowise security scan --history --output json`
+- "all" / "all-patterns" with history → `repowise security scan --history --all-patterns`
+- A path → `repowise security scan --history --path <dir>`
+- "since <rev>" / "to <rev>" → pass `--since` / `--to` accordingly
+
+```
+repowise security scan --history
+repowise security scan --history --since v1.0.0 --to HEAD
+repowise security scan --history --all-patterns --output json
+```
+
+## Notes
+
+- Default history mode reports **leaked-secret** patterns only
+ (`hardcoded_password` / `hardcoded_secret`) to avoid noise. Pass
+ `--all-patterns` for code-smell patterns (`eval`, `os.system`, weak hashes, …).
+- Never invent findings. If the scan stores zero findings, say so plainly.
+- For change defect risk (not secret scanning), use `/repowise:risk`.
diff --git a/tests/unit/cli/test_claude_plugin.py b/tests/unit/cli/test_claude_plugin.py
index cdbcdfdeb..8dce412b5 100644
--- a/tests/unit/cli/test_claude_plugin.py
+++ b/tests/unit/cli/test_claude_plugin.py
@@ -165,6 +165,7 @@ def test_claude_plugin_commands_have_frontmatter() -> None:
"reindex",
"risk",
"search",
+ "security",
"status",
"update",
}