Tips // Claude in practice

Tips for working better with Claude

One short tip at a time, with an example you can copy. Move through them at random or search for what you need.

OtherAdvancedClaude Agent SDK

If tool order matters, enforce it in code

Block process_refund until get_customer has returned a verified ID: the prompt works almost always, the hook works always.

An instruction in the prompt gives probabilistic compliance; a hook or a precondition in your code gives deterministic compliance. When the mistake costs money, exposes data or breaks a policy, use the second. The precondition can redirect to the escalation flow instead of just rejecting.

Example
# Pseudocode for the Agent SDK PreToolUse hook
if call.name == "process_refund":
    if not session.verified_customer_id:
        return deny("Verify the customer with get_customer first")
    if call.args.amount > 500:
        return redirect_to_escalation(call)
#hooks#determinism#business-rules