Adds one or more patterns to the denylist in a single update. Uses the same validation as allowlist patterns.
Throws synchronously if any pattern is invalid. The returned promise resolves once the preference write completes and rejects if the write fails.
ProtectedaddAdds the patterns missing from the list without the session value (set via --session-preference), which
writing the effective list back would save to a settings file. Writes when a pattern is missing from either
list: the write clears the session value, unless the written list equals it, so a pattern that only the saved
list has takes effect too.
Provides a full analysis of a command for the confirmation UI. Returns parsed sub-commands, dangerous pattern detection, and which sub-commands are not yet covered by the allowlist.
Checks a command and returns detailed result with precedence:
Why pattern is not acceptable, or undefined when it is. Same rules as the add methods, exposed for
UI that refuses a pattern before writing it, so those rules live in one place.
ProtectedgetChecks if a command is allowed based on the allowlist patterns. Returns false if the command contains dangerous patterns, is on the denylist, or if the allowlist is empty. Returns true only if ALL sub-commands match at least one allowlist pattern.
Returns true if ANY sub-command matches ANY denylist pattern.
Checks if a sub-command matches an allowlist pattern using Claude Code compatible syntax. Supports * wildcards: trailing (optional args), leading (suffix match), middle (required match).
ProtectedremoveRemoves the pattern from the list without the session value, and writes that list when the pattern is in either list. The write clears the session value, so a pattern that only the session value has goes too. When the written list equals the session value, nothing is written, and the effective list is already right.
ProtectedvalidateValidates a pattern and returns the trimmed version. Throws an error if the pattern is invalid.
Adds one or more patterns to the allowlist in a single update. Rejects empty or whitespace-only patterns, "*" alone, and invalid wildcard positions. Trims patterns before adding and avoids duplicates.
Throws synchronously if any pattern is invalid. The returned promise resolves once the preference write completes and rejects if the write fails.