Lesson

Stacking Claude Skills to Create Complex Workflows

Learn how to chain Claude Skills by creating a compress skill that explicitly requires and uses a separate timestamp skill for powerful, multi-step automations.

Access
Included
Transcript
Needs source

While individual AI agent skills are powerful, their true potential is unlocked when they can be combined to perform more complex, multi-step tasks. One skill might need the output of another to complete its work, creating a dependency chain.

This lesson demonstrates how to build modular, composable skills that can call each other. We will create a compress skill that needs a timestamped filename, and we will instruct it to use a separate timestamp skill to get that information.

The Initial compress Skill

First, we define our compress skill. Its goal is to take files resulting from a user's request and archive them into a .tar.gz file. The desired filename format includes a timestamp, which we initially define as a placeholder.

---
name: compress
description: Compress the resulting files of a user's request
allowed-tools: [Write, Bash(tar:*)]
---
## Usage

```bash
tar -czvf <project-root>/compressions/<timestamp>-<file-name-based-on-the-user-request>.tar.gz <files-from-user-request>
```

When we first run this, the AI doesn't know about our separate timestamp skill. It simply tries to fill in the <timestamp> placeholder itself, resulting in an incorrect or guessed value.

Explicitly Defining a Dependency

To solve this, we can explicitly tell the compress skill that it has a dependency. By adding a ## Requirements section to its SKILL.md, we can instruct the agent to use another skill first.

---
name: compress
description: Compress the resulting files of a user's request
allowed-tools: [Write, Bash(tar:*)]
---
## Requirements

You must use the timestamp skill to create the timestamp.

## Usage

```bash
tar -czvf <project-root>/compressions/<timestamp>-<file-name-based-on-the-user-request>.tar.gz <files-from-user-request>
```

With this simple instruction, the agent's behavior changes completely. It now understands the workflow:

  1. Run the timestamp skill.
  2. Capture the output (the correctly formatted timestamp).
  3. Run the compress skill, substituting the output from the first step into its command.

Running the Workflow

With the dependency defined, we can now make a more complex request that requires creating a file and then compressing it.

claude "Please create a summary of @index.ts and then compress the summary."

The agent correctly follows the multi-step process:

  1. Analyzes index.ts and writes a new summary file (e.g., index-ts-summary.md).
  2. Executes the timestamp skill to get the current timestamp.
  3. Executes the compress skill, using the tar command to archive index-ts-summary.md into a file with the correct timestamped name.

This pattern of creating small, single-purpose skills and composing them through explicit requirements allows you to build sophisticated, reliable, and reusable workflows for your AI agent.