In this blog post, we will see how a small Python script called is a pre-hook script for AI coding CLIs. It blocks pleasantry-only prompts like "hi", "hello", "ok", and "thank you" before they ever reach the model.
Here is the observation that started this. AI coding assistants are task tools, not chat buddies. Every "hello" still triggers a full round trip: the CLI reads it, sends it to the model, and the model replies. That is a wasted call, wasted tokens, and a small break in your flow, all for a prompt that carries no actual task.
I spend a lot of my time thinking about efficiency, whether that is a load test or a model call, so this felt like an easy win to automate away.
2. How it works
The idea is simple. A hook intercepts your prompt before it reaches the model:
You type "hi" --> Hook reads prompt --> Regex fullmatch --> Blocked
You type "fix auth bug" --> Hook reads prompt --> No match --> Prompt proceeds
Under the hood, the matcher normalizes your input (lowercase, strip punctuation, collapse whitespace) and checks if the entire prompt is a pleasantry using a fullmatch, not a partial match. That distinction matters a lot. Prompts that contain a pleasantry word but also carry a real task pass through untouched.
A few tools do not have a hook system to plug into yet, so they are not supported: CodeBuddy, OpenCode, Aider, Kilo Code, Trae, Hermes, Pi, OpenClaw, Amp, Google Antigravity, Cline, oh-my-pi, Freebuff, and Command Code.
and clone the repo. Then run the installer:
python install.py
The installer will:
- Copy
block_pleasantries.pyto~/.pleasantries/
- Detect which AI coding CLIs are installed on your machine
- Let you pick which ones to hook
- Merge the hook into each CLI's config, skipping anything already installed
If you would rather wire it up by hand, here is the Claude Code config as an example. Add this to ~/.claude/settings.json:
{
"hooks": {
"UserPromptSubmit": [
{ "hooks": [{ "type": "command",
"command": "python3 /path/to/block_pleasantries.py claude",
"timeout": 5 }] }
]
}
}
Swap in the real path to block_pleasantries.py, and you are set. Every other supported CLI follows the same pattern with its own config file, all documented in the README.
To remove every hook later:
python install.py --uninstall
Requirements are light: Python 3.10+, no external dependencies beyond the standard library (json, re, sys), and it runs on macOS, Linux, and Windows.
6. Customizing the blocklist
The blocklist lives in the PLEASANTRY_PATTERNS regex inside block_pleasantries.py, grouped by category:
Greetings: hi, hello, hey, howdy, good morning, and similar
Acknowledgments: ok, sure, yeah, got it
Thanks: thank you, thanks, thx, ty
Please: please, pls, plz
Farewells: bye, goodbye, see ya, later
If your team has its own shorthand, like a Slack-style "yo" or "np", just add it to the matching category and the hook picks it up on the next run.
Adding support for a brand new CLI is just as simple, since the core matcher is CLI-agnostic and each CLI only needs a small adapter function to plug into the shared ADAPTERS dict.
7. Wrap up
Pleasantries is a small tool solving a small but real problem. If you run multiple AI coding CLIs day to day and catch yourself typing "hi" before your actual ask, this hook quietly saves you a wasted model call every single time.
Happy Testing!
Do you type greetings to your AI coding assistant out of habit too, or am I the only one guilty of that?
SOCIAL SHARE CARD GENERATOR