writing-yara-rules

writing-yara-rules is a skill for Claude Code from trilwu/secskills. It costs 114 tokens per session (4,537 once invoked), scanned A, original, MIT.

A guide to writing YARA rules, which are search patterns for identifying malware and other file or memory artifacts. It covers strings, conditions, file structures, scanning modules, performance, and YARA-X.

In plain words
What is it for?
Creating, testing, reviewing, and tuning detections for files, memory, processes, malware samples, and related samples across a collection.
Why use it?
It helps create signatures that identify a malware family or capability without depending on easily changed details such as filenames. It also helps limit false matches and slow scans.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is yara -w -r rule.yar ./samples/family/ # -r recurse: must hit every known-true sample.

Part of the secskills-defense plugin — 22 skills shipped together

Good fit Creating, testing, reviewing, and tuning detections for files, memory, processes, malware samples, and related samples across a collection.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/trilwu/secskills
agentmods
npx agentmods add skills/trilwu/secskills/writing-yara-rules

Made for: Claude Code.

Or install secskills-defense, the plugin that ships this one along with the rest of its 22 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for writing-yara-rules

README.md
[![agentmods](https://agentmods.dev/badge/skills/trilwu/secskills/writing-yara-rules/github.svg)](https://agentmods.dev/skills/trilwu/secskills/writing-yara-rules)
Your own site
<a href="https://agentmods.dev/skills/trilwu/secskills/writing-yara-rules"><img src="https://agentmods.dev/badge/skills/trilwu/secskills/writing-yara-rules/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for writing-yara-rules

Your own site · 80×15
<a href="https://agentmods.dev/skills/trilwu/secskills/writing-yara-rules"><img src="https://agentmods.dev/badge/skills/trilwu/secskills/writing-yara-rules.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 114 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,537 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00114 $0.04537
Opus 5.5 $0.00046 $0.01815
Sonnet 5.5 $0.00023 $0.00907
Haiku 4.5 $0.00011 $0.00454

Measured 3mo ago against content hash f96db69f0795, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

writing-yara-rules scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl -sL "https://defuddle.md/<url>" # scheme in the path is optional
Origin

Copies of this mod

1 near-identical copy found in the catalogue:

secskills-defense/skills/writing-yara-rules/SKILL.md · 403 lines

How it starts

The opening of the file, as written. The whole thing — 403 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Writing YARA Rules

A good YARA rule matches the malware's nature — its code, its structure, its unavoidable constants — not its costume, which is a filename or a mutable string that changes on the next build. Match the nature and the rule survives recompilation and catches the whole family; match the costume and you catch one sample once. The entire craft is choosing strings and a condition that are both specific enough to avoid false positives and durable enough to generalize.

When to Use

  • Writing a YARA rule to detect a malware family, tool, or capability
  • Creating a signature for a file or in-memory artifact from a known sample
  • Turning IOCs or a captured specimen into a portable, testable detection
  • Hunting for a family across a corpus (VirusTotal Retrohunt, LOKI/THOR, on-host scan)
  • Clustering related samples by shared code, constants, or structure
  • Reviewing or tuning an existing rule for false positives and scan performance

When NOT to Use

  • The detection belongs in log or SIEM telemetry, not on files or memory — use writing-sigma-rules
  • Choosing what to detect and where it should live, the strategy above rule syntax — use engineering-detections
  • You do not yet understand the sample well enough to pick durable anchors — use analyzing-malware first
  • Running the hunt rather than authoring the signature — use hunting-threats
  • Packaging IOCs, attribution, and a finished report — use producing-threat-intelligence

Rule Anatomy

Three sections: meta (documentation, never matched on), strings (the patterns), condition (the boolean that decides a hit).

import "pe"

rule Family_Loader_v1
{
    meta:
        author      = "analyst"
        date        = "2026-07-26"
        description = "ExampleLoader stage-1, config-decode stub + family constants"
        hash        = "a1b2c3...<sha256 of the analyzed sample>"
        reference   = "https://internal/case/1234"
        version     = "1"
        tlp         = "amber"
    strings:
        $decode = { 8A 04 0? 32 0? 88 0? 4? 3B ?? 72 }
        $marker = "cfg::begin" ascii
        $mutex  = "Global\\ExL-%08x" ascii
    condition:
        uint16(0) == 0x5A4D and filesize < 2MB and 2 of them
}

Read the full file on GitHub · 403 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 403 lines · 114 tokens per session scan A f96db69f0795

Subscribe to this mod's changes

writing-yara-rules is a skill published in the GitHub repository trilwu/secskills (211 stars, last pushed 2mo ago), licensed MIT. It adds 114 tokens to every session and 4,537 once invoked, about $0.0005 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

writing-yara-rules compared with skills from other repositories

writing-yara-rules next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
writing-yara-rulestrilwu/secskillsSkill2112mo agoMITA114Claude Code
context-engineeringaddyosmani/agent-skillsSkill121k6d agoMITA43Claude Code
cloud-operator-share-contextgoogle/skillsSkill25ktodayApache-2.0A140Claude Code, Codex
comet-memoryrpamis/cometSkill3.3kyesterdayMITA38Claude Code, Codex
Agent Memory ArchitectureLeoYeAI/openclaw-master-skillsSkill2.2k8d agoMITA52Claude Code, Codex
digital-brainforyourhealth111-pixel/Vibe-SkillsSkill3.9k21d agoApache-2.0A57Claude Code, Codex
relevance-coarse-filterelvisun/newsjackSkill1.7k4d agoMITA57Claude Code