Files
ai/gateway/src/harness/skills

Skills

Skills are individual capabilities that the agent can use to accomplish tasks. Each skill is a self-contained unit with:

  • A markdown definition file (*.skill.md)
  • A TypeScript implementation extending BaseSkill
  • Clear input/output contracts
  • Parameter validation
  • Error handling

Skill Structure

skills/
├── base-skill.ts              # Base class
├── {skill-name}.skill.md      # Definition
├── {skill-name}.ts            # Implementation
└── README.md                  # This file

Creating a New Skill

1. Create the Definition File

Create {skill-name}.skill.md:

# My Skill

**Version:** 1.0.0
**Author:** Your Name
**Tags:** category1, category2

## Description
What does this skill do?

## Inputs
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| param1 | string | Yes | What it does |

## Outputs
What does it return?

## Example Usage
Show code example

2. Create the Implementation

Create {skill-name}.ts:

import { BaseSkill, SkillInput, SkillResult, SkillMetadata } from './base-skill.js';

export class MySkill extends BaseSkill {
  getMetadata(): SkillMetadata {
    return {
      name: 'my-skill',
      description: 'What it does',
      version: '1.0.0',
    };
  }

  getParametersSchema(): Record<string, unknown> {
    return {
      type: 'object',
      required: ['param1'],
      properties: {
        param1: { type: 'string' },
      },
    };
  }

  validateInput(parameters: Record<string, unknown>): boolean {
    return typeof parameters.param1 === 'string';
  }

  async execute(input: SkillInput): Promise<SkillResult> {
    this.logStart(input);

    try {
      // Your implementation here
      const result = this.success({ data: 'result' });
      this.logEnd(result);
      return result;
    } catch (error) {
      return this.error(error as Error);
    }
  }
}

3. Register the Skill

Add to index.ts:

export { MySkill } from './my-skill.js';

Using Skills in Workflows

Skills can be used in LangGraph workflows:

import { MarketAnalysisSkill } from '../skills/market-analysis.js';

const analyzeNode = async (state) => {
  const skill = new MarketAnalysisSkill(logger, model);
  const result = await skill.execute({
    context: state.userContext,
    parameters: {
      ticker: state.ticker,
      period: '4h',
    },
  });

  return {
    analysis: result.data,
  };
};

Best Practices

  1. Single Responsibility: Each skill should do one thing well
  2. Validation: Always validate inputs thoroughly
  3. Error Handling: Use try/catch and return meaningful errors
  4. Logging: Use logStart() and logEnd() helpers
  5. Documentation: Keep the .skill.md file up to date
  6. Testing: Write unit tests for skill logic
  7. Idempotency: Skills should be safe to retry

Available Skills

  • market-analysis: Analyze market conditions and trends
  • (Add more as you build them)

Skill Categories

  • Market Data: Query and analyze market information
  • Trading: Execute trades, manage positions
  • Analysis: Technical and fundamental analysis
  • Risk: Risk assessment and management
  • Utilities: Helper functions and utilities