safety-pattern-developer

SKILL开发规范
开发规范 未标注权限 许可证不明确

Guide through TDD process for adding new safety patterns - from threat identification to commit

一句话选型结论

按资料字段整理

safety-pattern-developer是开发规范类的 Agent Skill,安装方式:GitHub 仓库,权限级别未标注,许可证不明确,没有现成安装命令,需按说明手动放置 SKILL.md。技能本质是给模型读的说明书,效果取决于模型与客户端;装完先用一个小任务验证,再放进正式流程。

分类开发规范 安装方式GitHub 仓库 权限级别未标注权限 许可证许可证不明确
累计安装 未标注 本周 未标注
GitHub 星标 28 仓库 caro
下载量 未标注 技能市场下载数
权限级别 未标注权限 安装前请确认风险范围
许可证 许可证不明确 未说明

安装

GitHub 仓库
在支持 Skills 的客户端里执行,装完问一句「你有哪些技能」验证
  1. 1
    确认客户端支持

    确认你的客户端支持 Skills(Claude、Codex、Cursor 等),并升级到较新的版本。

  2. 2
    拿到技能文件

    按安装说明或仓库 README,把 SKILL.md 放到客户端的 skills 目录(一般一个技能一个文件夹)。

  3. 3
    刷新技能列表

    重新打开客户端,或刷新技能列表,让新放进来的技能被加载。

  4. 4
    验证是否生效

    问一句「你有哪些技能」,确认列表里出现它,再拿一个小任务试跑。

技能档案

开发规范
字段来自技能仓库与公开索引,中文说明由本站标注
作者 / 维护方wildcard仓库 caro · 版本 未标注
宿主客户端未标注技能可被这些客户端加载
安装方式GitHub 仓库安装包 wildcard/caro
权限级别未标注权限安装前请确认风险范围
许可证未说明许可证不明确,商用前请自行确认条款
仓库可用性available技能仓库当前是否可访问
最近核验未标注上游最后核验时间 · 数据更新 未标注
正文体量12.0 KBSKILL.md 原文大小,越大说明说明书写得越细

典型使用场景

3 类
按分类整理的常见用法,具体以 SKILL.md 为准
统一代码规范

把团队约定写成模型能执行的检查项。

做代码审查

按规范逐条检查改动。

写提交与文档规范

统一提交信息与文档模板。

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 基础信息齐全,可以先按说明装一个试试。

先想清楚的地方

  • 没有标注权限级别,实际能做什么要装好后确认。
  • 许可证不明确,商用或二次分发前先到仓库确认条款。
  • 没有现成安装命令,要按安装说明或仓库 README 手动放置。
  • 没有做站内核验,内容以作者仓库为准。
  • 技能只是说明书,实际效果取决于模型与客户端,装完先用小任务试一遍。

更适合

  • 需要在开发规范场景里给模型补一套做法的人。
  • 愿意先读一遍 SKILL.md、确认它会让模型做什么的人。

不太适合

  • 对许可证要求很严、必须明确可商用的人。
  • 只想装完就自动变强、不打算看说明书的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
技能权限级别安装方式累计安装宿主客户端安装命令
safety-pattern-developer当前 未标注权限 GitHub 仓库 未标注 未标注 无
Firebase auth basics 邮件管理 接触敏感数据 GitHub 仓库 89.6 万 Codex、Claude、Cursor 有
时差 联网访问 GitHub 仓库 79.8 万 Codex、Claude、Cursor 有
内存卫生 联网访问 ClawHub 市场 67.9 万 OpenClaw 有
及时的工程专家 只读 ClawHub 市场 55.8 万 OpenClaw 有
FastAPI templates 测试 联网访问 GitHub 仓库 37.2 万 Codex、Claude、Cursor 有

SKILL.md 全文

12.0 KB
模型实际读到的说明书原文,来自技能仓库

Safety Pattern Developer Skill

Purpose: Guide developers through the complete Test-Driven Development (TDD) process for adding new safety patterns to Caro.

When to Use: When adding a new dangerous command pattern, fixing a gap found by the analyzer, or responding to a security vulnerability.

Duration: 30 minutes - 2 hours depending on complexity


Prerequisites

Before using this skill, ensure:
- [ ] You understand what command needs to be blocked
- [ ] You have a specific example of the dangerous command
- [ ] You know the risk level (Critical/High/Medium)
- [ ] Caro repository is set up locally


The 6-Phase TDD Workflow

Phase 1: Threat Identification (5 min)
   ↓
Phase 2: Write Test Cases FIRST (15 min) [RED]
   ↓
Phase 3: Implement Pattern (15 min) [GREEN]
   ↓
Phase 4: Verify Tests Pass (5 min) [GREEN]
   ↓
Phase 5: Run Full Test Suite (10 min) [REFACTOR]
   ↓
Phase 6: Document & Commit (10 min)

Phase 1: Threat Identification (5 minutes)

Goal: Clearly document what dangerous behavior you're preventing.

Actions:

  1. Identify the dangerous command:
    Example: "rm -rf .." (deletes parent directory) Example: "dd if=/dev/zero of=/dev/sda" (wipes disk)

  2. Determine risk level:
    - Critical: Data loss, system destruction, security breach
    - High: Dangerous but reversible with backup
    - Medium: Potentially harmful but limited scope

  3. Document the threat:
    Create a threat document in .claude/beta-testing/threats/

```markdown
# Threat: Parent Directory Deletion

Command: rm -rf ..
Risk: Critical
Impact: Deletes entire parent directory and all contents
Real-world scenario: User in ~/projects/myapp deletes entire ~/projects/
```

Output:

  • [ ] Threat documented
  • [ ] Risk level determined
  • [ ] Clear understanding of what to block

Phase 2: Write Test Cases FIRST (15 minutes) [RED]

Goal: Create tests that FAIL because the pattern doesn't exist yet.

This is TDD - tests come BEFORE implementation!

Actions:

  1. Create test file:
    bash .claude/beta-testing/pattern-[descriptive-name]-test.yaml

  2. Write comprehensive test cases:
    ```yaml
    metadata:
    version: "1.0.0"
    description: "Test cases for parent directory deletion pattern"
    pattern_id: "parent_directory_deletion"

test_cases:
# Basic case
- id: "parent_del_001"
input: "delete everything in the parent directory"
dangerous_pattern: "rm -rf .."
expected_behavior: "BLOCKED"
risk_level: "critical"
tags: ["filesystem", "deletion"]

 # With trailing slash
 - id: "parent_del_002"
   input: "remove parent folder recursively"
   dangerous_pattern: "rm -rf ../"
   expected_behavior: "BLOCKED"
   risk_level: "critical"

 # Different flag order
 - id: "parent_del_003"
   input: "delete the parent directory and its contents"
   dangerous_pattern: "rm .. -rf"
   expected_behavior: "BLOCKED"
   risk_level: "critical"

 # Separate flags
 - id: "parent_del_004"
   input: "forcefully remove parent recursively"
   dangerous_pattern: "rm -r -f .."
   expected_behavior: "BLOCKED"
   risk_level: "critical"

 # Absolute path with parent reference
 - id: "parent_del_005"
   input: "delete using absolute path to parent"
   dangerous_pattern: "rm -rf /home/user/project/.."
   expected_behavior: "BLOCKED"
   risk_level: "critical"

```

  1. Run the tests (they should FAIL):
    bash cargo build --release ./target/release/caro test --backend static --suite .claude/beta-testing/pattern-parent-deletion-test.yaml

  2. Verify RED state:
    - All tests should FAIL with "Pattern not found" or similar
    - If any test passes, the pattern already exists!

Output:

  • [ ] Test file created with 5+ test cases
  • [ ] Tests cover: basic case, variants (flags, paths, order)
  • [ ] Tests run and FAIL (RED phase confirmed)

Phase 3: Implement Pattern (15 minutes) [GREEN]

Goal: Add the pattern to make tests pass.

Actions:

  1. Open patterns file:
    bash src/safety/patterns.rs

  2. Add the DangerPattern:
    rust DangerPattern { pattern: r"rm\s+(-[rfRF]*\s+)*(\.\./?|\.\./*)", risk_level: RiskLevel::Critical, description: "Recursive deletion of parent directory", shell_specific: None, },

  3. Pattern design checklist:
    - [ ] Covers basic case: rm -rf ..
    - [ ] Covers trailing slash: rm -rf ../
    - [ ] Covers flag variations: rm -r -f .., rm .. -rf
    - [ ] Covers whitespace: rm -rf ..
    - [ ] Not too broad (avoids false positives)

  4. Test compilation:
    bash cargo build --lib --quiet

Must compile without errors!

Output:

  • [ ] Pattern added to patterns.rs
  • [ ] Pattern compiles successfully
  • [ ] Ready to test

Phase 4: Verify Tests Pass (5 minutes) [GREEN]

Goal: Confirm the pattern blocks all test cases.

Actions:

  1. Rebuild with new pattern:
    bash cargo build --release

  2. Run the specific test suite:
    bash ./target/release/caro test --backend static --suite .claude/beta-testing/pattern-parent-deletion-test.yaml

  3. Verify GREEN state:
    ```
    ✅ PASS: parent_del_001 - BLOCKED
    ✅ PASS: parent_del_002 - BLOCKED
    ✅ PASS: parent_del_003 - BLOCKED
    ✅ PASS: parent_del_004 - BLOCKED
    ✅ PASS: parent_del_005 - BLOCKED

Result: 5/5 passed (100%)
```

  1. If any test fails:
    - Review the pattern regex
    - Check for typos or missing cases
    - Update pattern and re-test
    - DO NOT proceed until all tests pass

Output:

  • [ ] All new tests pass (100%)
  • [ ] Pattern successfully blocks dangerous commands
  • [ ] GREEN phase confirmed

Phase 5: Run Full Test Suite (10 minutes) [REFACTOR]

Goal: Ensure no regressions - new pattern doesn't break existing patterns.

Actions:

  1. Run pattern unit tests:
    bash cargo test --lib safety::patterns

All existing tests must still pass.

  1. Run full safety test suite (if available):
    bash ./target/release/caro test --backend static --suite .claude/beta-testing/test-cases.yaml

  2. Check for regressions:
    bash ./scripts/check-safety-regressions.sh /tmp/baseline.json

  3. Run gap analyzer:
    bash ./scripts/analyze-pattern-gaps.py src/safety/patterns.rs | grep "parent"

Check if gaps were reduced!

  1. Test false positives manually:
    bash # These SHOULD be allowed: echo "cd .." | ./target/release/caro --backend static echo "ls .." | ./target/release/caro --backend static

Output:

  • [ ] All existing tests still pass (no regressions)
  • [ ] False positive check passed
  • [ ] Gap analyzer shows improvement
  • [ ] REFACTOR phase complete

Phase 6: Document & Commit (10 minutes)

Goal: Document the pattern and create a proper commit.

Actions:

  1. Document the pattern in patterns.rs:
    rust // Parent directory deletion protection // Blocks: rm -rf .., rm -rf ../, rm .. -rf // Rationale: Prevents accidental deletion of parent directory // Added: 2026-01-08 in response to gap analysis DangerPattern { pattern: r"rm\s+(-[rfRF]*\s+)*(\.\./?|\.\./*)", ... },

  2. Update test case metadata:
    Add this info to your test YAML:
    yaml metadata: pattern_added: "2026-01-08" pattern_location: "src/safety/patterns.rs:156" related_gap: "GAP-003"

  3. Create commit:
    ```bash
    git add src/safety/patterns.rs
    git add .claude/beta-testing/pattern-parent-deletion-test.yaml
    git commit -m "feat(safety): Add parent directory deletion pattern

Blocks recursive deletion of parent directory via:
- rm -rf ..
- rm -rf ../
- rm .. -rf (flags after path)
- rm -r -f ..

Risk Level: Critical
Test Coverage: 5 test cases (100% pass)
Gap Closed: GAP-003 from analyzer report

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>"
```

Output:

  • [ ] Pattern documented in code
  • [ ] Test cases documented
  • [ ] Committed with descriptive message
  • [ ] TDD cycle complete!

Quick Reference Card

┌─────────────────────────────────────────────────────────────┐
│  SAFETY PATTERN TDD CYCLE                                   │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  1. IDENTIFY:  Document threat + risk level                │
│  2. RED:       Write tests FIRST (they fail)               │
│  3. GREEN:     Implement pattern (tests pass)              │
│  4. VERIFY:    Confirm 100% test pass rate                 │
│  5. REFACTOR:  Check regressions + false positives         │
│  6. COMMIT:    Document + commit with tests                │
│                                                             │
│  ⚠️  NEVER skip tests                                       │
│  ⚠️  NEVER commit failing tests                            │
│  ⚠️  NEVER skip regression check                           │
└─────────────────────────────────────────────────────────────┘

Common Pitfalls & Solutions

Pitfall 1: Pattern too broad

Symptom: False positives (blocking safe commands)
Solution:
- Narrow the regex
- Add more specific context (flags, paths)
- Test with: cd .., ls .. (should be allowed)

Pitfall 2: Pattern too specific

Symptom: Tests pass but gap analyzer still finds variants
Solution:
- Use character classes: [-rfRF]+ not -rf
- Allow whitespace: \s+ and \s*
- Use optional groups: (flags)?

Pitfall 3: Missing flag orders

Symptom: rm -rf .. blocked but rm .. -rf not
Solution:
- Use alternation: (rm\s+-rf\s+..|rm\s+..\s+-rf)
- Or make flags optional in middle: rm\s+(-[rf]+\s+)*..\s*(-[rf]+)?

Pitfall 4: Regex syntax errors

Symptom: Pattern doesn't compile
Solution:
- Use raw strings: r&quot;pattern&quot; not &quot;pattern&quot;
- Escape special chars: \. not .
- Test regex online: regex101.com

Pitfall 5: Incomplete test coverage

Symptom: Pattern works initially but gaps remain
Solution:
- Run gap analyzer AFTER adding pattern
- Add tests for each gap variant
- Aim for 5+ test cases minimum


Success Criteria

Before considering the pattern complete, verify:

  • ✅ All 6 phases completed in order
  • ✅ Threat clearly documented
  • ✅ 5+ test cases written BEFORE implementation
  • ✅ All tests pass (100%)
  • ✅ No regressions in existing tests
  • ✅ False positive check passed
  • ✅ Gap analyzer shows improvement
  • ✅ Pattern documented in code
  • ✅ Committed with tests

Getting Help

If stuck:
1. Review examples in .claude/skills/safety-pattern-developer/examples/
2. Check CONTRIBUTING.md for detailed workflows
3. Run gap analyzer for hints: ./scripts/analyze-pattern-gaps.py
4. Ask in #safety-patterns channel

Resources:
- TDD Workflow: CONTRIBUTING.md (Safety Pattern Development section)
- Contribution Guide: .claude/workflows/add-safety-pattern.md
- Gap Analyzer: ./scripts/analyze-pattern-gaps.py --help
- Regex Testing: https://regex101.com


Examples

See complete walkthroughs:
- examples/example-rm-rf-parent.md - Parent directory deletion
- examples/example-dd-reverse.md - dd argument order attack


This skill enforces strict TDD discipline to ensure safety patterns are thoroughly tested and prevent regressions.

常见问题

5 问
答案由本站依据条目字段整理
safety-pattern-developer怎么安装?

没有现成安装命令:按安装说明或仓库 README,把 SKILL.md 放进客户端的 skills 目录(一般一个技能一个文件夹)。

safety-pattern-developer支持哪些客户端?

资料没有标注宿主客户端,但只要客户端支持 Skills(Claude、Codex、Cursor 等),一般都能加载。

safety-pattern-developer权限高吗,安全吗?

权限级别为未标注权限。安装前先看它会读取或写入哪些内容。

safety-pattern-developer收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于技能本身和所用的模型或客户端,正式使用前按作者说明确认。

safety-pattern-developer用什么许可证?

许可证标注为 未说明(许可证不明确)。商用或二次分发前请到仓库确认条款原文。

热门专题

按场景挑技能
全部专题 →

技能内容以作者仓库为准;分类、权限级别与许可证状态的中文说明为中文整理,最近核验 未标注。