Hook Weights and Ordering
Sequencing multiple hooks deterministically.
Hook Weights and Ordering is a free Helm Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Helm Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Order Matters
When several hooks share one event, the sequence can matter. Maybe a secret must exist before the migration runs. Helm orders hooks with a weight.
The Weight Annotation
You set ordering with the helm.sh/hook-weight annotation. Its value is a string holding a number that Helm uses to sort hooks of the same event.
"helm.sh/hook-weight": "5"Lower Runs First
Helm sorts weights in ascending order, so the lowest number runs first. A hook weighted -5 fires before one weighted 0, which fires before one at 10.
Negatives Are Allowed
Weights can be negative. Give a setup hook a value like minus five when you want it to run ahead of everything sitting at the default weight of zero.
"helm.sh/hook-weight": "-5"Quote the Number
The weight value must be a quoted string, even though it represents a number. Write "10" with quotes, not a bare 10, or the annotation is invalid.
annotations:
"helm.sh/hook-weight": "10"Default Is Zero
A hook without a weight annotation is treated as weight zero. That makes zero a handy baseline you can schedule other hooks before or after.
Events Group First
Weights only sort within the same event. A pre-install hook never interleaves with a post-install one; all pre-install hooks run, then later events run.
Ties Sort by Name
If two hooks share the same weight, Helm falls back to sorting them by resource name alphabetically. Distinct weights are clearer when order truly matters.
Each Weight Completes
Helm runs hooks weight by weight and waits for each to be ready before the next. So a setup hook fully finishes before the migration it prepares begins. ⏳
A Practical Pair
Picture a secret-creation hook at weight -5 and a migration hook at weight 0. Helm guarantees the secret lands first, so the migration can read it.
# secret hook
"helm.sh/hook-weight": "-5"
# migration hook
"helm.sh/hook-weight": "0"Spread Weights Out
Leave gaps between weights, like 10, 20, 30, instead of 1, 2, 3. Later you can slot a new hook in between without renumbering everything else. 📐
Quick Check
Two pre-install hooks have weights -5 and 10. You need to know which runs first.
Recap
The hook-weight annotation, a quoted number, orders hooks of one event from lowest to highest. Default is zero and ties break by name. 🔢
Frequently asked questions
Is the “Hook Weights and Ordering” lesson free?
Yes — the full text of “Hook Weights and Ordering” is free to read here on the web, and the Helm Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Helm Academy course, upgrade to CoddyKit PRO.
What will I learn in “Hook Weights and Ordering”?
Sequencing multiple hooks deterministically. You practise Helm Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Helm Academy?
No prior experience is required. Helm Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Hook Weights and Ordering” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Helm Academy lesson?
Yes. Every Helm Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- What Hooks Are and When They Fire
- A Database Migration pre-upgrade Job
- Hook Weights and Ordering
- Hook Deletion Policies