Skip to main content

Module steer

Module steer 

Source
Expand description

Redirection steering: recognise the ad-hoc shell idioms a ct tool serves better, and (as a Claude Code PreToolUse hook) steer the agent to the ct equivalent instead.

Agents reach for raw shell — find | xargs grep, sed -i, cat | head, for loops — even when a suite tool would do the job bounded, deterministic, and self-verifying. analyze is the pure heart: it classifies a shell command string into an optional Steer naming the ct tool that serves it and a best-effort equivalent command. The hook submodule wraps that in the Claude Code PreToolUse JSON protocol (deny / ask / warn); the install submodule wires the hook into a project’s .claude/settings.json.

The matcher is deliberately conservative: it only fires on a fixed set of high-confidence 1:1 idioms, never re-steers a command that already invokes ct, and returns None (allow) whenever it is unsure. The hook is fail-open — any malformed input or unrecognised command is allowed — because it runs ahead of every shell call.

Modules§

hook
The Claude Code PreToolUse hook protocol: turn a stdin envelope into a steering decision.
install
Merging the steering hook into a Claude Code settings file. The merge runs through the comment- and layout-preserving ct-patch engine (crate::patch): the existing file is parsed only to decide which edits to make, and those edits are byte-range splices against the original text, so the user’s comments and formatting survive.

Structs§

Steer
A steering match: a ct tool serves the inspected command.

Enums§

Mode
What the hook does when a command matches a steering rule.

Functions§

analyze
Classify a shell command. None means “allow” — no ct tool clearly serves it. The matcher only fires on high-confidence idioms and never re-steers a command that already invokes ct.