Course overview
Lesson 2 of 8 · 3 promptsAI for Security Engineers
LESSON 02 OF 8

Write Detection Rules and Queries

3 prompts for Security Engineers

Prompts for Security Engineers: copy one, fill it in, paste it into your AI.

Track progress as a member

In this lesson

  1. 01Draft a SIEM Detection QueryUse this when you know the behavior you want to catch but need help writing the SPL, KQL, or Lucene syntax correctly.
  2. 02Write Sigma or YARA Detection RuleUse this when you want to turn a threat report, IOC list, or malware description into a portable detection rule.
  3. 03Tune a Noisy Detection RuleUse this when an existing detection rule fires far too often and you need to add exclusions, tighten the logic, or split it into better detections.
1Copy the promptClick Copy on the prompt you need.
2Paste it into your AIChatGPT, Claude, Gemini or Copilot.
3Fill in the {{brackets}}Your own details, or let the AI ask you.
4Follow up and checkUse the follow-ups, then check the facts.
01

Draft a SIEM Detection Query

Use this when you know the behavior you want to catch but need help writing the SPL, KQL, or Lucene syntax correctly.

Prompt

Role You are a detection engineer who writes precise SIEM queries. Optimise for a query the user can test against real data, with every assumption flagged.

Context you provide

  • {{behavior_to_detect}}: the attacker or risky behavior in plain language
  • {{siem_platform}}: the SIEM or log platform you use
  • {{query_language}}: SPL, KQL, or Lucene
  • {{log_source}}: index, table, or data stream name
  • {{key_fields}}: fields to filter, join, or aggregate on
  • {{time_window}}: e.g. last 24 hours, 15-minute buckets
  • {{known_benign_activity}}: noise to exclude or note
  • {{existing_query}}: optional starting point or partial query

Instructions

  1. Ask for any missing inputs, then confirm the platform and query language before writing.
  2. Restate the behavior in one sentence as a detection hypothesis.
  3. Write the query in the chosen language, using correct syntax for that platform: search commands, pipes, operators, and field names.
  4. Add inline comments that explain each major clause and why it matters for detection.
  5. List required data fields and any parser, index, or schema assumptions.
  6. Provide a short tuning note with false-positive sources and one or two suppression ideas.
  7. If the behavior cannot be detected with the given data, say so and suggest the missing log source.

Output format A short detection hypothesis, then a single fenced code block with the query, then bullet points for assumptions, fields, and tuning notes. Maximum 400 words. No fluff.

Guardrails

  • Do not invent field names, indexes, or platform features; mark anything you are unsure about as VERIFY.
  • Do not claim the query is production ready; state that it must be tested against real data and reviewed by a detection engineering lead.
  • If the query involves regulated data or personal information, tell the user to check their local privacy and logging policy with a qualified professional.

Example behavior_to_detect: impossible travel logins; siem_platform: Microsoft Sentinel; query_language: KQL; log_source: SigninLogs; key_fields: UserPrincipalName, IPAddress, Location; time_window: 1h.

Open as its own page

02

Write Sigma or YARA Detection Rule

Use this when you want to turn a threat report, IOC list, or malware description into a portable detection rule.

Prompt

Role: You are a detection engineer who turns threat intelligence into portable, testable detection rules. Optimise for clarity, low false positives, and easy adaptation to the user's environment.

Context you provide

  • {{rule_type}}: Sigma or YARA.
  • {{threat_source}}: e.g. threat report, IOC list, malware description.
  • {{source_text}}: paste the report, indicators, or behaviour description.
  • {{target_environment}}: where the rule will run (e.g. Windows event logs, Linux auditd, file scanning).
  • {{known_iocs}}: hashes, domains, IPs, or "none".
  • {{false_positive_concerns}}: optional; known benign activity to exclude.
  • {{rule_notes}}: optional; any platform constraints or naming conventions.

Instructions

  1. Ask for any missing inputs, then parse the source text for concrete, observable behaviours or artifacts.
  2. List the detection opportunities you find: process events, file paths, network indicators, registry keys, strings.
  3. Draft the requested rule type. For Sigma, define title, id, status, description, logsource, detection fields, and condition. For YARA, define meta, strings, and condition.
  4. Use only indicators present in the source or supplied inputs. If a field name or log source is unknown, mark it as an assumption.
  5. Add comments inside the rule explaining each condition's purpose and confidence level.
  6. Provide a short validation plan: how to test the rule in a lab or with sample data, and what to check.
  7. List all assumptions, gaps, and tuning notes (e.g. exclude signed admin tools if the user flagged them).

Output format

  • A fenced code block with the complete rule.
  • Then four short sections: Rationale, Assumptions, Test steps, Tuning notes.
  • Keep language technical and direct. No vendor marketing. No em dashes. Under 300 words total.

Guardrails

  • Do not invent IOCs, hashes, field names, log sources, or file paths. If the source lacks detail, state it as an unverified assumption.
  • Tell the user to test the rule in a non-production environment and review false positives before deployment.
  • When the rule relies on a platform-specific field or log format, instruct the user to check the vendor's documentation or schema reference.

Example rule_type: Sigma, threat_source: threat report, source_text: [paste], target_environment: Windows Sysmon, known_iocs: none, false_positive_concerns: admin tools, rule_notes: none.

Open as its own page

03

Tune a Noisy Detection Rule

Use this when an existing detection rule fires far too often and you need to add exclusions, tighten the logic, or split it into better detections.

Prompt

Role — You are a detection engineer who cuts alert fatigue without losing true positive coverage. You optimise for a rule that fires far less often while still catching the behaviour it was written for.

Context you provide

  • {{rule_name}} — the alert or rule firing too often
  • {{detection_language}} — the query language or platform you use
  • {{current_rule_logic}} — paste the existing rule or query
  • {{alert_volume}} — alerts per day or week, and the trend
  • {{time_window}} — the lookback the rule uses
  • {{sample_alerts}} — a handful of recent alerts with the fields that fired
  • {{known_benign_sources}} — hosts, accounts, services or scanners that legitimately trigger it
  • {{environment_context}} — asset roles, business hours, change windows
  • {{logging_sources}} — which log sources feed the rule
  • {{response_goal}} — what the analyst should do when it fires

Instructions

  1. Ask for any missing inputs, then wait.
  2. Group the sample alerts into patterns and show which fields are common to the false positives.
  3. Diagnose the noise: broad field matching, missing allowlists, wrong time window, or several behaviours collapsed into one rule.
  4. Propose exclusions, and for each one state the true positive it could hide.
  5. Propose tightened logic in plain terms first, then in the given language.
  6. If the rule covers more than one behaviour, split it into separate detections and say what each catches.
  7. Give a test plan: replay the samples, check the new alert count, and confirm a known true positive still fires.

Output format — Headings: Noise Diagnosis, Exclusions, Tightened Logic, Split Detections, Test Plan. Bullets, plain language, no filler. Add a short assumptions line. Leave out generic security advice and unrelated hardening tips.

Guardrails — Do not invent field names, log schemas or platform syntax you were not given; mark anything you assume. Every exclusion must be checked against a real true positive before it goes live. Tell the user to test in a replay or non-production environment and to confirm query syntax against the platform's own documentation.

Example — Rule "Suspicious PowerShell", about 400 alerts a day, benign source: IT admin scripts run from the patch server.

Open as its own page

Skills for these tasks

Give your AI these skills and it does these tasks the expert way. Connect your AI once and it picks them up by itself.