Skip to content

Your First Tool

Let's create a simple tool that explains code. You'll learn the basics of tool configuration.

Create the Tool

Run the interactive creator:

smarttools create

Or create the file manually at ~/.smarttools/explain/config.yaml:

name: explain
version: "1.0.0"
description: Explain code or concepts in simple terms
category: code

arguments:
  - flag: --level
    variable: level
    default: "beginner"
    description: "Explanation level: beginner, intermediate, or expert"

steps:
  - type: prompt
    provider: claude
    prompt: |
      Explain the following in simple terms suitable for a {level}:

      {input}

      Be concise but thorough. Use examples where helpful.
    output_var: explanation

output: "{explanation}"

Test Your Tool

# Explain some code
echo "def fib(n): return n if n < 2 else fib(n-1) + fib(n-2)" | explain

# Explain for an expert
cat complex_algorithm.py | explain --level expert

Understanding the Config

Arguments

Each argument becomes a CLI flag. The variable name is used in templates:

arguments:
  - flag: --level        # CLI flag: --level beginner
    variable: level      # Use as {level} in prompts
    default: "beginner"  # Default if not specified

Steps

Steps run in order. Each step can be a prompt or Python code:

steps:
  - type: prompt
    provider: claude     # Which AI to use
    prompt: "..."        # The prompt template
    output_var: result   # Store response in {result}

Output

The output template formats the final result:

output: "{explanation}"  # Print the explanation variable

Next Steps