Skip to main content

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:

  1. Run the project's test suite (use npm test or whatever test command your project uses)
  2. Check for lint errors (use npm run lint or equivalent)
  3. Stop if tests or lint fail — do not proceed with a broken build
  4. Stage all changes with git add
  5. Create a commit with a descriptive message based on the changes
  6. 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

  1. Create the skills directory:
mkdir -p .claude/skills
  1. Create .claude/skills/finish-feature.md with:
    • 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
Writing Good Skill Instructions

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

  1. Make a small code change in your project (create or modify a file)
  2. Start Claude Code: claude
  3. Tell Claude: "I'm done with this feature, please finish it up"
  4. Watch Claude follow your skill's instructions
  5. Verify that:
    • Tests and lint were checked
    • A commit was created
    • The changelog was updated

Part 4: Test the Failure Case

  1. Modify your package.json so the test script fails:
{
"scripts": {
"test": "echo 'FAIL: 2 tests failed' && exit 1",
"lint": "echo 'No lint errors'"
}
}
  1. Make a code change and ask Claude to finish the feature again
  2. Verify that Claude stops when tests fail and does not commit
warning

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

Help Us Improve

How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.

Give Feedback →