agentleFS
diegocconsolinidiegocconsolini/ClaudeSkillCollection/batch-security-migration/SKILL.md

batch-security-migration

Skill7 starsChanged 14 months agoMITView on GitHub

Use when applying the same security fix across many files or repos at once — large-scale vulnerability remediation. Provides 7 copy-paste /batch recipes (XSS, HTTPS, SQLi, input validation, log PII, secret rotation, CVE patches) each with a safety tier and false-positive trap, plus scan_diff.py to prove the migration introduced no new HIGH/CRITICAL findings.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run a baseline scan: scan_plugin.py <target> --output before.json --format json.

    line 33
  2. Distinctive:

    Ensure the existing test suite passes before you start.

    line 36
  3. Very specific:

    Verify: grep -rn 'innerHTML' src/ returns only reviewed cases.

    line 54
  4. Very specific:

    Verify: grep -rn 'http://' .

    line 59
  5. Distinctive:

    Verify handler coverage and that no unintended dependency was added.

    line 69

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Batch Security Migration

Turn Claude Code's built-in /batch into a security-migration tool. This skill does not reinvent /batch — /batch already fans work out into worktree-isolated per-unit PRs. This skill supplies the recipes, the safety tiers, and an objective before/after gate (scripts/scan_diff.py).

When to use

You have the same vulnerability class in many places (dozens of files, or many repos) and want to fix them in one coordinated pass with per-unit review and a regression gate.

Safety tiers

TierMeaning
🟢 safeMechanical text substitution; review only the flagged dynamic cases.
🟡 reviewSemantic change; the per-unit PR review is the gate.
🔴 manualNever full-auto — high blast radius. Drive /batch one unit at a time with a human + test run per unit.

Pre-scan checklist

  1. Clean git tree (git status empty) — /batch needs a clean base.
  2. Run a baseline scan: scan_plugin.py <target> --output before.json --format json.
  3. Confirm /batch is available (Claude Code ≥ 2.1.63).
  4. Scope to a subdirectory first; don't run repo-wide on the first pass.
  5. Ensure the existing test suite passes before you start.

Recipes

#RecipeTierFalse-positive trapVerify
1XSS: innerHTML → textContent🟢 safedynamic-HTML assignment is intentional in a few spotsgrep should drop for static cases
2HTTPS: http:// → https://🟢 safelocalhost / 127.0.0.1 / example URLs must be excludedno http:// outside the allowlist
3SQLi: string-concat → parameterized🟡 reviewnot every concatenated string is a queryper-unit PR review
4Input validation on route handlers🟡 reviewmay add a dependency; verify handler coveragetests + handler list
5Log sanitization: strip PII from logs🟡 reviewregex over-match can corrupt non-PII logscheck redaction correctness
6Secret rotation: hardcoded key → env var🔴 manualtest fixtures look like real secretsmanual per unit + secret scan
7Dependency CVE patch updates🔴 manuala patch can break an APItest run per bump

1. XSS: innerHTML → textContent (🟢)

/batch over files matching grep -rl 'innerHTML' src/: "Replace element.innerHTML = x with element.textContent = x where x is plain text. Leave intentional HTML injection (templating, sanitized fragments) and add a // reviewed: dynamic HTML comment instead." Verify: grep -rn 'innerHTML' src/ returns only reviewed cases.

2. HTTPS: http:// → https:// (🟢)

/batch: "Replace http:// with https:// in source and config. Do NOT touch localhost, 127.0.0.1, 0.0.0.0, example.com, or XML namespace URIs." Verify: grep -rn 'http://' . | grep -v -E 'localhost|127\.0\.0\.1|example\.' is empty.

3. SQLi: parameterized queries (🟡)

/batch: "Convert string-concatenated SQL into parameterized queries for the driver in use. Each file is its own PR — flag any query you can't safely parameterize." Review every per-unit PR; this is semantic.

4. Input validation on route handlers (🟡)

/batch: "Add input validation to each Express/route handler using the project's existing validation library. If none exists, flag the unit instead of adding a new dependency." Verify handler coverage and that no unintended dependency was added.

5. Log sanitization: strip PII (🟡)

/batch: "Wrap log statements that emit email/SSN/credit-card values in the project's redaction helper. Don't redact non-PII." Check redaction correctness — regexes over-match.

6. Secret rotation: hardcoded key → env var (🔴 manual)

Drive /batch one unit at a time. "Replace a hardcoded secret with os.environ[...] / process.env... and add it to .env.example." Trap: test fixtures and example keys look like real secrets — never full-auto. After: rotate every real key that was exposed.

7. Dependency CVE patch updates (🔴 manual)

Drive /batch one bump at a time. "Update <pkg> to the patched version for <CVE>." Trap: patches can break APIs — run the full test suite per bump before merging.

Post-migration workflow

  1. Merge the per-unit PRs /batch produced.
  2. Re-scan: scan_plugin.py <target> --output after.json --format json.
  3. Gate: python3 scripts/scan_diff.py before.json after.json
    • exit 0 + "GATE: PASS" → no new HIGH/CRITICAL; ship.
    • exit 1 + "GATE: FAIL" → triage the listed NEW findings, or re-run with --report-only once you've justified them.

Or let scan_diff run both scans for you: python3 scripts/scan_diff.py --scan <target_before> <target_after>

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.