Skip to content

nudge

nudge

nudge

nudge(
    message: str,
    *,
    when: Callable[[BaseHookEvent], bool] | None = None,
    signals: Sequence[Signal | NlpSignal]
    | Signals
    | None = None,
    only_if: Sequence[TCondition] = (),
    skip_if: Sequence[TCondition] = (),
    block: bool = False,
    events: Event | None = None,
    max_fires: int | None = None,
    tests: InlineTests | None = None,
    async_: bool = False,
) -> None

Register a nudge that warns (or blocks) when conditions or signals match.

Example

nudge("Remember to run tests", only_if=[TouchedFile("*/.py")])

With signal scoring: >>> nudge("Stop retrying", ... signals=Signals([Signal(r"retry", weight=2)], threshold=2, window=5))

gate

gate(message: str, **kwargs: Any) -> None

Register a blocking gate — shorthand for nudge(message, block=True, ...).

Example

gate("Run tests before committing", when=lambda evt: not has_tests(evt))