AI Blocks › Keep your code secure
Code scan rule writer
Describe a bug pattern. Get a tested Semgrep rule that finds it across your code.
Code scan rule writer is a free AI skill for the job "Keep your code secure". Give the instructions to an AI assistant that supports the required files and tools, then review its output.
Free · No account · CC BY 4.0 licence · Made by sickn33 · Level: expert · Thinking: high
Made by sickn33. See the original on GitHub; we copied it as it is, with its licence.
What it does
Describe a bug pattern once and get a Semgrep rule that finds it everywhere in your code. The rule is tested, so it catches the bad cases and leaves safe code alone. It writes the rule, then a test file with cases that should match and cases that should not. It runs the Semgrep test command and fixes the rule until both sides pass. It uses taint mode when data must be followed from user input to a risky call, since plain pattern matching gets noisy there. It pushes back on shortcuts like "the pattern looks complete" or "one test is enough". You need Semgrep installed.
You give it
- A description of the bug or pattern
- An example of bad code
- An example of safe code (optional)
- The language
- A buyer brief (optional)
You get
- A Semgrep rule file
- A test file with match and no-match cases
- Test results
- Notes on false positives
Use it when
- You found a bug and want to find every copy of it.
- You want to enforce a coding rule across a big codebase.
- You need to catch user input reaching a dangerous call.
- Your current scan rules raise too many false alarms.
How to use it
- Add it to your AI once: download it and add the folder to Claude, ChatGPT or Codex as a skill.
- Ask for the job in your own words. Your AI opens the skill when it fits.
- It works best when your AI can run code and read your project files.