Claude
Skills
Sign in
Back

agent.define

Included with Lifetime
$97 forever

# agent.define Skill

AI Agents

What this skill does

# agent.define Skill

Validates and registers agent manifests for the Betty Framework.

## Purpose

The `agent.define` skill is the Layer 2 (Reasoning Layer) equivalent of `skill.define`. It validates agent manifests (`agent.yaml`) for schema compliance, verifies skill references, and updates the central Agent Registry.

## Capabilities

- Validate agent manifest structure and required fields
- Verify agent name and version formats
- Validate reasoning mode enum values
- Check that all referenced skills exist in skill registry
- Ensure capabilities and skills lists are non-empty
- Validate status lifecycle values
- Register valid agents in `/registry/agents.json`
- Update existing agent entries with new versions

## Usage

### Command Line

```bash
python skills/agent.define/agent_define.py <path_to_agent.yaml>
```

### Arguments

| Argument | Type | Required | Description |
|----------|------|----------|-------------|
| `manifest_path` | string | Yes | Path to the agent.yaml file to validate |

### Exit Codes

- `0`: Validation succeeded and agent was registered
- `1`: Validation failed or registration error

## Validation Rules

### Required Fields

All agent manifests must include:

| Field | Type | Validation |
|-------|------|------------|
| `name` | string | Must match `^[a-z][a-z0-9._-]*$` |
| `version` | string | Must follow semantic versioning |
| `description` | string | Non-empty string (1-200 chars recommended) |
| `capabilities` | array[string] | Must contain at least one item |
| `skills_available` | array[string] | Must contain at least one item, all skills must exist in registry |
| `reasoning_mode` | enum | Must be `iterative` or `oneshot` |

### Optional Fields

| Field | Type | Default | Validation |
|-------|------|---------|------------|
| `status` | enum | `draft` | Must be `draft`, `active`, `deprecated`, or `archived` |
| `context_requirements` | object | `{}` | Any valid object |
| `workflow_pattern` | string | `null` | Any string |
| `example_task` | string | `null` | Any string |
| `error_handling` | object | `{}` | Any valid object |
| `output` | object | `{}` | Any valid object |
| `tags` | array[string] | `[]` | Array of strings |
| `dependencies` | array[string] | `[]` | Array of strings |

### Name Format

Agent names must:
- Start with a lowercase letter
- Contain only lowercase letters, numbers, dots, hyphens, underscores
- Follow pattern: `<domain>.<action>`

**Valid**: `api.designer`, `compliance.checker`, `data-migrator`
**Invalid**: `ApiDesigner`, `1agent`, `agent_name`

### Version Format

Versions must follow semantic versioning: `MAJOR.MINOR.PATCH[-prerelease]`

**Valid**: `0.1.0`, `1.0.0`, `2.3.1-beta`, `1.0.0-rc.1`
**Invalid**: `1.0`, `v1.0.0`, `1.0.0.0`

### Reasoning Mode

Must be one of:
- `iterative`: Agent can retry with feedback and refine based on errors
- `oneshot`: Agent executes once without retry

### Skills Validation

All skills in `skills_available` must exist in the skill registry (`/registry/skills.json`).

## Response Format

### Success Response

```json
{
  "ok": true,
  "status": "success",
  "errors": [],
  "path": "agents/api.designer/agent.yaml",
  "details": {
    "valid": true,
    "errors": [],
    "path": "agents/api.designer/agent.yaml",
    "manifest": {
      "name": "api.designer",
      "version": "0.1.0",
      "description": "Design RESTful APIs...",
      "capabilities": [...],
      "skills_available": [...],
      "reasoning_mode": "iterative"
    },
    "status": "registered",
    "registry_updated": true
  }
}
```

### Failure Response

```json
{
  "ok": false,
  "status": "failed",
  "errors": [
    "Missing required fields: capabilities, skills_available",
    "Invalid reasoning_mode: 'hybrid'. Must be one of: iterative, oneshot"
  ],
  "path": "agents/bad.agent/agent.yaml",
  "details": {
    "valid": false,
    "errors": [
      "Missing required fields: capabilities, skills_available",
      "Invalid reasoning_mode: 'hybrid'. Must be one of: iterative, oneshot"
    ],
    "path": "agents/bad.agent/agent.yaml"
  }
}
```

## Examples

### Example 1: Validate Iterative Agent

**Agent Manifest** (`agents/api.designer/agent.yaml`):
```yaml
name: api.designer
version: 0.1.0
description: "Design RESTful APIs following enterprise guidelines"

capabilities:
  - Design RESTful APIs from requirements
  - Apply Zalando guidelines automatically
  - Generate OpenAPI 3.1 specs
  - Iteratively refine based on validation feedback

skills_available:
  - api.define
  - api.validate
  - api.generate-models

reasoning_mode: iterative

status: draft

tags:
  - api
  - design
  - openapi
```

**Command**:
```bash
python skills/agent.define/agent_define.py agents/api.designer/agent.yaml
```

**Output**:
```json
{
  "ok": true,
  "status": "success",
  "errors": [],
  "path": "agents/api.designer/agent.yaml",
  "details": {
    "valid": true,
    "status": "registered",
    "registry_updated": true
  }
}
```

### Example 2: Validation Errors

**Agent Manifest** (`agents/bad.agent/agent.yaml`):
```yaml
name: BadAgent  # Invalid: must be lowercase
version: 1.0   # Invalid: must be semver
description: "Test agent"
capabilities: []  # Invalid: must have at least one
skills_available:
  - nonexistent.skill  # Invalid: skill doesn't exist
reasoning_mode: hybrid  # Invalid: must be iterative or oneshot
```

**Command**:
```bash
python skills/agent.define/agent_define.py agents/bad.agent/agent.yaml
```

**Output**:
```json
{
  "ok": false,
  "status": "failed",
  "errors": [
    "Invalid name: Invalid agent name: 'BadAgent'. Must start with lowercase letter...",
    "Invalid version: Invalid version: '1.0'. Must follow semantic versioning...",
    "Invalid reasoning_mode: Invalid reasoning_mode: 'hybrid'. Must be one of: iterative, oneshot",
    "capabilities must contain at least one item",
    "Skills not found in registry: nonexistent.skill"
  ],
  "path": "agents/bad.agent/agent.yaml"
}
```

### Example 3: Oneshot Agent

**Agent Manifest** (`agents/api.analyzer/agent.yaml`):
```yaml
name: api.analyzer
version: 0.1.0
description: "Analyze API specifications for compatibility"

capabilities:
  - Detect breaking changes between API versions
  - Generate compatibility reports
  - Suggest migration paths

skills_available:
  - api.compatibility

reasoning_mode: oneshot

output:
  success:
    - Compatibility report
    - Breaking changes list
  failure:
    - Error analysis

status: active

tags:
  - api
  - analysis
  - compatibility
```

**Command**:
```bash
python skills/agent.define/agent_define.py agents/api.analyzer/agent.yaml
```

**Result**: Agent validated and registered successfully.

## Integration

### With Registry

The skill automatically updates `/registry/agents.json`:

```json
{
  "registry_version": "1.0.0",
  "generated_at": "2025-10-23T10:30:00Z",
  "agents": [
    {
      "name": "api.designer",
      "version": "0.1.0",
      "description": "Design RESTful APIs following enterprise guidelines",
      "reasoning_mode": "iterative",
      "skills_available": ["api.define", "api.validate", "api.generate-models"],
      "capabilities": ["Design RESTful APIs from requirements", ...],
      "status": "draft",
      "tags": ["api", "design", "openapi"],
      "dependencies": []
    }
  ]
}
```

### With Other Skills

- **Depends on**: `skill.define` (for skill registry validation)
- **Used by**: Future `command.define` skill (to register commands that invoke agents)
- **Complements**: `workflow.compose` (agents orchestrate skills; workflows execute fixed sequences)

## Common Errors

### Missing Skills in Registry

**Error**:
```
Skills not found in registry: api.nonexistent, data.missing
```

**Solution**: Ensure all skills in `skills_available` are registered in `/registry/skills.json`. Check skill names for typos.

### Invalid Reasoning Mode

**Error**:
```
Invalid reasoning_mode: 'hybrid'. Must be one of: iterative, oneshot
```

**Solution**: Use `iterative` for agents that ret
Files: 4
Size: 23.3 KB
Complexity: 28/100
Category: AI Agents

Related in AI Agents