agent-guardrails-update
Re-analyze Claude Code session logs against existing agent guardrail rules to measure effectiveness, catch false positives, identify missed anti-patterns, and…
от florianbuetow★ 22 звезды на GitHub
Установить agent-guardrails-update в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Agent Guardrails Update
Re-analyze session logs against installed guardrail rules to measure effectiveness and refine patterns. This is the feedback loop: install rules with /agent-guardrails:install, use them for a while, then run /agent-guardrails:update to tune.
Workflow
Step 1: Load Installed Rules
Read the installed guardrail script:
cat .claude/hooks/stop-guardrails.sh 2>/dev/null
Parse each grep block to extract:
- Rule name (from the
# {name}comment) - Pattern (from the
grep -qiEargument) - Message (from the
blocked+=argument)
If no script exists, tell the user to run /agent-guardrails:install first and stop.
Step 2: Load Canonical Rule Definitions
Read the canonical rule definitions from the plugin's rules/ directory:
Source of truth: ${CLAUDE_PLUGIN_ROOT}/rules/no-*.md
Read each rule file's YAML frontmatter to extract name, pattern, and message fields. The nine baseline categories are: no-guessing, no-stalling, no-preference-asking, no-false-completion, no-skipping, no-dismissing, no-cosmetic, no-caveats, no-flagging.
Step 3: Analyze Recent Sessions
Find session logs from the period since rules were installed. Default to last 7 days; accept $ARGUMENTS for custom ranges (e.g., "update last 30 days").
find ~/.claude/projects/ -name "*.jsonl" -mtime -7 ! -path "*/subagents/*" 2>/dev/null | head -30
Build and run a Python analysis script at /tmp/agent-guardrails-update.py that:
- Reads each JSONL session file
- Extracts assistant message text from
type: "assistant"entries - For each installed rule, tests every assistant message against the rule's regex pattern
- Records:
- Matches per rule — how many times each rule's pattern was found in raw assistant text
- Match excerpts — 200-char context around each match (up to 10 per rule)
- Phrase frequency — which specific phrases trigger each rule most often
- Also runs a full anti-pattern scan using the canonical rule definitions to find uncovered patterns — anti-patterns present in logs that no installed rule catches
- Outputs structured JSON to stdout
Script requirements:
- Python stdlib only (json, re, os, glob, sys, collections)
- Handle malformed JSONL gracefully
- Skip subagent sessions
- Accept
--days Nargument
Step 4: Assess Rule Effectiveness
For each installed rule, classify it into one of four states:
State: Working Well
- Pattern matches anti-pattern instances correctly
- No evidence of false positives (matches on legitimate content)
- Action: Keep as-is. Report match count.
State: Too Aggressive (False Positives)
Detected when the pattern matches legitimate assistant text. Common indicators:
- Rule matches inside code blocks or tool output (not assistant prose)
- Rule matches in contexts where the phrase is appropriate (e.g., "I think" in "I think we should" when giving a recommendation the user asked for)
- Very high match count relative to other rules (over-triggering)
Action: Suggest tightening the regex. Provide the specific false-positive excerpts and a refined pattern.
State: Too Lenient (False Negatives)
Detected when the full anti-pattern scan finds instances that the installed rule misses. Common indicators:
- Novel phrases that express the same anti-pattern but don't match the regex
- Variations or synonyms the pattern doesn't cover
- Multi-sentence hedging that no single-phrase regex catches
Action: Suggest expanding the regex with the missed phrases. Provide the specific missed excerpts and an updated pattern.
State: Inactive / No Data
- Rule is enabled but had zero matches in the analysis period
- Either the rule is working perfectly (preventing the behavior) or the pattern never triggers
Action: Note as "no matches" — cannot determine effectiveness without matches. Suggest the user check if the behavior was actually prevented or if the pattern needs testing.
Step 5: Check for Uncovered Patterns
Compare the full anti-pattern scan results against installed rules. For each anti-pattern category:
- If a rule exists for it -> covered (assess effectiveness above)
- If no rule exists -> uncovered gap
Report uncovered gaps with:
- Category name
- Match count from scan
- Top phrases found
- Recommended rule (use curated rule from
/agent-guardrails:installif available)
Step 6: Present Update Report
Format results inline:
## Agent Guardrails Update Report
**Rules analyzed:** {count}
**Sessions scanned:** {count}
**Time range:** {date range}
### Rule Effectiveness
| Rule | Status | Matches | Assessment |
|------|--------|---------|------------|
| no-guessing | enabled | 23 | Working well |
| no-stalling | enabled | 5 | Too aggressive (2 false positives) |
| no-preference-asking | enabled | 0 | No data |
| no-false-completion | enabled | 8 | Working well |
| no-skipping | enabled | 12 | Too lenient (missed 4 instances)
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл agent-guardrails-update?
Re-analyze Claude Code session logs against existing agent guardrail rules to measure effectiveness, catch false positives, identify missed anti-patterns, and refine regex patterns. Use when user asks to "update guardrails", "refine guardrail rules", "check guardrail effectiveness", "agent-guardrails update", "tune guardrails", or wants to improve existing behavioral rules based on real usage data.
Как установить скилл agent-guardrails-update?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл agent-guardrails-update запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…