Skip to main content

Creating Your First Skill

Skills are .hub YAML files that teach AI agents how to perform specific tasks. This guide walks you through creating one from scratch, testing it locally, and publishing it to the Hubify registry.

What You Will Build

By the end of this guide you will have a published .hub skill that any Hubify workspace can install with hubify install <your-skill>.

Prerequisites

  • Hubify CLI installed (npm install -g hubify)
  • Authenticated (hubify auth login)
  • A Hubify workspace (or a local project with hubify init run)
1

Create the skill directory

Every skill lives in its own directory with a .hub YAML manifest at the root.
mkdir api-error-handling
cd api-error-handling
hubify hub init --type skill
This scaffolds a api-error-handling.hub file with the required structure.
2

Define the YAML frontmatter

Open the .hub file and fill in the metadata. Every field in the YAML block tells the registry and other agents what this skill does, who wrote it, and where it applies.
---
name: api-error-handling
display_name: API Error Handling
version: 1.0.0
type: skill
description: |
  Patterns for handling API errors in TypeScript/JavaScript applications
  with proper typing, logging, and user feedback.
author: your-username
license: MIT

human_editable: false

category: coding
subcategory: error-handling
complexity: intermediate
platforms:
  - claude-code
  - cursor
  - windsurf
tags:
  - typescript
  - javascript
  - error-handling
  - api
use_cases:
  - Building REST API clients
  - Handling fetch/axios errors
  - Creating error boundaries
tool_calls:
  - file_read
  - file_write
---
human_editable: false is required for publishing. This tells the registry that the skill is agent-executable, not a human-editable document.
3

Write the skill instructions

Below the YAML frontmatter, write the markdown body. This is what agents read when they execute the skill. Be specific, include real code, and handle edge cases.
# API Error Handling

## Overview

This skill provides patterns for handling API errors in TypeScript/JavaScript
applications with proper typing, logging, and user feedback.

## When to Apply

Apply this skill when:
- Building REST API clients
- Handling fetch/axios errors
- Implementing error boundaries
- Creating user-friendly error messages

## Instructions

### 1. Create Typed Error Classes

Always define typed error classes for different error scenarios:

\`\`\`typescript
export class ApiError extends Error {
  constructor(
    message: string,
    public statusCode: number,
    public endpoint: string
  ) {
    super(message);
    this.name = 'ApiError';
  }
}

export class NetworkError extends Error {
  constructor(message: string, public originalError: Error) {
    super(message);
    this.name = 'NetworkError';
  }
}
\`\`\`

### 2. Create Error Handler Wrapper

Wrap API calls with consistent error handling:

\`\`\`typescript
async function apiRequest<T>(
  endpoint: string,
  options: RequestInit = {}
): Promise<T> {
  try {
    const response = await fetch(endpoint, options);
    if (!response.ok) {
      throw new ApiError(
        `API request failed: ${response.statusText}`,
        response.status,
        endpoint
      );
    }
    return response.json();
  } catch (error) {
    if (error instanceof ApiError) throw error;
    throw new NetworkError('Network request failed', error as Error);
  }
}
\`\`\`

### 3. Implement Retry Logic

Add retry logic for transient failures:

\`\`\`typescript
async function withRetry<T>(
  operation: () => Promise<T>,
  maxRetries = 3,
  delay = 1000
): Promise<T> {
  let lastError: Error;
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
    try {
      return await operation();
    } catch (error) {
      lastError = error as Error;
      if (attempt < maxRetries && isRetryable(error)) {
        await sleep(delay * attempt);
        continue;
      }
      throw error;
    }
  }
  throw lastError!;
}
\`\`\`

## Common Pitfalls

- Do not swallow errors silently -- always log or re-throw
- Do not expose internal error details to end users -- map to friendly messages
- Do not forget request timeouts -- add AbortController for every fetch call
4

Validate the skill

Run the validator to make sure the .hub file is structurally correct before publishing.
hubify hub validate api-error-handling.hub
Expected output:
  .hub Validation Results

  File: /path/to/api-error-handling.hub

  ✓ Valid .hub file

  Parsed Metadata:
    Name:           api-error-handling
    Version:        1.0.0
    Type:           skill
    Author:         your-username
    License:        MIT
    Human Editable: false
5

Test locally

Before publishing, verify the skill works with your agent. Copy it into your workspace skills directory and use it.
# Copy into your workspace
cp api-error-handling.hub ~/my-workspace/skills/api-error-handling/

# Use with Claude Code (or your preferred agent)
cd ~/my-workspace
claude "Using the api-error-handling skill, add error handling to src/api/client.ts"
Verify the agent follows the instructions correctly and produces the expected code patterns.
6

Run sandbox test (optional)

Hubify provides E2B sandbox environments for automated skill testing. This runs the skill in an isolated container and validates that code examples compile and execute.
hubify test api-error-handling.hub
  E2B Sandbox Test

  Skill: api-error-handling
  Environment: Node.js 22

  Running tests...
    ✓ Skill instructions parse correctly
    ✓ Code examples are valid TypeScript
    ✓ Examples execute without errors

  Sandbox test passed.
7

Publish to the registry

When you are satisfied the skill works, publish it.
hubify publish api-error-handling.hub
The skill goes through the 5-gate Trust Gateway:
  1. Schema validation — YAML structure and required fields
  2. Provenance verification — author identity check
  3. Content security scan — prompt injection, malware, data exfiltration patterns
  4. Reputation check — author history and trust score
  5. E2B sandbox test — automated execution in isolated environment
  Publishing api-error-handling...

  Trust Gateway:
    ✓ Gate 1: Schema validation passed
    ✓ Gate 2: Provenance verified
    ✓ Gate 3: Content security scan clean
    ✓ Gate 4: Reputation check passed
    ✓ Gate 5: Sandbox test passed

  Published: api-error-handling@1.0.0

  Your skill is now live at:
  https://hubify.com/skills/api-error-handling

  Initial trust metrics:
    Confidence:         0.00 (no executions yet)
    Verification Level: 0 (untested)
8

Build trust through execution reports

After publishing, use the skill in real projects and report results. Every report from every agent builds the skill’s confidence score.
# Report a successful execution
hubify report api-error-handling --result success

# Report with an improvement suggestion
hubify report api-error-handling \
  --result success \
  --improvement "Add pattern for handling 429 rate limit errors with exponential backoff"
Trust levels grow with real usage:
StageExecutionsConfidenceLevel
New00.000 (untested)
Early10-500.60-0.701 (sandbox)
Growing50-5000.70-0.852 (field)
Mature500+0.85+3 (battle-tested)

How Skills Evolve

Once your skill is published, it enters the self-evolution loop:
  1. Agents across the network execute it in real projects
  2. Agents report improvements via hubify report
  3. When 3 or more similar improvements accumulate, auto-evolution triggers
  4. Claude Sonnet drafts an improved version
  5. The new version enters canary deployment (tested against the old version)
  6. If the canary succeeds, the improvement is promoted
You do not need to manually update your skill. The collective intelligence network improves it for you.

Tips

Be specific in your instructions. Vague guidance like “handle errors properly” leads to inconsistent results. Include concrete code examples with actual function signatures.
Always include a “When to Apply” section. This helps agents decide whether your skill is relevant to the current task before they load the full instructions.
Document common pitfalls. Agents learn from negative patterns just as much as positive ones.
Test across platforms. A skill that works on Claude Code might need adjustments for Cursor or Windsurf. Specify supported platforms in the platforms field.

Next Steps

Publishing Guide

Advanced publishing options and versioning

HUB.yaml Format

Complete .hub / HUB.yaml specification

For Agents

How agents discover and execute skills

CLI Reference

All CLI commands