Make it repeatable: skills, hooks and subagents

Day 4, 30 minutes · advanced

Goal of this lessonPackage one task you repeat on every project so the agent does it the same way every time from one short command.

Why it matters

On every job you check the same things in every change: whether it does what was asked, whether it has tests, whether a secret or a real customer slipped in. Today that review lives in your head and in the prompt you happen to type. The day you leave, it leaves with you, and the client's engineer inherits a solution that only works when you are the one typing.

Coding agents give you three ways to make work repeatable. A skill is packaged know-how that the agent loads when it is needed. A hook is a script that runs by itself at a fixed moment, so a check cannot be forgotten. A subagent is a helper with its own context window (everything the model can see at once), so a big reading job does not crowd your main session.

At the end of this lesson your usual review is one short command in the practice repository. A hook runs the tests every time the agent finishes, and you have run the review on two different changes and got the same shape of result both times.

Which one to use

This course uses one rule: know-how goes in a skill, a check that must always run goes in a hook, and a side job that reads a lot goes to a subagent. The agent decides whether a skill fits, unless you call it yourself. It never decides whether a hook runs.

On day 3 you wrote an instruction file, which rides along in every session. A skill works the other way round: until it is needed, the agent sees little more than its name and description. So a rule that must always hold goes in the instruction file or a hook, and a procedure you use now and then goes in a skill.

The steps

You work in the orderdesk/ repository from days 2 and 3. Commit the day 3 change first, so that change A is its own commit and the working tree is clean. Pick your tool below and follow its steps. This is the order, and what each part must hold. Steps 6 and 8 are optional: the checklist needs the skill, the hook and the two reviews, so do the helper only if you have time left.

  1. Write the checklist down. Five items, in this order: does the change do what was asked and nothing else; are tests added or updated, and do they pass; no secrets and no real customer data in the change; files in data/ are untouched; names and error messages are clear.
  2. Fix the shape of every result. Verdict (ship or hold), Findings (at most three, each with file and line), Risk (one line), Question for the author (one). A fixed shape is what makes two reviews comparable.
  3. Package it as change-review. Lower case, one hyphen. Avoid plain review where your tool already has a built-in command with that name. Let the skill say which change it reviews when you name none (the uncommitted changes, otherwise the last commit), so the bare command is enough.
  4. Run it on change A, the expected_delivery_for change from day 3. If that is not your last commit, name its commit when you ask. Save the result as reviews/change-a.md.
  5. Add the hook. It runs a small test script, scripts/run_tests.sh, when the agent finishes a turn. When a test fails, the hook sends the agent back to work with the failure. Where your tool documents a guard against a loop, use it. On Windows the guide of your tool says whether the hook can call a PowerShell script, scripts/run_tests.ps1, instead. Where it cannot, run the tests by hand before you accept a change. On that tab this is how you do today's second action.
  6. Optional: add the helper diff-reader. It only reads, and it returns a summary of a large diff. Because it only reads, you give it the diff as a file.
  7. Make change B with the agent: draft_reply.py greets the customer by first name, taken from from_name in the sample email. The greeting becomes Hi Sanne, and nothing else changes. The hook runs the tests when the agent finishes.
  8. Optional: hand change B to diff-reader. Save the diff with git diff > reviews/change-b.diff, ask for the summary, then check how full your main window is.
  9. Run change-review on change B and save the result as reviews/change-b.md. Then commit change B.

The two changes as diff text

In a chat tool there is no repository, so paste these two diffs. In a coding tool, review your own changes: they may look a little different.

Change A:

--- a/orders.py
+++ b/orders.py
+import csv
@@
+def expected_delivery_for(order_id):
+    """Return the expected delivery date of an order, or None."""
+    with open("data/orders.csv", newline="") as f:
+        for row in csv.DictReader(f):
+            if row["order_id"] == order_id:
+                return row["expected_delivery"]
+    return None
--- a/test_orders.py
+++ b/test_orders.py
+from orders import expected_delivery_for
@@
+    def test_expected_delivery(self):
+        self.assertEqual(expected_delivery_for("WH-10432"), "2026-12-03")

Change B:

--- a/draft_reply.py
+++ b/draft_reply.py
@@
-def build_draft(order_id, status):
+def build_draft(order_id, status, first_name):
     return "\n".join([
         f"Subject: Your order {order_id}",
         "",
-        "Hello,",
+        f"Hi {first_name},",
@@
-    print(build_draft(order_id, status_for(order_id)))
+    print(build_draft(order_id, status_for(order_id), email["from_name"]))

Check the result

Put reviews/change-a.md and reviews/change-b.md side by side.

  • Both have the same four headings in the same order. If one drifts, tighten the shape in the skill, not in your prompt.
  • The verdicts may differ, and that is fine. Change B as shown has no new test. A review that does not raise that has a gap in item 2 of the checklist.
  • Where your tool could add the hook, it really fires. Break a test on purpose, ask the agent for a small change, and see it come back to the failure. Then undo the break.
  • If you made the helper: its summary is short, and your main session never read the whole diff.

How the tools compare

  • Claude Code: skill in .claude/skills/, a Stop hook in .claude/settings.json, subagent in .claude/agents/.
  • OpenAI Codex: skill in .agents/skills/, a Stop hook in .codex/hooks.json that runs only after you trust it, custom agent as a TOML file in .codex/agents/.
  • Gemini CLI: custom command in .gemini/commands/ (skills exist too), an AfterAgent hook in .gemini/settings.json, subagent in .gemini/agents/.
  • Cursor: skill in .cursor/skills/, a stop hook in .cursor/hooks.json, subagent in .cursor/agents/ with a read-only setting.
  • GitHub Copilot: skill in .github/skills/, an agentStop hook in .github/hooks/, custom agent in .github/agents/.
  • The four chat products: a saved skill (in ChatGPT, a plugin with one skill). We found no vendor page that shows a hook or a subagent in their chat. OpenAI documents subagents for ChatGPT Work (ChatGPT's agent for longer, multi-step tasks) and for Codex.
  • Shared format: in all five coding tools a skill is a SKILL.md file with a name and a description. Cursor also loads skills from the Claude and Codex folders, and Copilot CLI also reads .claude/skills.

Keep it for the next job

  • The skill, the hook and the helper are files in the repository. Commit them, so they travel with the code and the client's engineer gets them at handover.
  • A hook runs a script with your rights and does not ask before each run. Read every hook before you trust it, also one that came with a client repository.
  • Keep secrets and real customer data out of skill files. Anyone who gets the repository or a shared skill gets them too.
  • Where a client admin blocks hooks, run the tests by hand before you accept a change, and write that step into the skill.
  • On day 7 the same kind of check runs with nobody at the keyboard.

Deeper dive

Today's actions

Ticks are not saved without an account

Do it in your tool

Claude

  1. Turn on code execution: Settings > Capabilities > Code execution and file creation (called Create and edit files in the updated layout).
  2. Make a folder change-review on your computer with one file SKILL.md and paste this text into it.
    ---
    name: change-review
    description: Reviews one code change that the user pastes as diff text, against the team checklist. Use when asked to review a change or a diff.
    ---
    Review the code change the user pastes as diff text.
    
    Check these five items in this order:
    1. Does the change do what was asked and nothing else?
    2. Are tests added or updated, and do they pass? You cannot run them here, so judge from the diff and say so under Risk.
    3. No secrets and no real customer data in the change.
    4. Files in data/ are untouched.
    5. Names and error messages are clear.
    
    Answer in exactly this shape:
    Verdict: ship or hold
    Findings: at most three, each with file and line
    Risk: one line
    Question for the author: one
    
    Do not rewrite the code.
  3. Zip the folder itself, not only its contents, with any zip tool, so that the ZIP holds the folder change-review. On macOS or Linux: zip -r change-review.zip change-review/.
  4. Go to Customize > Skills, click the + button, then + Create skill.
  5. Select Upload a skill, upload the ZIP file and check that the skill is switched on in your list.
  6. Open a new chat, type / in the message box, select the change-review skill and paste change A from the lesson text.
  7. Open another new chat and do the same with change B. Check that both answers have the same four headings.

Note: Skills need code execution switched on. We found no hook or subagent in Claude chat on the pages we read: for the test hook and the diff-reader helper, use the Claude Code tab of this lesson. Keep secrets and real data out of the skill folder, because everyone you share a skill with gets its files. Save each result yourself as reviews/change-a.md and reviews/change-b.md.

Checked on 27 November 2026 · Source: Claude Help Center: Use skills in Claude (opens in a new tab)

Create a free account to save your progress. Sign in or sign up