Day 3, 30 minutes · advanced
Why it matters
Yesterday's skill works, but it relies on Claude reading the ticket rules and getting every line right. Most of the time it will. For things a computer can check exactly, such as "is every field there" or "is the status one of three words", a small script is better than an instruction. It gives the same answer every time, and Claude can read its output and fix what it reports.
Today you turn repair-ticket from one file into a small folder. You add a ticket template, a check script and a line that lets the skill run its own script without a permission prompt. SKILL.md gets shorter, not longer. At the end Claude writes a ticket, runs the check, fixes what fails and shows you the OK line.
A skill is a folder
The skills page shows a skill as a folder: SKILL.md is required, and anything else is optional. Supporting files keep SKILL.md focused on the essentials, while Claude reads the details only when needed. After today Odette's skill looks like this:
.claude/skills/repair-ticket/
SKILL.md
template.txt
scripts/
check-ticket.sh
Two kinds of supporting file:
- Files Claude reads, such as
template.txt. Point to them fromSKILL.mdso Claude knows they exist and when to open them. - Scripts Claude runs, such as
check-ticket.sh. Claude runs the script and only its output enters the conversation, not the code. The best practices page says to make clear whether Claude should run a script or read it, and to give scripts clear error messages so Claude can fix what they report.
The skills page also suggests keeping SKILL.md under 500 lines and moving detail into separate files. Odette's is about 15.
Point to files with the skill's own folder
A skill can be started from any folder in the project, so a plain relative path may point to the wrong place. Claude Code fills in ${CLAUDE_SKILL_DIR} with the folder that holds the skill's SKILL.md. Use it for every path to a file inside the skill:
Run the check with the Bash tool: sh "${CLAUDE_SKILL_DIR}/scripts/check-ticket.sh" tickets/PW-NNNN.txt
The same placeholder keeps working when the skill later moves into a plugin, where it points to the skill's folder inside the plugin.
Let the skill run its own script
In Manual mode Claude Code asks before every command. The allowed-tools field lets a skill pre-approve tools for the turn that starts the skill:
allowed-tools: Bash(sh "${CLAUDE_SKILL_DIR}/scripts/check-ticket.sh" *)
Claude Code fills in ${CLAUDE_SKILL_DIR} in this rule too, so it matches exactly the command the instructions give. The * at the end covers the ticket file name. Three limits from the skills page:
- The grant clears when you send your next message. Start the skill again and it applies again for that turn.
- It does not restrict anything. Other tools stay available, and your normal permission rules still apply to them.
- It counts even in a
claude -prun in a folder you never trusted. That is why you review theallowed-toolsof skills in someone else's repository before you run Claude Code there. Lesson 6 comes back to this.
The script itself
check-ticket.sh is a dozen lines of plain shell. It checks one ticket: all eight fields present, a status of new, waiting or ready, an estimate that starts with EUR and a number, and no email address. It prints one line per problem and ends with exit code 1, or prints an OK line and ends with 0.
On Windows, Claude's Bash tool uses Git Bash, which comes with Git for Windows. Claude Code 101 recommended installing it. With Git for Windows installed, Claude has a Bash tool, and for claude.ai and Console accounts also a PowerShell tool, which it then treats as its main shell. That is why the instructions say "with the Bash tool". On macOS and Linux nothing changes. If you want to run the script yourself on Windows, open Git Bash in the project folder; on macOS and Linux use your normal terminal.
The steps
- Start Claude Code in Manual mode in the practice folder.
- Ask Claude to add the template and the script to the skill folder. Approve the writes after reading them.
- Ask Claude to replace
SKILL.mdwith the shorter version that points to both files and setsallowed-tools. - Start the skill on Rutger's note and watch: you approve the ticket file, then Claude runs the check without asking you and shows the OK line.
- Break a ticket on purpose and ask Claude to run the check: it lists the problems.
- Commit the skill folder.
Follow the steps for Claude Code below.
Example: the check catches a slip
Odette's note about Rutger's city bike said "about 45 euro, maybe 50". Claude first wrote Estimate: EUR 45 to 50. The check passed that line, because it starts with EUR and a number, but Odette did not like it and added one rule to SKILL.md: "Estimate: one number, the highest one in the note." The next ticket said EUR 50. The script caught what it could check, and the instruction handled the judgment call. That split is the point of today.
Common mistakes
- A path without
${CLAUDE_SKILL_DIR}. It works when Claude happens to be in the right folder and fails later. - A script that prints nothing useful. "Error" tells Claude nothing. "no Parts line" tells it what to fix.
- Expecting
allowed-toolsto last all session. It covers the turn that starts the skill. For a whole session, use a permission rule instead.
Today's actions
Ticks are not saved without an accountDo it in Claude Code
Claude Code
- Start Claude Code in Manual mode in the practice folder.
cd pennywhistle-shop claude --permission-mode manual - Paste this prompt and press Enter. Read both files in the prompt and choose Yes for each.
In .claude/skills/repair-ticket/ create two files with exactly this content. Do not run them. 1. template.txt: Ticket: PW-0000 Customer: first name only Bike: type and colour, for example blue city bike Problem: what the customer noticed, in one line Work: what we will do, in one line Parts: parts we need, or none Estimate: EUR and a whole number Status: new, waiting or ready 2. scripts/check-ticket.sh: #!/bin/sh # check-ticket.sh: checks one Pennywhistle repair ticket f="$1" [ -f "$f" ] || { echo "No ticket file: $f"; exit 1; } fail=0 for field in Ticket Customer Bike Problem Work Parts Estimate Status; do grep -q "^$field: " "$f" || { echo "$f: no $field line"; fail=1; } done grep -Eq '^Status: (new|waiting|ready)([^a-z]|$)' "$f" || { echo "$f: Status must be new, waiting or ready"; fail=1; } grep -Eq '^Estimate: EUR [0-9]' "$f" || { echo "$f: Estimate must start with EUR and a number"; fail=1; } if grep -q '@' "$f"; then echo "$f: remove the email address"; fail=1; fi if [ "$fail" -eq 0 ]; then echo "OK: $f passes"; fi exit "$fail" - Paste this prompt to replace
SKILL.mdwith a shorter version that points to both files, and approve the edit.Replace .claude/skills/repair-ticket/SKILL.md with exactly this content: --- name: repair-ticket description: Turns a rough customer note about a bike repair into a tidy Pennywhistle Cycles repair ticket and checks it. Use when the user pastes a customer note, a phone message or a quick description of a bike problem, or asks for a repair ticket. allowed-tools: Bash(sh "${CLAUDE_SKILL_DIR}/scripts/check-ticket.sh" *) --- Make one repair ticket from the customer note. 1. Follow the layout in ${CLAUDE_SKILL_DIR}/template.txt exactly, one line per field. 2. Save it as tickets/PW-NNNN.txt with the next free number, starting at PW-0001. 3. Customer: first name only. Never copy a phone number or email address. 4. Estimate: EUR and a whole number from the note, or EUR 0 if it gives no price. Status: new. 5. Run the check with the Bash tool: sh "${CLAUDE_SKILL_DIR}/scripts/check-ticket.sh" tickets/PW-NNNN.txt 6. Fix every problem it prints and run it again. Finish when it prints OK, and show that line. 7. Then list anything from the note you left out. - Run the skill on Rutger's note. Approve the new ticket file. Claude then runs the check without asking you and shows the OK line.
/repair-ticket Make a ticket from notes/rutger.txt - Break a ticket on purpose and run the check yourself through Claude. This time Claude Code asks before the command, because the skill's grant only covered its own turn: choose Yes.
Create tickets/PW-0099.txt with only these three lines: Ticket: PW-0099 Customer: test@example.com Status: done Then run sh .claude/skills/repair-ticket/scripts/check-ticket.sh tickets/PW-0099.txt with the Bash tool and show me the full output. - Read the list of problems, then ask Claude to delete the broken ticket and commit the rest.
Delete tickets/PW-0099.txt. Then commit the skill folder and the new ticket with the message: Add a template and a check to repair-ticket.
Note: On Windows you need Git for Windows: the script runs with the Bash tool, which uses Git Bash. To run it yourself, open Git Bash in the project folder and type the sh line from step 5. On macOS and Linux use your normal terminal. The grant in allowed-tools covers only the turn that starts the skill.
Paid planNeeds a paid Claude plan (Pro, Max, Ultra, Team or Enterprise) or a Claude Console account. The free Claude plan does not include Claude Code.
Create a free account to save your progress
Free, and no payment details. Your ticks and finished lessons are kept, on every device.
Create a free account I already have an accountCreate a free account to save your progress. Sign in or sign up