|
| 1 | +--- |
| 2 | +description: Set custom rules for Safety Net |
| 3 | +--- |
| 4 | + |
| 5 | +You are helping the user configure custom blocking rules for claude-code-safety-net. |
| 6 | + |
| 7 | +## Context |
| 8 | + |
| 9 | +### Schema Documentation |
| 10 | + |
| 11 | +!`npx -y cc-safety-net --custom-rules-doc` |
| 12 | + |
| 13 | +## Your Task |
| 14 | + |
| 15 | +Follow this flow exactly: |
| 16 | + |
| 17 | +### Step 1: Ask for Scope |
| 18 | + |
| 19 | +Ask: **Which scope would you like to configure?** |
| 20 | +- **User** (`~/.cc-safety-net/config.json`) - applies to all your projects |
| 21 | +- **Project** (`.safety-net.json`) - applies only to this project |
| 22 | + |
| 23 | +### Step 2: Show Examples and Ask for Rules |
| 24 | + |
| 25 | +Show examples in natural language: |
| 26 | +- "Block `git add -A` and `git add .` to prevent blanket staging" |
| 27 | +- "Block `npm install -g` to prevent global package installs" |
| 28 | +- "Block `docker system prune` to prevent accidental cleanup" |
| 29 | + |
| 30 | +Ask the user to describe rules in natural language. They can list multiple. |
| 31 | + |
| 32 | +### Step 3: Generate JSON Config |
| 33 | + |
| 34 | +Parse user input and generate valid schema JSON using the schema documentation above. |
| 35 | + |
| 36 | +### Step 4: Show Config and Confirm |
| 37 | + |
| 38 | +Display the generated JSON and ask: |
| 39 | +- "Does this look correct?" |
| 40 | +- "Would you like to modify anything?" |
| 41 | + |
| 42 | +### Step 5: Check and Handle Existing Config |
| 43 | + |
| 44 | +1. Check existing User Config with `cat ~/.cc-safety-net/config.json 2>/dev/null || echo "No user config found"` |
| 45 | +2. Check existing Project Config with `cat .safety-net.json 2>/dev/null || echo "No project config found"` |
| 46 | + |
| 47 | +If the chosen scope already has a config: |
| 48 | +Show the existing config to the user. |
| 49 | +Ask: **Merge** (add new rules, duplicates use new version) or **Replace**? |
| 50 | + |
| 51 | +### Step 6: Write and Validate |
| 52 | + |
| 53 | +Write the config to the chosen scope, then validate with `npx -y cc-safety-net --verify-config`. |
| 54 | + |
| 55 | +If validation errors: |
| 56 | +- Show specific errors |
| 57 | +- Offer to fix with your best suggestion |
| 58 | +- Confirm before proceeding |
| 59 | + |
| 60 | +### Step 7: Confirm Success |
| 61 | + |
| 62 | +Tell the user: |
| 63 | +1. Config saved to [path] |
| 64 | +2. **Changes take effect immediately** - no restart needed |
| 65 | +3. Summary of rules added |
| 66 | + |
| 67 | +## Important Notes |
| 68 | + |
| 69 | +- Custom rules can only ADD restrictions, not bypass built-in protections |
| 70 | +- Rule names must be unique (case-insensitive) |
| 71 | +- Invalid config → entire config ignored, only built-in rules apply |
0 commit comments