Decide Where Guidance Lives

Your changelog skill now loads when you ask for the day’s entry, by name or in your own words. Its first step says to run npm test and stop if anything fails. However, that step is text the model reads, and a session can still skip it or skim the result, especially when the tests take a while or the request sounds urgent.

In this lesson, you’ll move the test run out of the instructions and into a script that runs the same way every time. You’ll also work out a rule of thumb for any piece of guidance: does it belong in the instruction file, a skill, a script, or nowhere at all? Start with the step that must never be skipped.

Turn the Must-Happen Step Into a Script

Instructions guide the agent, but they don’t run. When a step must happen exactly, the dependable place for it is code, and a skill’s folder can hold that code next to SKILL.md. For the changelog skill, that’s a script, scripts/check.js, which runs the tests and reports a failure in a way that can’t be misread.

The script reports its verdict the way every command does, with an exit code. A command that ends with exit code 0 succeeded, and any other number means it failed. npm test already exits with a non-zero code when a test fails, which is how a script, or your shell, can tell without reading the output.

Writing a script that starts another command uses features of Node.js that this course doesn’t teach, so hand the job to your agent. Here’s an example task, with a goal, limits, and a done-when you can check yourself:

Language: Text
In the changelog-entry skill's folder, add
scripts/check.js. It runs npm test from the repository
root and shows its output. If any test fails, it prints
"Tests failed: no changelog entry." and exits with a
non-zero exit code. It never writes to CHANGELOG.md.
Change no other file.
Done when the script exits non-zero and leaves
CHANGELOG.md unchanged while a test fails, and exits 0
when all tests pass.

The done-when is the part you’ll check. A done report is a claim, so prove it with a test that fails on purpose. Save this file as test/broken.test.js. It compares two different status strings, so it fails whatever the festival’s code does, and it exists only to see how the script handles a failure:

Language: JavaScript
import { test } from "node:test";
import assert from "node:assert/strict";

test("fails on purpose to try check.js", () => {
  assert.equal("held", "claimed");
});

Then run the script with && after it. Your shell runs the command after && only when the first one exits with 0, so the message is your exit code check. The script’s path depends on your agent, so open the version for yours, checked in December 2026:

Language: Shell
$ node .claude/skills/changelog-entry/scripts/check.js && echo "Check passed"

When the script works, you’ll then change step 1 of .claude/skills/changelog-entry/SKILL.md to this:

Language: Markdown Text
1. Run `node .claude/skills/changelog-entry/scripts/check.js`.
   If it exits with an error, stop and report its output.
   Don't write an entry.
Language: Shell
$ node .agents/skills/changelog-entry/scripts/check.js && echo "Check passed"

When the script works, you’ll then change step 1 of .agents/skills/changelog-entry/SKILL.md to this:

Language: Markdown Text
1. Run `node .agents/skills/changelog-entry/scripts/check.js`.
   If it exits with an error, stop and report its output.
   Don't write an entry.

With the broken test in place, you should see the failing test and the script’s message, but no “Check passed”, and git status should show CHANGELOG.md unchanged. Delete test/broken.test.js, run the same command again, and “Check passed” appears. If either run goes differently, give the agent what you saw and ask it to fix the script.

Your agent’s check.js won’t match anyone else’s, so have it reviewed before you commit. The button below opens Code Mentor: paste your task, the script, and both runs’ output, and it checks them against your done-when:

Then make the step 1 change shown for your agent, and run git status and git diff. Expect only the new scripts/check.js and your step 1 edit. Discard anything else the agent changed, and commit the skill’s folder.

In manual mode, which you set in Package a Repeated Job as a Skill, Claude Code asks before it first runs the script, so if you allow it for good, allow that exact command, not node *. Codex’s default mode runs it in the sandbox without asking. Either way, review later changes to check.js like any diff.

The script still doesn’t make the step impossible to skip. The agent has to run it, and stopping after a failure is still step 1’s guidance. The agent writes the entry itself, so nothing in check.js stops that edit.

What changes is that the check can’t be done loosely. It runs every test, it decides by exit code rather than by the model’s reading of the output, and the session shows whether it ran and what it reported. To enforce the stop too, the model’s draft would have to go through a script that appends it only when the tests pass, which is more than this skill needs.

A skill’s scripts run as your agent’s commands, so take care with skills you copy from someone else. Their instructions direct your agent, and their scripts run with your permissions, credentials, and network access. Read SKILL.md and every script before you install a skill.

Choose Where Each Piece of Guidance Goes

You’ve now used three places for guidance, and each one costs something different. Cost here means context, the room in a session that every loaded line takes up, and reliability, how sure you can be that the guidance is followed:

  • The instruction file loads in every session. Each line costs context in every task, so it’s for rules that every task needs, such as how to run the tests or which files to leave alone. It’s still guidance: the model reads it, and nothing enforces it.
  • A skill costs a line or two of context, its name and description, until it’s picked. Then its whole body loads. It’s for a procedure that only some tasks need, and it’s guidance too.
  • A script runs outside the model. It costs no context except the output it prints, and it does the same thing every time. It’s for steps that must happen exactly, but something still has to run it.
  • Nowhere is a real option. Leave a line out when the agent already does it without being told, when it’s too vague to act on, such as “write good code,” or when it’s for one task only and belongs in that task’s message.

Guidance from the first three places reaches a session at different times, and only the script’s output ever comes back from outside the model:

The instruction file and skill descriptions load every session, a skill's body when picked, and a script sends back only output.
Each Place Reaches the Session at a Different Time

That gives you a rule of thumb. Ask first whether the guidance has to hold exactly. A step that must happen exactly goes in a script, though what the agent does with its result, such as stopping after a failure, stays guidance. Something that must never happen, such as pushing to GitHub without your approval, goes in your agent’s permission rules, which block it rather than asking the model to hold back.

If the guidance doesn’t have to hold exactly, ask how many tasks need it. Every task means the instruction file, some tasks means a skill, and one task means the task itself.

Try it on the festival repository. Its rules sit in one file that both agents read:

Codex reads AGENTS.md, and Claude Code reads CLAUDE.md, which only imports AGENTS.md. So open AGENTS.md.

Sort every line of it into those four places, with a reason for each, and mark any line that forbids an action as a permission rule instead. A long instruction file usually has a few lines that only one kind of task needs and a few that the agent would follow anyway:

Decide When a Skill May Run on Its Own

A skill that the agent can pick on its own is convenient for a job like the changelog. The entry is an edit in your working tree. If you commit after every job, then the worst outcome of an unexpected pick is a change you review and discard with git restore CHANGELOG.md. If the file already holds edits of yours, remove only the entry’s lines instead, because git restore discards the whole file’s uncommitted changes.

Some jobs aren’t like that. A skill that pushes to GitHub, deploys the app, or publishes a notice to the festival’s volunteers has side effects, changes outside your working tree that you can’t take back by discarding a file. For a skill like that, you want it to run only when you invoke it by name. Both agents have a setting that turns off implicit invocation, checked in December 2026. Open the version for your agent:

Add disable-model-invocation: true to the skill’s front matter:

Language: Markdown Text
---
name: publish-notice
description: Publishes the day's notice for volunteers.
disable-model-invocation: true
---

Claude Code then leaves the skill out of what it picks from, and the skill runs only when you type /publish-notice.

Add a file, agents/openai.yaml, inside the skill’s folder, with this setting:

Language: YAML
policy:
  allow_implicit_invocation: false

Codex then doesn’t pick the skill on its own, and the skill runs only when you invoke it with $publish-notice or from /skills.

The setting only decides when the skill loads. It doesn’t limit what the agent may run, so require approval for commands like git push and deployment commands in your permission rules too.

Leave the changelog skill as it is. Its entry stays in your working tree, where you can review it before anything leaves your machine.

Check Your Understanding

Answer these before you open the answers:

  1. For each of these lines, choose the instruction file, a skill, a script, or nowhere, and say why: “Run the tests with npm test.” “Write the day’s changelog in the festival’s format.” “Never write an entry while a test fails.” “Write clean, readable code.”
  2. A teammate moves the changelog steps into the instruction file “so the agent never misses them.” What does that cost, and what does it fail to fix?
  3. You’re writing a skill that commits the day’s entry and pushes it to GitHub. Should the agent be able to pick it on its own? Why or why not?
  1. “Run the tests with npm test” goes in the instruction file, because every task needs it. The changelog format goes in a skill, because only the changelog job needs it. “Never write an entry while a test fails” splits in two: running and judging the tests go in a script, and stopping before the write stays in the skill, since the agent writes the entry. “Write clean, readable code” goes nowhere, because it’s too vague for the agent to act on.
  2. Every session would load the steps, including sessions that never touch the changelog, so they cost context in every task. They’d still be guidance the model reads, so a session could still skip the test step. Only a script runs the tests and determines their verdict the same way every time.
  3. No. Pushing is a side effect outside your working tree, so require explicit invocation with your agent’s setting, run it by name when you mean it, and leave the push itself asking for approval.

You’ve moved the changelog skill’s test step into scripts/check.js, and you have a rule of thumb for where guidance goes. In the next lesson, Exercise: Build a Changelog Skill, you’ll build those pieces yourself.

It’s the course’s first coding exercise, and it runs in your browser without your agent: you write code in the editor, click Run Tests, and automated tests check it. Run them often, read a failing test’s message for clues, and use Full screen for room. Its Contents tab explains more.

Become a Member to join the conversation.