YouTip LogoYouTip

Skills Multi Step

Simple tasks only require one step, but real-world workflows often involve multiple stages. This guide introduces how to break down complex tasks into clear steps and organize them into a reliable execution process in SKILL.md. * * * ## Why Explicitly Define Steps Claude is smart, but without explicit step guidance, it might skip certain stages or execute them in an inconsistent order. The benefits of explicit steps: First, it makes Claude's behavior predictable. Second, it helps users understand what's happening. Third, when errors occur, it's easy to identify which step caused the problem. * * * ## Basic Principles of Step Design | Principle | Description | | --- | --- | | One step, one task | Avoid completing multiple unrelated operations in a single step | | Clear input/output between steps | The output of the previous step is the input to the next, without relying on implicit state | | Feedback after each step | Inform the user what was completed and what comes next | | Allow interruption | Users can pause or modify parameters at any step | * * * ## Defining Multi-Step Processes in SKILL.md ## Example --- name: excel-report-generator description: > Generates a formatted Excel report based on user-uploaded raw data, including data cleaning, chart generation, and summary statistics. Triggered when users need data reports, Excel output, or automated statistics. --- # Excel Report Generator ## Execution Process ### Step 1: Read and Validate Data 1. Check if the file exists and if the format is .csv or .xlsx 2. Read the file and output basic information: - Total rows and columns - Data types of each column - Null value count statistics 3. If serious issues are found (e.g., empty file, unsupported format), stop and inform the user **Output**: Data basic information report (displayed in the conversation) --- ### Step 2: Data Cleaning Run `scripts/clean_data.py`, which executes: - Delete completely duplicate rows - Fill null values in numeric columns with 0 - Trim leading and trailing whitespace from strings Output cleaned data to `/home/claude/cleaned_data.csv` **Output**: Cleaning report (how many rows deleted, how many values modified) --- ### Step 3: Generate Statistical Summary Run `scripts/calc_stats.py`, which calculates: - Mean, median, and standard deviation for each numeric column - Trend data grouped by time column (if time column exists) Output to `/home/claude/stats.json` --- ### Step 4: Generate Excel Report Run `scripts/gen_excel.py`, which generates an Excel file containing: - Sheet1: Cleaned raw data - Sheet2: Statistical summary table - Sheet3: Line chart (if time series data exists) Save the final file to `/mnt/user-data/outputs/report_YYYYMMDD.xlsx` **Output**: Use present_files to display the file and provide download link --- ### Error Handling When any step fails: 1. Display the complete error message 2. Explain possible reasons 3. Ask the user if they want to skip the current step or modify parameters and retry * * * ## Organizing Step Scripts Each step in a multi-step process can correspond to an independent script file, or be combined into a single main script. ### Option One: One Script Per Step (Recommended for Complex Processes) excel-report-generator/β”œβ”€β”€ SKILL.md └── scripts/ β”œβ”€β”€ clean_data.py # Step 2: Data Cleaning β”œβ”€β”€ calc_stats.py # Step 3: Statistical Calculation └── gen_excel.py # Step 4: Generate Report ### Option Two: Single Main Script (Suitable for Simple Processes) ## Example # File path: scripts/pipeline.py # Single main script, uses --step parameter to control which step to execute import argparse import sys def step_clean(input_file: str, output_file: str) ->dict: """Step 2: Data Cleaning""" print(f"cleaning data:{input_file}") # actual data cleaning logic... return{"status": "success","removed_rows": 3,"fixed_values": 12} def step_stats(input_file: str, output_file: str) ->dict: """Step 3: Statistical Calculation""" print(f"calculating statistics:{input_file}") # actual statistics logic... return{"status": "success","columns_analyzed":
← Skills ToolchainSkills Error Handling β†’