Exit code

A number that a script returns at the end to say how it went: 0 means “everything is fine”, 2 means (in hooks) “stop the action”.

You’ll also find it as: exit codes, exit 2

How it appears in the course

The script answers with a number (the exit code): 0 means “everything is fine”, 2 means “stop”.
Introduction · Module 07, Hooks: automatic actions
Every program returns a number when it finishes. That’s the exit code. It’s the program’s way of saying “everything is fine” or “stop”.
What does a hook receive, and what does it answer? · Module 07, Hooks: automatic actions
If the file name contains one of them, it writes a message on stderr (>&2) and exits with exit 2. That means “stop”. Claude gets the message and understands why it isn’t allowed.
Ready-to-use recipes · Module 07, Hooks: automatic actions

Where you learn it

In module 07 · Hooks: automatic actions, in the Claude Code for Beginners course.

Related terms

Learn Claude Code from zero, in plain English

12 modules with 1–2 minute lessons, which you can also do on your phone. The first two modules are free.