agentleFS
YehudaFrankelYehudaFrankel/clankbrain/.claude/skills/_archived_generate-guards/SKILL.md

generate-guards

Skill16 starsChanged 7 months agoMITView on GitHub

Scan this project's error history and codebase to propose project-specific guards for guard-patterns.md. Generic guards ship with the kit — this skill creates the ones that prevent YOUR recurring mistakes. Trigger phrases: "generate guards", "add guards", "create project guards", "what guards should I add", "guards from my errors".

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

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

    If yes → strong candidate.

    line 35
  2. Very specific:

    If greppable → candidate; mark it as [from regret log]

    line 40
  3. Distinctive:

    Look for lessons mentioning a specific code pattern to avoid

    line 44
  4. Distinctive:

    If a pattern appears in 2+ lessons → strong candidate

    line 45
  5. Very specific:

    Check what languages are in the project (Glob for .java, .js, .py, etc.)

    line 48
  6. Distinctive:

    Use Grep to confirm the pattern actually exists in this codebase before proposing it

    line 50
  7. Very specific:

    Do NOT write to guard-patterns.md without confirmation.

    line 71
  8. Distinctive:

    Ask: "Add these [N] guards to guard-patterns.md?

    line 73

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

Skill: generate-guards

Trigger: "generate guards" · "add guards" · "create project guards" · "what guards should I add" · "guards from my errors"


Why this matters

The 4 generic guards that ship with Clankbrain (NULL_BEFORE_ACCESS, HARDCODED_URL, RAW_ERROR_EXPOSURE, CONSOLE_LOG_LEFT_IN) are starting points. The ones that actually prevent your mistakes are derived from your own error history. Every entry in error-lookup.md and regret.md is a candidate guard — a mistake the codebase could have caught automatically.

This skill converts your error history into automated prevention.


Steps

Step 1 — Read existing guards

  • Read .claude/rules/guard-patterns.md
  • List guard IDs already present — don't propose duplicates
  • Note which file types and patterns are already covered

Step 2 — Mine error history for guard candidates

From error-lookup.md (highest priority — already proved costly):

  • Read .claude/memory/error-lookup.md
  • For each known error: could a grep pattern have caught this before it ran?
  • If yes → strong candidate; mark it as [from error history]

From regret.md (rejected approaches that might slip back in):

  • Read .claude/memory/tasks/regret.md
  • For each rejected approach: is there a code pattern that signals this approach being used?
  • If greppable → candidate; mark it as [from regret log]

From lessons.md (recurring patterns):

  • Read tasks/lessons.md
  • Look for lessons mentioning a specific code pattern to avoid
  • If a pattern appears in 2+ lessons → strong candidate

From the stack (general best practices for detected tech):

  • Check what languages are in the project (Glob for .java, .js, .py, etc.)
  • Apply stack-specific candidates: SQL concatenation (Java/Python), async without await (JS), missing null checks (Java), etc.
  • Use Grep to confirm the pattern actually exists in this codebase before proposing it

Step 3 — Propose guards

For each candidate, format it as:

## GUARD_ID
- **Check**: [one sentence: what this guards against]
- **How to scan**: Grep for `[exact regex pattern]` in [file scope, e.g. "*.java", "*.js"]
- **Files**: [specific files or file types]
- **Why**: [what breaks if this pattern appears — reference the error or lesson that caused it]

Show all candidates. For each one:

  • Mark source: [from error history], [from regret log], [from lessons], or [best practice]
  • State what specific past mistake it would have caught, if known

Prioritize error-history and regret-log guards first — they have proven cost.

Step 4 — Confirm before writing

Do NOT write to guard-patterns.md without confirmation.

Ask: "Add these [N] guards to guard-patterns.md? Say yes to add all, or list which ones to keep."

Step 5 — Write confirmed guards

Append each confirmed guard to .claude/rules/guard-patterns.md with a blank line between guards.

Then report: "[N] guards added. Run Guard Check to scan the codebase for existing violations now."


Closing message

"Guards added to guard-patterns.md. These run automatically on Guard Check and Pre-Ship Check. Re-run this skill after every 5 sessions — your error history grows, and so should your guards."

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.