Home / Session 5
session-5.md — ~/hacking-with-ai
5

Skills, Extensions & MCP

Build domain-specific tools and connect to external systems

60 min Skills + MCP servers Loading...
Session 5 of 8

// Overview

Skills let you package domain-specific instructions with example files — invoked on demand with /skill-name. MCP (Model Context Protocol) connects Claude to external tools like databases and APIs. Together they form your AI extension layer.

Learning Objectives

// Setup

Create the skills directory structure

bash
cd my-full-app
mkdir -p .claude/skills
# Prepare to build your first skill
Verify: Directory structure created

// Challenge

Create a Java testing skill

25m +15m bonus

Build a skill that teaches Claude your team's Java testing patterns. Document patterns in a skill file and make it invocable with /java-testing.

✓ Success Criteria

  • Skill file has frontmatter (description)
  • Skill body has clear instructions
  • Uses @path imports to reference real test examples
  • Skill invoked with /java-testing
  • Generated tests match team style exactly
  • Uses $ARGUMENTS for parameterized input
⚠ Hints (click to reveal)
  • Use @path imports to reference the BEST test examples
  • Document both patterns and anti-patterns
  • Test by asking Claude to generate a test

Code Playground

Interactive

Try These Prompts

Analyze test patterns
Analyze FliptFeatureFlagClientTest and DltProcessorTest. Note the victim pattern, @Nested classes, BDD Mockito (given/when/then), and SimpleMeterRegistry assertions. What makes these tests excellent?
Find the exemplary tests first — these two are the best in the codebase
Expected: Claude identifies naming, structure, assertion patterns from real test files
Find best examples
Compare FliptFeatureFlagClientTest, DltProcessorTest, and any other strong test files. Which 2-3 should I include as @path imports in my java-testing skill? Explain the specific patterns each demonstrates.
Good examples teach better than documentation
Expected: Claude identifies exemplary tests with reasoning about specific patterns
Create SKILL.md
Help me write SKILL.md for a java-testing skill based on the patterns you found. Include the metadata section, instructions, and reference the context files.
Follow the progressive disclosure format
Expected: Claude creates properly structured SKILL.md
Test the skill
/java-testing Write tests for the MerchantService class that handles creating and fetching merchants.
Invoke your new skill
Expected: Generated tests should match team patterns exactly

Config Generator

Code Examples

Skill File Structure
---
description: Generate Java tests following team conventions
allowed-tools: [Read, Write, Edit, Bash, Grep, Glob]
hooks:
  PreToolUse:
    - matcher: Write
      body: "Verify test naming convention before writing"
---

# Java Testing Skill

## When to use
- Writing new unit tests
- Creating integration tests with Testcontainers
- Testing Kafka consumers/producers

Apply to: $ARGUMENTS

## Instructions
1. Use @Nested classes to group related tests
2. Follow naming: should{Action}When{Condition}
3. Use AssertJ for ALL assertions (not JUnit assertions)
4. Integration tests use @Testcontainers annotation

## Reference Examples
@src/test/java/com/example/ExampleUnitTest.java
@src/test/java/com/example/ExampleIntegrationIT.java

## DO NOT
- Do not use assertEquals (use AssertJ assertThat)
- Do not write tests without @DisplayName
- Do not mock repositories in integration tests
Skill Directory Structure
.claude/
  skills/
    java-testing.md           # Skill file (frontmatter + instructions)
    java-testing/             # Supporting files directory
      unit-test-template.java # Template files for the skill
      it-test-template.java   # More templates
    code-review.md            # Another skill
    refactor.md               # Another skill
  hooks/                      # Hook scripts directory
    pre-write-check.sh        # Runs before Write tool
    post-test-notify.sh       # Runs after test execution

Skill File Format:
1. Frontmatter (description, allowed-tools, optional flags)
2. Body (instructions, @path imports)
3. $ARGUMENTS placeholder for parameters

Dynamic Context Injection:
  !./mvnw dependency:tree     # Inject command output as context
  !cat build.gradle           # Works with any shell command
  Use in skill body for live project data

Portable Skills:
  ${CLAUDE_SKILL_DIR}            # References the skill's own directory
  Use in SKILL.md to reference local templates/files portably

Invoke with:
  /java-testing MerchantService
  /claude-api                     # Built-in skill for Claude API & Anthropic SDK
  /loop 5m check deploy status    # Bundled skill for recurring prompts

Install a plugin:
  claude plugin add <plugin-name>
  /plugin <name>                  # Invoke a plugin skill
  /reload-plugins                 # Apply pending plugin changes without restart

Plugin Manifest:
  .claude-plugin/plugin.json      # Plugin manifest file format

Plugin Sources:
  npm, git, local, git-subdir     # git-subdir points to a subdirectory in a git repo

Ecosystem Scale (Feb 2026):
  270+ plugins, 739 agent skills, 1298 standalone skills

Plugin Trust:
  Per-server approval dialog for MCP servers
  pluginTrustMessage in managed settings for org-custom trust context

Options in frontmatter:
  description: ...                # Required
  allowed-tools: [Read, Write]    # Restrict tool access
  disable-model-invocation: true  # Only model can invoke (not user-invocable)
  user-invocable: true            # User can invoke via /skill-name (default)
  context: fork                   # Run in isolated subagent context
  agent: Explore                  # Specify which subagent type (Explore, etc.)
  hooks: { PreToolUse: [...] }    # Skill-scoped hooks (command + prompt + MCP tool types)

Skill Arguments:
  $ARGUMENTS                      # All arguments as a single string
  $ARGUMENTS[0], $ARGUMENTS[1]    # Positional args by index
  $1, $2, $3                      # Shorthand positional args
  ${CLAUDE_SESSION_ID}             # Current session ID

Conditional Rules Files (.claude/rules/*.md):
  paths: ["src/test/**"]          # Only load when working on matching files
  Use frontmatter to scope rules to specific parts of the codebase

Hook Events (17 total):
  PreToolUse / PostToolUse        # Before/after tool execution
  PostToolUseFailure              # When a tool execution fails
  SessionStart / SessionEnd       # Session lifecycle
  UserPromptSubmit                # When user submits a prompt
  PermissionRequest               # When a permission is requested
  Notification                    # On notification events
  SubagentStart / SubagentStop    # Subagent lifecycle (agent teams)
  Stop                            # When agent stops
  TeammateIdle                    # When a teammate becomes idle
  TaskCompleted                   # When a task completes
  PreCompact                      # Before context compaction
  ConfigChange                    # When settings change
  WorktreeCreate / WorktreeRemove # Agent team worktree lifecycle
  InstructionsLoaded              # When CLAUDE.md or .claude/rules/*.md are loaded

Hook Types:
  Shell command hooks             # Run a shell command, inspect stdout/stderr
  HTTP hooks                      # POST JSON to a URL and receive JSON responses
  Prompt hooks                    # LLM-based evaluation instead of shell scripts
  MCP tool hooks                  # Hooks that invoke MCP tools

Scheduled Tasks:
  /loop 5m check deploy status    # Recurring prompts at intervals
  CronCreate / CronList / CronDelete  # Programmatic scheduling tools
  Session-scoped with 3-day expiry    # Tasks auto-expire after 3 days

// Key Takeaways

// Resources

Skills Documentation Hooks Documentation Plugins Documentation Scheduled Tasks MCP Documentation MCP Protocol Spec MCP Servers Repository Sandboxing