secret-remediation

Rewrite git history to remove committed secrets and PII.

Updated Mar 31, 2026
One-click install
npx skills add https://github.com/shellicar/skills --skill secret-remediation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: secret-remediation
Source: https://github.com/shellicar/skills/tree/main/skills/secret-remediation
Command: npx skills add https://github.com/shellicar/skills --skill secret-remediation

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires git, sed, find, cmp, and includes scripts (resource) components.

What problem does it solve?

This Skill provides a repeatable, safety‑first workflow to rewrite git commit history to remove secrets and personally identifiable information that were committed and later detected by secret-scanning, and it emphasizes mandatory credential rotation for any value that reached a remote.

Core Features & Use Cases

  • Scenario-aware remediation: Handles main-only, feature-branch local-only, pushed feature with PR, and combined scenarios with clear actions for each.
  • Search and scrub tools: Includes a read-only history search, a destructive orchestrator that runs git filter-branch, and a tree-filter helper that applies sed expressions per commit.
  • Safety guardrails: Enforces a clean working tree, requires an explicit destructive flag, creates a backup tag, shows a countdown, and prints the force-push command for manual execution.
  • Operational guidance: Guides credential rotation, plan confirmation with the Supreme Commander, per-branch execution, and post-scrub verification.
  • Use Case: After secret-scanning finds an API key in past commits on main and a pushed feature branch, use this Skill to plan replacements, scrub affected branches, and coordinate credential rotation and force-pushes.

Quick Start

Run the secret-remediation workflow after secret-scanning identifies historical values by creating an expressions file, confirming the replacement plan with the Supreme Commander, running the search to preview matches, and then executing the scrub per affected branch with the required safety flag.

Frequently Asked Questions about secret-remediation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I remove secrets and PII from git history after they have been committed?

Use git filter-branch with sed replacement patterns to rewrite repository commits and remove committed secrets. This process scrubs affected branches by applying an expressions file of replacement patterns to targeted historical commits, replacing sensitive values.

What is the safest way to rewrite git history to scrub secrets across main and feature branches?

The safest way to rewrite git history for secret scrubbing requires a clean working tree, backup tags, and per-branch execution. You run a read-only search to preview matches, then execute the destructive filter-branch scrub with an explicit flag for each affected branch separately.

Do I need to rotate credentials if I rewrite git history to remove pushed secrets?

Yes, mandatory credential rotation is required for any secret values that reached a remote repository. Rewriting git history removes the secret from commits, but any pushed credentials must be considered compromised and rotated immediately to prevent unauthorized access.

Can I use git filter-branch and sed to remediate secrets in a repository with pushed feature branches and PRs?

Yes, this secret remediation workflow handles pushed feature branches with PRs by applying sed expressions per commit via a tree-filter helper. You must run the scrub per affected branch and manually execute the force-push command to update the remote.

What are the limitations and prerequisites for using git filter-branch to remove secrets from repository commits?

Prerequisites include a clean working tree and an expressions file of sed replacement patterns. Limitations involve requiring an explicit destructive flag to run the scrub, manual force-push execution to update remotes, and coordinated credential rotation for any values previously pushed.

Why does secret remediation require an expressions file and a manual force-push after rewriting commits?

An expressions file defines the sed replacement patterns used to scrub secrets per commit. A manual force-push is required because the destructive orchestrator rewrites history and prints the force-push command for manual execution, ensuring the remote update is deliberate and coordinated.