You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 39deb49
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+22-1Lines changed: 22 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,7 @@ Nudge uses agent hook systems to watch supported operations:
22
22
When something matches a rule you've defined:
23
23
24
24
-**Interrupt** (PreToolUse rules): Nudge catches the issue *before* it's written and explains what to fix
25
+
-**Substitute** (PreToolUse Bash rules): Nudge rewrites simple deterministic commands, lets the tool proceed, and tells the model what changed
25
26
-**Continue** (UserPromptSubmit rules): Nudge injects context into the conversation to guide the agent
26
27
-**Passthrough**: No rules matched, everything proceeds normally
27
28
@@ -71,6 +72,24 @@ error: rule violation
71
72
72
73
The pattern: **what's wrong** -> **how to fix** -> **retry**.
73
74
75
+
For simple mechanical Bash command rewrites, use `action: substitute` with a regex `replace:` template instead of a blocking message:
76
+
77
+
```yaml
78
+
version: 1
79
+
rules:
80
+
- name: use-yarn-add
81
+
action: substitute
82
+
on:
83
+
- hook: PreToolUse
84
+
tool: Bash
85
+
command:
86
+
- kind: Regex
87
+
pattern: "^npm install(?: (?P<args>.*))?$"
88
+
replace: "yarn add {{ $args }}"
89
+
```
90
+
91
+
Substitutions work for Claude Code and Codex CLI. Nudge returns the provider's full updated tool input with only `command` changed, and adds `hookSpecificOutput.additionalContext` so the model sees what was rewritten.
92
+
74
93
For the full rule syntax and copy-pasteable examples, run `nudge claude docs` or `nudge codex docs`.
75
94
76
95
### Rule Writing Is Iterative
@@ -155,6 +174,8 @@ nudge check "**/*.rs"
155
174
nudge check || exit 1
156
175
```
157
176
177
+
`nudge check` only evaluates file-based block rules for `PreToolUse` Write/Edit matchers. It ignores `action: substitute` rules because substitutions rewrite live Bash hook payloads and need a provider to receive `updatedInput`.
0 commit comments