Building Reusable Claude Code Skills

Lesson 2: Writing Effective Skills

Lesson Objectives

By the end of this lesson, students should be able to:

  • Write trigger conditions that activate reliably and specifically
  • Structure Skill instructions for Claude's effective use
  • Apply the Skill writing patterns that produce consistent behavior
  • Avoid the common Skill writing mistakes that produce unreliable activation

Lesson Content

Skill file structure.

A Skill is a markdown file with a frontmatter header and instruction content (verify current format at docs.anthropic.com/en/docs/claude-code):

—
name: pr-code-review
description: Step-by-step code review checklist for pull requests
triggers:
– "review this PR"
– "review this code"
– "code review"
– "check this diff"
—

## PR Code Review Checklist

When reviewing a PR, check in this order:

1. **Security**: Input validation on user-supplied data, authentication/authorization checks, no hardcoded credentials
2. **Test coverage**: Are the happy path and error cases covered? Do tests test behavior or implementation?
3. **Error handling**: Are errors caught and handled or propagated appropriately?
4. **Readability**: Variable names, function names, and logic are clear without comments
5. **Performance**: Are there obvious N+1 queries, unnecessary re-computation, or missing indexes?

For each item: pass, flag for discussion, or request change.

Writing effective triggers.

Triggers are the phrases or conditions that activate the Skill. Effective triggers:

  • Match the natural language a user would use when requesting the task
  • Include variations (formal and informal phrasings)
  • Are specific enough to avoid false activation
  • Are not so narrow that they miss legitimate requests

For a code review Skill: ["review this PR", "code review", "review this code", "check this diff", "review my changes"] – multiple phrasings of the same intent.

Instruction structure for Skills.

Structure Skill instructions as procedural guidance Claude follows:

  • Use numbered steps for ordered workflows
  • Use checklists for evaluation tasks
  • Use clear headers to organize multi-part instructions
  • Keep instructions actionable ("check for X", "verify that Y") not descriptive ("X is important")

Common Skill writing mistakes.

  • Triggers too broad: A trigger of "code" activates for any code-related task – not just review
  • Triggers too narrow: A trigger of "review PR #123" activates for nothing useful
  • Instructions too vague: "Review for quality" is not actionable; "Check for unhandled null returns" is
  • Instructions too long: A 500-word Skill dilutes the key points; keep Skills focused on the most important checks for the specific task

Enroll to continue this lesson.

The preview above shows the lesson objectives and opening lesson content. Enroll to view the full lesson, complete the practice work, and take the lesson quiz.

Log In / Create Account
Back to Course