Capstone: Create a Custom Skill
Time: 30-60 minutes | Skills: Built-In Skills, Custom Skills, Triggers
The Scenario
You are a developer who does the same set of steps every time you finish a feature: you run tests, check for lint errors, write a commit message, and update a changelog file. Instead of remembering every step (or telling Claude each time), you want to create a custom skill that handles this entire workflow automatically.
Your goal: create a "Finish Feature" skill that Claude can follow whenever you say you are done with a feature.
Requirements
Your skill should:
- Run the project's test suite (use
npm testor whatever test command your project uses) - Check for lint errors (use
npm run lintor equivalent) - Stop if tests or lint fail — do not proceed with a broken build
- Stage all changes with
git add - Create a commit with a descriptive message based on the changes
- Add an entry to CHANGELOG.md with today's date and a summary of the change
Step-by-Step Guide
Part 1: Set Up a Test Project
If you do not have a project to work with, create a simple one:
mkdir feature-workflow
cd feature-workflow
git init
npm init -y
Create a basic package.json scripts section so the skill has commands to run:
{
"scripts": {
"test": "echo 'All tests passed'",
"lint": "echo 'No lint errors'"
}
}
Create an initial CHANGELOG.md:
# Changelog
## Changes
Commit the initial setup:
git add -A
git commit -m "Initial project setup"
Part 2: Create the Skill
- Create the skills directory:
mkdir -p .claude/skills
- Create
.claude/skills/finish-feature.mdwith:- Frontmatter containing a title, description, and triggers (think about what words you would say when finishing a feature)
- Step-by-step instructions covering all six requirements above
- Clear rules about when to stop (test/lint failures)
- Instructions for what format the changelog entry should use
Write your skill as if you are explaining the process to a new team member. Be specific about:
- The exact commands to run
- What to do if something fails
- The exact format for output (like changelog entries)
Part 3: Test Your Skill
- Make a small code change in your project (create or modify a file)
- Start Claude Code:
claude - Tell Claude: "I'm done with this feature, please finish it up"
- Watch Claude follow your skill's instructions
- Verify that:
- Tests and lint were checked
- A commit was created
- The changelog was updated
Part 4: Test the Failure Case
- Modify your
package.jsonso the test script fails:
{
"scripts": {
"test": "echo 'FAIL: 2 tests failed' && exit 1",
"lint": "echo 'No lint errors'"
}
}
- Make a code change and ask Claude to finish the feature again
- Verify that Claude stops when tests fail and does not commit
If Claude proceeds despite test failures, your skill instructions need to be more explicit. Add something like: "If the test command exits with a non-zero code, STOP immediately and report the failure. Do NOT continue to the next step."
Part 5: Refine
Based on your testing, refine the skill:
- Did Claude miss any steps? Make the instructions more explicit.
- Did Claude do something unexpected? Add rules to prevent it.
- Is the changelog format correct? Adjust the template.
Self-Assessment
- Identified a repeatable workflow to automate
- Created a skill file with proper frontmatter (title, description, triggers)
- Wrote clear step-by-step instructions in the skill body
- Defined triggers for automatic activation
- Tested the skill in a real scenario and it followed all steps
- Tested the failure case (Claude stops when tests fail)
- Refined the skill based on test results
How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.