d-and-r-rules
FreeNo executable scriptsNot checkedWorking with Detection & Response rules in LimaCharlie — AI-assisted generation, validation, unit testing, historical replay, deployment, FP rules, stateful…
by refractionPOINT★ 32 GitHub starsAbout this skill
D&R Rules
How to work with Detection & Response rules in LimaCharlie. This covers rule generation, validation, testing, deployment, stateful rules, behavioral detection patterns, suppression, alternate targets, and response actions.
Critical Rule: NEVER Write D&R Rules Manually
D&R rule syntax is validated against organization-specific schemas. Manual YAML will fail validation. Always use AI generation commands.
Rule Generation
Generate Detection Component
limacharlie ai generate-detection --description "Detect NEW_PROCESS events where the command line contains '-enc' and the process is powershell.exe" --oid <oid> --output yaml
Generate Response Component
limacharlie ai generate-response --description "Report the detection with priority 8, add tag 'encoded-powershell' with 7 day TTL" --oid <oid> --output yaml
Common Response Actions
| Action | Description |
|---|---|
report |
Create a detection (alert) |
tag |
Add/remove sensor tags |
task |
Send command to sensor |
isolate network |
Persistent network isolation (survives reboot) |
rejoin network |
Remove network isolation |
seal / unseal |
Tamper-resistance for the EDR |
add var / del var |
Set/remove sensor variables |
extension request |
Call an extension asynchronously |
start ai agent |
Spawn AI session |
output |
Forward event to a specific output |
wait |
Delay before next action (max 1 minute) |
Validation
Always validate before deploying. Write YAML to temp files, then validate:
cat > /tmp/detect.yaml << 'EOF'
<detection_yaml>
EOF
cat > /tmp/respond.yaml << 'EOF'
<response_yaml>
EOF
limacharlie dr validate --detect /tmp/detect.yaml --respond /tmp/respond.yaml --oid <oid>
Unit Testing
Test rules against crafted sample events:
# Write combined rule file
cat > /tmp/rule.yaml << 'EOF'
detect:
<detection>
respond:
<response>
EOF
# Write test events
cat > /tmp/events.json << 'EOF'
[
{
"routing": {"event_type": "NEW_PROCESS"},
"event": {
"COMMAND_LINE": "powershell.exe -enc SGVsbG8=",
"FILE_PATH": "C:\\Windows\\System32\\powershell.exe"
}
}
]
EOF
limacharlie dr test --input-file /tmp/rule.yaml --events /tmp/events.json --trace --oid <oid> --output yaml
Create both positive tests (MUST match) and negative tests (MUST NOT match).
Historical Replay
Test rules against real historical data. Save the rule first under a temporary name, disabled so it never runs live:
# Save as a disabled temporary rule
limacharlie dr set --key temp-test-rule --input-file /tmp/rule.yaml --disabled --oid <oid>
# Calculate time range
start=$(date -d '1 hour ago' +%s) && end=$(date +%s)
# Estimate volume first (dry run)
limacharlie dr replay --name temp-test-rule --start $start --end $end --selector '"prod" in tags' --dry-run --oid <oid> --output yaml
# Run replay, scoped to the sensors the rule targets (always pass --selector or --sid)
limacharlie dr replay --name temp-test-rule --start $start --end $end --selector '"prod" in tags' --oid <oid> --output yaml
# Clean up temporary rule
limacharlie dr delete --key temp-test-rule --confirm --oid <oid>
Use the same scope as the rule: an org-wide replay tests a different rule, and a large one
can stop at the server's deadline. Before reading results, check the replay was complete:
stats.results_partial: true, a stats.stop_reason other than empty or none, a non-empty
stats.skipped_events or an error mean the results cover only part of the window. A
partial replay with 0 matches is inconclusive; narrow the scope or the window and re-run.
Deployment
Create/Update a Rule
cat > /tmp/rule.yaml << 'EOF'
detect:
<validated_detection>
respond:
<validated_response>
EOF
limacharlie dr set --key <rule-name> --input-file /tmp/rule.yaml --oid <oid>
Enable a new rule in stages rather than on its whole scope at once: first on one canary
sensor (an is tagged condition on a canary tag) with only the report action, then the
full target scope still with report only, then the other response actions. Check the
volume with limacharlie detection list --cat <detection-name> --start <ts> --end <ts> --oid <oid>
after each stage. The detection-engineering skill (Phase 5) has the full procedure.
List Rules
limacharlie dr list --oid <oid> --output yaml
Get a Rule
limacharlie dr get --key <rule-name> --oid <oid> --output yaml
Delete a Rule
limacharlie dr delete --key <rule-name> --confirm --oid <oid>
Rule Hive Namespaces
D&R rules are stored across three hives:
| Hive | Description | How Added |
|---|---|---|
dr-general |
Custom rules you create | limacharlie dr set |
dr-managed |
Managed rules from subscribed rulesets | Automatic from subscriptions |
dr-services |
Service-provided rules | From extensions/service |
Install d-and-r-rules in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
BashReadFAQ
What does the d-and-r-rules skill do?
Working with Detection & Response rules in LimaCharlie — AI-assisted generation, validation, unit testing, historical replay, deployment, FP rules, stateful rules, behavioral detection patterns, suppression, alternate detection targets, and response actions. Use when creating, testing, modifying, or managing D&R rules, false positive rules, or understanding detection patterns.
How do I install the d-and-r-rules skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the d-and-r-rules skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
by Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
by Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
by Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
by Anthropic