# SkillFoundry v5.12.0 — GuardLoop

**Released:** 2026-05-13

---

## What's in This Release

### GuardLoop × SkillFoundry Integration

v5.12.0 integrates [GuardLoop](https://github.com/samibs/guardloop.dev) — a self-improving AI governance engine — as live Claude Code hooks and a `/guardloop` skill. The framework now detects its own failure patterns session by session and promotes them into enforced rules automatically.

**The core idea:** Every LLM session produces errors. GuardLoop captures those errors, counts how often each pattern recurs, and — when a pattern crosses a threshold — writes it as an enforceable rule that all code-generating agents read. The framework gets harder to fool over time without any manual effort.

---

## New: `/guardloop` Skill

```
/guardloop              Pattern frequency report
/guardloop analyze      Same as above — full report with candidates
/guardloop promote      Promote ready patterns → agents/_guardloop-rules.md
/guardloop scan         Live scan of current codebase for all 10 patterns
/guardloop status       Hook health check + pattern summary
/guardloop reset        Reset counters (preserves promoted rules)
```

---

## New: Automatic Session Hooks

### `failure-scan.sh` — PostToolUse (Edit|Write)

Runs after every file write/edit. Scans for 3 CRITICAL patterns in under 5ms:

1. **Hardcoded secrets** — Credential assignments not using environment variables
2. **localStorage tokens** — `localStorage.setItem/getItem` calls with "token" — XSS risk
3. **File corruption** — Repeating character artifacts from AI generation

Non-blocking. Warns inline via stdout. Adds file to `guardloop-files.log` for the full harvest.

### `guardloop-harvest.sh` — Stop hook

Runs at session end (before `batch-check.sh`). Scans every code file edited during the session with the full 10-pattern set:

| Pattern | Severity | What it catches |
|---------|----------|----------------|
| `hardcoded-secret` | critical | Credentials in source |
| `localstorage-token` | critical | Tokens in localStorage |
| `file-corruption` | critical | Repeating char artifacts |
| `empty-catch` | high | Silent error swallowing |
| `placeholder-code` | high | TODO/STUB in production code |
| `nullable-array-method` | high | `.map()` on nullable fields |
| `ts-ignore-no-comment` | medium | Unjustified @ts-ignore |
| `console-log-unguarded` | medium | Unguarded debug logs |
| `hardcoded-path` | medium | Hardcoded filesystem paths |
| `select-star-query` | medium | `SELECT *` in API queries |

Each detection is appended to `memory_bank/knowledge/errors-universal.jsonl` as a structured JSONL entry (tagged `guardloop`, `auto-detect`). Pattern frequency counters update in `.claude/hooks/state/guardloop-patterns.json`.

---

## New: Adaptive Rules File

`agents/_guardloop-rules.md` — starts empty, self-populates when patterns are promoted.

**Promotion threshold:** 3+ occurrences + not previously promoted.

When `/guardloop promote` runs, it:
1. Reads `guardloop-patterns.json` for patterns at threshold
2. Writes each pattern as a row in the `agents/_guardloop-rules.md` enforcement table
3. Marks the pattern as promoted (won't re-promote until reset)

All code-generating agents that inherit from `_quality-primer.md` enforce promoted rules on subsequent sessions.

---

## Migration Notes

No breaking changes. All hooks are additive:

- `failure-scan.sh` is wired as a second hook on the existing `PostToolUse: Edit|Write` matcher (after `accumulate-edits.sh`)
- `guardloop-harvest.sh` is wired as the first hook on the `Stop` matcher (before `batch-check.sh`), so it reads `guardloop-files.log` before `batch-check.sh` cleans up its own state

No new dependencies. Scripts use `bash`, `grep`, `python3` (standard on all developer machines).

---

## Files Added

```
.claude/hooks/failure-scan.sh        ← PostToolUse hook (new)
.claude/hooks/guardloop-harvest.sh   ← Stop hook (new)
.claude/commands/guardloop.md        ← /guardloop skill (new)
scripts/guardloop-analyze.sh         ← Analysis backend (new)
scripts/guardloop-promote.sh         ← Promotion backend (new)
agents/_guardloop-rules.md           ← Adaptive rules file (new)
```

## Files Modified

```
.claude/settings.json                ← Two new hook registrations
```

---

*Source: [github.com/samibs/guardloop.dev](https://github.com/samibs/guardloop.dev)*
