Use when a ranked list of confirmed security findings exists and must be fixed and shipped. Applies fixes one at a time on the current branch, one fix per commit with a regression test in the same commit, verifying the project's check command and full test suite after every commit, then folding the pattern into prevention.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Security Fix Cycle?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/gethacked-ai-security-fix-cycle)
---
name: security-fix-cycle
description: >-
Use when a ranked list of confirmed security findings exists and must be fixed and shipped. Applies fixes one at a time on the current branch, one fix per commit with a regression test in the same commit, verifying the project's check command and full test suite after every commit, then folding the pattern into prevention.
metadata:
version: "1.0"
---
# Security Fix Cycle
The disciplined loop that turns confirmed findings into shipped fixes. The audit phase belongs to `security-review` — this skill starts where the audit ends.
## Entry condition
You have a **ranked list of confirmed findings**: each with `file:line`, a severity (CRITICAL / HIGH / MEDIUM / LOW), and a description of the failure. If you do not have that list, run `security-review` first (and `threat-modeling` or `software-supply-chain-security` for design and dependency risk), consolidate the output into a ranked list, and come back here.
## Rules that do not bend
1. **Audit agents are read-only.** They report; they never modify code. A finding without `file:line` and evidence is not a finding.
2. **One fix at a time, on the current branch.** Each fix is committed to the working branch — no fix branch, no merge. Never fix in parallel worktrees: parallel fixes on overlapping files conflict, and the conflict resolution silently reverts an earlier fix. A linear history keeps each fix bisectable and revertible with a single `git revert`.
3. **One fix per commit.** "Fix 15 security issues" is unreviewable and unrevertable.
4. **Every fix ships with a regression test in the same commit.** The test fails before the fix and passes after.
5. **Verify after every commit.** Run the project's check command and its full test suite; proceed only if both pass.
6. **Never resolve a conflict with `--theirs` on security-critical files.** Resolve it by hand, understanding both sides.
7. **Full suite before push.**
8. **Stop and investigate** if a later audit finds a regression from an earlier fix.
## Phase 1: Preparation (before the first fix)
```
[ ] 1. Create a baseline: run the project's test command, record the pass/fail state
[ ] 2. Run the project's dependency-audit command, record known vulnerabilities
[ ] 3. Record the current bug count by severity — the target for the next cycle
[ ] 4. Identify high-risk areas: recent changes, external interfaces, auth paths
```
Commands are the project's own — never hard-coded. Examples:
| Purpose | Rust | Node | Python | Go |
|---|---|---|---|---|
| check / build | `cargo check --all-features --all-targets` | `npm run build` | `ruff check .` | `go vet ./...` |
| test (full suite) | `cargo test --all-features --quiet` | `npm test` | `pytest -q` | `go test ./...` |
| dependency audit | `cargo audit` | `npm audit` | `pip-audit` | `govulncheck ./...` |
| lint | `cargo clippy -- -D warnings` | `npm run lint` | `ruff check .` | `golangci-lint run` |
## Phase 2: Audit (owned by `security-review`)
Do not re-audit here. `security-review` runs the read-only pass and produces the ranked list. The only rule carried forward is that those agents never modify code:
```
┌────────────────────────────────────────────────────────┐
│ AUDIT AGENTS — read-only, one focus area each │
├────────────────────────────────────────────────────────┤
│ input validation · auth & authorization · crypto and │
│ secrets · concurrency · error handling · dependencies │
└────────────────────────────────────────────────────────┘
```
Each agent audits only its area, reports `file:line` + severity + description, and attempts no fix.
## Phase 3: Consolidate (single agent)
One agent combines all findings into a single prioritized list. This is the entry condition for the fix cycle:
```markdown
## CRITICAL (fix first, may block others)
1. [file:line] SQL injection in /api/users — parameterized query missing
2. [file:line] Auth bypass in /admin — missing permission check
## HIGH (fix before the next audit)
3. [file:line] Command injection in script runner — shell metacharacters not escaped
4. [file:line] Path traversal in plugin loader — canonicalization missing
## MEDIUM (next sprint)
5. [file:line] API key logged in error messages
6. [file:line] Rate limiter bypass via race condition
## LOW (backlog)
7. [file:line] Missing CORS headers
8. [file:line] Weak TLS configuration warning
```
## Phase 4: Fix (sequential, one at a time, on the current branch)
```
Loop:
1. Pick the highest-severity unfixed finding
2. Write the failing regression test for that finding
3. Implement ONLY that fix (no refactoring, no "while I'm here" changes)
4. Run the project's check command
5. Run the project's full test command
6. Commit: "Fix [severity] in [file]: [short description]" + the regression test
7. Push the branch — only after the full suite passes
8. Verify CI passes on the branch
9. Go to step 1
```
**Why sequential, on the current branch?** No fix branch and no merge to unwind. Parallel fixes on overlapping files conflict, and the conflict resolution silently reverts an earlier fix. A linear history keeps every fix one commit — independently verifiable, bisectable, and reverted with a single `git revert`.
## Phase 5: Regression prevention (after all fixes)
```
[ ] 1. Run the project's full test command
[ ] 2. Run the project's lint command (zero warnings)
[ ] 3. Run the project's dependency-audit command
[ ] 4. Verify CI passes on the branch
[ ] 5. Document the new bug count — it should be lower
[ ] 6. Update pre-commit hooks if new patterns emerged
```
## Phase 6: Prevention integration
Anything learned goes into prevention:
1. **Pre-commit hook**: catch the *pattern*, not just the instance.
2. **CI gate**: add a check for that vulnerability type.
3. **Code review checklist**: add the finding category.
4. **Architecture patterns**: document safe defaults so the bug cannot recur by omission.
```bash
# Example: if SQL interpolation was found, add a guard to the pre-commit hook.
# Scans the tracked Rust, Python, JS and TS sources for a query/execute/exec call whose
# argument is interpolated. A heuristic: it catches the obvious shapes, not a proof of safety.
if git grep -nE '(query|execute|exec)[A-Za-z_]*[[:space:]]*\([^)]*(\+|format!|\.format\(|f"|`|\$\{|%[sd])' -- '*.rs' '*.py' '*.js' '*.ts'; then
echo "WARNING: interpolated query call - possible SQL injection"
exit 1
fi
```
## Anti-patterns to avoid
| Anti-pattern | Why it fails |
|---|---|
| **Parallel fixes in separate worktrees** | Conflicts on overlapping files silently revert an earlier fix |
| **A fix branch per finding** | Merging brings conflicts and history churn; a linear branch reverts with one `git revert` |
| **Batch commits** ("Fix 15 security issues") | Unreviewable, unrevertable, no per-fix regression test |
| **Audit + fix in the same agent** | Conflict of interest, partial fixes |
| **Skipping verification** | Introduces regressions nobody catches until the next audit |
| **No prevention** | The same bugs return next cycle |
## Key principles
| Principle | Why |
|---|---|
| Audit agents read-only | Prevents conflicting changes |
| Fix sequentially on the current branch | Linear history — each fix is bisectable and revertible |
| One fix per commit | Bisectable, reversible |
| Verify after each fix | Catch regressions immediately |
| Document prevention | The next audit starts from a cleaner baseline |
## Metrics to track
- Bug count per severity over time — should decrease
- Time to fix per severity — should decrease as patterns emerge
- Regression rate — fixes that introduce new bugs
- Reappearance rate — the same bugs coming back
## The goal
Each cycle finds fewer bugs than the last because prevention stops new instances, fixes address root causes rather than symptoms, and architecture patterns become secure by default.
**Timeline:** the cycle runs audit → fix CRITICAL → fix HIGH → verify, prevent, and test. It is not paced by calendar weeks; it ends when every ranked finding is fixed, verified, and prevented.