- Lab
-
Libraries: If you want this lab, consider one of these libraries.
AI Ready: Advanced Claude Code Lab
Beyond simply having Claude Code troubleshoot, code, and work with your applications and services via the Claude prompt, you can further extend Claude Code’s abilities through the use of a Model Context Protocol (MCP) server, skills, subagents, git worktrees, and hook events. In this lab, you’ll get hands-on with all of these, by first setting up Claude Code to work with an MCP server for troubleshooting tickets, then standardizing a shared workflow in the CLAUDE file. Next, you’ll create a Claude skill for reading tickets, then set up subagents, work in parallel with git worktrees, and finally create Claude event hooks to log Claude’s activity and prevent blocked actions.
Lab Info
Table of Contents
-
Challenge
Introduction
Claude Code offers a number of extensions and advanced features that let you more effectively use Claude with your coding projects. These include the ability to connect to Model Context Protocol (MCP) servers, use skills to consistently perform repetitive actions, work with subagents to perform specialized tasks, leverage git worktrees to perform tasks in parallel, and use hook events to trigger actions before or after certain tools are used.
A Python-based MCP ticketing server is provided and already running in the lab environment. This server contains a number of tickets that track bugs and other issues you (that is, Claude) need to resolve throughout the duration of this lab.
-
Challenge
Claude Code and Model Context Protocol Servers
MCP servers work as an adapter between your AI agent, such as Claude, and an external data source – in this case, a ticket tracking service that records bugs and tasks that need to be resolved within an application.
Without an MCP server, to work with an existing data source, Claude often needs to leverage a wide variety of tools, tool schemas, and functions to perform the required task. An MCP streamlines this process, working as an integration layer that provides Claude with everything it needs to work with the external service. MCP servers also provide the benefit of standardizing how Claude will work – Claude will not need additional context to rediscover how to work with the server every time it needs to work with the external data source; it just uses the tools provided in the connection layer to perform the task(s).
To connect to an MCP server use the
claude mcp addcommand, providing a server name and details about how to connect to the server. For this lab, a local ticket server is provided via Python script. To launch it, you'll reference Python via the virtual environment with"$(pwd)/.venv/bin/python"and the server itself with"$(pwd)/server/ticket_server.py". Since Claude is what is launching the server, using absolute pathing ensures everything will start correctly. By default, Claude Code does not show results from the MCP tool that are longer than 50,000 characters. Instead, it saves the text to a file and shows a preview of the results. You can alter this behavior through the use of theMAX_RESULTS_CHARSsetting. To change this or any setting for an MCP server, use the-eflag when connecting the server. Up until this point, you have configured the MCP server to work with a private, local entry – notice the--localin the previousclaude mcp addcommands. To have the MCP server work for anyone who works with the project, you can set up the scope so it's project-level. This creates a.mcp.jsonfile in the project directory that will be available for anyone who clones the project. -
Challenge
Standardizing with project instructions and skills
Most often, you will not be the sole person working on a project, and you will not be the only person using Claude with that project. To ensure Claude works consistently across shared projects, you should do things like provide project instructions in the
CLAUDE.mdfile, which is read by Claude whenever started within the project; and provide reusable Claude skills that consistently perform common tasks within the project itself.The project in this lab already has a
CLAUDE.mdfile with basic information about the project. The configurations for skills are also provided in theticket-server/claude/skillsdirectory; these are not in the appropriate spot for Claude to use them and are not yet enabled. To add reusable Claude skills to the project, create and define a skill in aSKILL.mdfile within a.claude/skills/<skill-name>/directory. Skills can be set up so Claude only uses specific, defined tools and commands; and skills can be configured so they can only be run manually by the user or Claude can automatically run it when it thinks the skill will be appropriate. Thefix-ticketskill requires the user to manually run it for Claude to use it. In contrast, you can also configure skills so Claude will use them when it deems appropriate without the need for a user to manually run the skill. This was disabled via thedisable-model-invocationparameter in the previous skill, but is otherwise enabled by default. -
Challenge
Delegating work with subagents
Subagents are specialized AI workers that can be run in parallel with your regular Claude session. These agents are provided with instructions and limited tools to perform their tasks, and have their own context and context window. Once a subagent completes its task, it sends a report back to Claude.
The primary difference between skills and subagents is this use of context: skills work within the context of the current conversation; whereas subagents only have the context that is provided within the subagent configuration, and therefore always work with fresh context. This isolates the work and can limit token spend.
Subagents are configured for a project in the
.claude/agentsdirectory, and, like skills, are configured within a markdown file. -
Challenge
Using git worktrees
A git worktree lets you check out multiple git branches in a single repository in parallel by working in different directories. When paired with Claude, it means Claude can run two or more sessions at the same time, and resolve multiple issues at once without touching the files of another session. To use worktrees with Claude Code, use the
--worktreeflag to define the name of the desired worktree. The worktree itself will be created from the latest commit. -
Challenge
Automating tasks with hooks
A hook is a script or command that Claude runs automatically before or after certain actions are performed. Hooks are ideal for enforcing project rules, automating tasks, and integrating Claude Code with existing workflows and standards.
A
PreToolUsehook is set to run before a tool is used, and can even block the use of certain tools.PostToolUsehooks run after a tool is used. Hooks are defined in the Claude settings using JSON, and given that they contain code and commands that affect how Claude works with your greater project, should always be tested before being added. Hooks also expect to receive a JSON description of the action in standard input to perform its action. The hooks are now set up for use locally—notice the.localin the Claude settings file. Hooks, like skills, can also be shared with the greater project using the project's shared settings at.claude/settings.json. Before sharing, however, you should test the hooks with Claude itself and not just the setup script.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.