|
| 1 | +--- |
| 2 | +description: List passthru rules with scope, source, list, and index annotations |
| 3 | +argument-hint: "[--scope user|project|all] [--list allow|deny|all] [--source authored|imported|all] [--tool <regex>] [--format table|json|raw] [--flat]" |
| 4 | +--- |
| 5 | + |
| 6 | +# /passthru:list |
| 7 | + |
| 8 | +Show every passthru rule across user and project scopes, grouped by |
| 9 | +`(scope, list, source)` with 1-based indexes that match the numbering |
| 10 | +`/passthru:remove` expects. |
| 11 | + |
| 12 | +Rules come from up to four files: |
| 13 | + |
| 14 | +* `~/.claude/passthru.json` - user-authored |
| 15 | +* `~/.claude/passthru.imported.json` - user-imported (written by |
| 16 | + `scripts/bootstrap.sh`) |
| 17 | +* `$PWD/.claude/passthru.json` - project-authored |
| 18 | +* `$PWD/.claude/passthru.imported.json` - project-imported |
| 19 | + |
| 20 | +## What you must do |
| 21 | + |
| 22 | +You are Claude. Shell out to the list script with `$ARGUMENTS` passed |
| 23 | +verbatim, then present the output. Do not paraphrase table rows; quote |
| 24 | +them verbatim. |
| 25 | + |
| 26 | +### 1. Run the list viewer |
| 27 | + |
| 28 | +Invoke exactly: |
| 29 | + |
| 30 | +```bash |
| 31 | +bash ${CLAUDE_PLUGIN_ROOT}/scripts/list.sh $ARGUMENTS |
| 32 | +``` |
| 33 | + |
| 34 | +Capture stdout, stderr, and the exit code. The script accepts: |
| 35 | + |
| 36 | +* `--scope user|project|all` - default `all`. |
| 37 | +* `--list allow|deny|all` - default `all`. |
| 38 | +* `--source authored|imported|all` - default `all`. Useful to see only |
| 39 | + bootstrap imports, or to check the hand-curated authored set. |
| 40 | +* `--tool <regex>` - perl regex matched against the `.tool` field. |
| 41 | +* `--format table|json|raw` - default `table` (colorized when stdout is |
| 42 | + a tty), `json` emits an array of annotated rule objects (scope, |
| 43 | + source, list, index, path, rule), `raw` emits one rule JSON per line |
| 44 | + with annotations stripped. |
| 45 | +* `--flat` - skip grouped rendering and emit one flat table with |
| 46 | + `scope`, `list`, `source`, `#` columns in front. |
| 47 | + |
| 48 | +### 2. Present the result |
| 49 | + |
| 50 | +Branch on the exit code: |
| 51 | + |
| 52 | +**Exit 0, stdout has rows:** show the grouped (or flat) table verbatim. |
| 53 | +Optionally add a one-liner summarizing the filter that was applied so |
| 54 | +the user knows which rules they are looking at. |
| 55 | + |
| 56 | +**Exit 0, stderr says `no rules found`:** no rule files exist yet, or |
| 57 | +the filter matched nothing. Suggest `/passthru:add` to add a first rule |
| 58 | +or `/passthru:bootstrap` to import from native settings. |
| 59 | + |
| 60 | +**Exit 2:** the user passed a bad `--tool` regex or an unknown flag. |
| 61 | +Surface stderr verbatim and suggest re-running with `--help`. |
| 62 | + |
| 63 | +### 3. Guidance |
| 64 | + |
| 65 | +* Point the user at `/passthru:remove <scope> <list> <index>` when they |
| 66 | + ask how to delete a rule. The indexes in this command's output line |
| 67 | + up with what `remove` expects. |
| 68 | +* Imported rules are regenerated by `/passthru:bootstrap`. If the user |
| 69 | + wants to edit them, they should change the underlying |
| 70 | + `permissions.allow` entries in their `settings.json` and re-run |
| 71 | + bootstrap, not hand-edit the imported file. |
| 72 | +* `--format raw` is the right choice for piping into `jq` for custom |
| 73 | + queries without quoting hassle. |
| 74 | + |
| 75 | +## Examples |
| 76 | + |
| 77 | +* Show everything (default grouping): |
| 78 | + |
| 79 | + ``` |
| 80 | + /passthru:list |
| 81 | + ``` |
| 82 | + |
| 83 | +* Show only deny rules in the user scope: |
| 84 | + |
| 85 | + ``` |
| 86 | + /passthru:list --scope user --list deny |
| 87 | + ``` |
| 88 | + |
| 89 | +* Show only what was imported by bootstrap: |
| 90 | + |
| 91 | + ``` |
| 92 | + /passthru:list --source imported |
| 93 | + ``` |
| 94 | + |
| 95 | +* Filter by tool: |
| 96 | + |
| 97 | + ``` |
| 98 | + /passthru:list --tool '^Bash$' |
| 99 | + ``` |
| 100 | + |
| 101 | +* Emit a flat table for easy grepping: |
| 102 | + |
| 103 | + ``` |
| 104 | + /passthru:list --flat |
| 105 | + ``` |
| 106 | + |
| 107 | +* JSON for scripting: |
| 108 | + |
| 109 | + ``` |
| 110 | + /passthru:list --format json |
| 111 | + ``` |
0 commit comments